Home | History | Annotate | Download | only in internal

Lines Matching defs:String

34 // This header file declares the String class and functions used internally by
44 #include <string.h>
50 // String - a UTF-8 string class.
52 // We cannot use std::string as Microsoft's STL implementation in
57 // Also, String is different from std::string in that it can represent
58 // both NULL and the empty string, while std::string cannot represent
61 // NULL and the empty string are considered different. NULL is less
62 // than anything (including the empty string) except itself.
66 // string class here.
69 // std::string on platforms where it cannot be used, we define a copy
73 // In order to make the representation efficient, the d'tor of String
74 // is not virtual. Therefore DO NOT INHERIT FROM String.
75 class String {
96 // This is useful for printing a C string in the syntax of a literal.
99 static String ShowCStringQuoted(const char* c_str);
101 // Clones a 0-terminated C string, allocating memory using new. The
103 // delete[]. Returns the cloned string, or NULL if the input is
106 // This is different from strdup() in string.h, which allocates
113 // NULL C string is considered different to any non-NULL C string,
114 // including the empty string.
117 // Converts a wide C string to a String using the UTF-8 encoding.
119 // the conversion, "(failed to convert from wide string)" is
121 static String ShowWideCString(const wchar_t* wide_c_str);
124 // the converted string in double quotes.
125 static String ShowWideCStringQuoted(const wchar_t* wide_c_str);
131 // NULL C string is considered different to any non-NULL C string,
132 // including the empty string.
139 // A NULL C string is considered different to any non-NULL C string,
140 // including the empty string.
144 // Formats a list of arguments to a String, using the same format
145 // spec string as for printf.
153 static String Format(const char* format, ...);
157 // The default c'tor constructs a NULL string.
158 String() : c_str_(NULL) {}
160 // Constructs a String by cloning a 0-terminated C string.
161 String(const char* c_str) : c_str_(NULL) { // NOLINT
165 // Constructs a String by copying a given number of chars from a
166 // buffer. E.g. String("hello", 3) will create the string "hel".
167 String(const char* buffer, size_t len);
169 // The copy c'tor creates a new copy of the string. The two
170 // String objects do not share content.
171 String(const String& str) : c_str_(NULL) {
175 // D'tor. String is intended to be a final class, so the d'tor
177 ~String() { delete[] c_str_; }
179 // Returns true iff this is an empty string (i.e. "").
184 // Compares this with another String.
187 int Compare(const String& rhs) const;
189 // Returns true iff this String equals the given C string. A NULL
190 // string and a non-NULL string are considered not equal.
195 // Returns true iff this String doesn't equal the given C string. A NULL
196 // string and a non-NULL string are considered not equal.
201 // Returns true iff this String ends with the given suffix. *Any*
202 // String is considered to end with a NULL or empty suffix.
205 // Returns true iff this String ends with the given suffix, not considering
206 // case. Any String is considered to end with a NULL or empty suffix.
209 // Returns the length of the encapsulated string, or -1 if the
210 // string is NULL.
215 // Gets the 0-terminated C string this String object represents.
216 // The String object still owns the string. Therefore the caller
220 // Sets the 0-terminated C string this String object represents.
221 // The old string in this object is deleted, and this object will
222 // own a clone of the input string. This function copies only up to
230 // Assigns a C string to this object. Self-assignment works.
231 const String& operator=(const char* c_str);
233 // Assigns a String object to this object. Self-assignment works.
234 const String& operator=(const String &rhs) {
243 // Streams a String to an ostream.
244 inline ::std::ostream& operator <<(::std::ostream& os, const String& str) {
245 // We call String::ShowCString() to convert NULL to "(null)".
247 return os << String::ShowCString(str.c_str());
250 // Gets the content of the StrStream's buffer as a String. Each '\0'
252 String StrStreamToString(StrStream* stream);
254 // Converts a streamable value to a String. A NULL pointer is
255 // converted to "(null)". When the input value is a ::string,
256 // ::std::string, ::wstring, or ::std::wstring object, each NUL
263 String StreamableToString(const T& streamable);