41 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ 42 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ 92 static String ShowCStringQuoted(
const char* c_str);
101 static const char* CloneCString(
const char* c_str);
103 #if GTEST_OS_WINDOWS_MOBILE 116 static LPCWSTR AnsiToUtf16(
const char* c_str);
126 static const char* Utf16ToAnsi(LPCWSTR utf16_str);
134 static bool CStringEquals(
const char* lhs,
const char* rhs);
140 static String ShowWideCString(
const wchar_t* wide_c_str);
144 static String ShowWideCStringQuoted(
const wchar_t* wide_c_str);
152 static bool WideCStringEquals(
const wchar_t* lhs,
const wchar_t* rhs);
175 static bool CaseInsensitiveWideCStringEquals(
const wchar_t* lhs,
187 static String Format(
const char* format, ...);
196 if (a_c_str == NULL) {
200 ConstructNonNull(a_c_str, strlen(a_c_str));
208 String(
const char* buffer,
size_t a_length) {
209 ConstructNonNull(buffer, a_length);
227 ConstructNonNull(str.c_str(), str.length());
232 #if GTEST_HAS_GLOBAL_STRING 234 ConstructNonNull(str.c_str(), str.length());
238 #endif // GTEST_HAS_GLOBAL_STRING 241 bool empty()
const {
return (c_str() != NULL) && (length() == 0); }
246 int Compare(
const String& rhs)
const;
250 bool operator==(
const char* a_c_str)
const {
return Compare(a_c_str) == 0; }
258 bool operator!=(
const char* a_c_str)
const {
return !(*
this == a_c_str); }
262 bool EndsWith(
const char* suffix)
const;
266 bool EndsWithCaseInsensitive(
const char* suffix)
const;
270 size_t length()
const {
return length_; }
275 const char*
c_str()
const {
return c_str_; }
279 return *
this =
String(a_c_str);
286 if (rhs.
c_str() == NULL) {
303 char*
const str =
new char[a_length + 1];
304 memcpy(str, buffer, a_length);
305 str[a_length] =
'\0';
317 if (str.
c_str() == NULL) {
320 const char*
const c_str = str.
c_str();
321 for (
size_t i = 0; i != str.
length(); i++) {
322 if (c_str[i] ==
'\0') {
344 template <
typename T>
350 #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
Definition: gmock-matchers.h:2795
Definition: gmock-actions.h:49
size_t length() const
Definition: gtest-string.h:270
inline::std::ostream & operator<<(::std::ostream &os, const String &str)
Definition: gtest-string.h:316
bool operator==(const char *a_c_str) const
Definition: gtest-string.h:250
::std::string string
Definition: gtest-port.h:756
GTEST_API_ String StringStreamToString(::std::stringstream *stream)
Definition: gtest.cc:1735
const char * c_str_
Definition: gtest-string.h:310
#define GTEST_API_
Definition: gtest-port.h:662
bool operator<(const String &rhs) const
Definition: gtest-string.h:254
size_t length_
Definition: gtest-string.h:311
const char * c_str() const
Definition: gtest-string.h:275
String(const ::std::string &str)
Definition: gtest-string.h:226
const String & operator=(const char *a_c_str)
Definition: gtest-string.h:278
~String()
Definition: gtest-string.h:218
bool operator!=(const char *a_c_str) const
Definition: gtest-string.h:258
void ConstructNonNull(const char *buffer, size_t a_length)
Definition: gtest-string.h:302
const String & operator=(const String &rhs)
Definition: gtest-string.h:283
bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
Definition: gmock-matchers.h:854
Definition: gtest-string.h:81
bool empty() const
Definition: gtest-string.h:241
Definition: InputPrereqs.h:78
String(const char *a_c_str)
Definition: gtest-string.h:195
String()
Definition: gtest-string.h:192
String(const String &str)
Definition: gtest-string.h:214
String(const char *buffer, size_t a_length)
Definition: gtest-string.h:208
String StreamableToString(const T &streamable)
Definition: gtest.h:172