Home | History | Annotate | Download | only in bindings

Lines Matching defs:String

10 #include <string>
18 // A UTF-8 encoded character string that can be null. Provides functions that
19 // are similar to std::string, along with access to the underlying std::string
21 class String {
23 // Constructs an empty string.
24 String() : is_null_(false) {}
25 String(const std::string& str) : value_(str), is_null_(false) {}
26 String(const char* chars) : is_null_(!chars) {
30 String(const char* chars, size_t num_chars)
32 String(const mojo::String& str)
36 String(const char chars[N])
39 String(std::string&& other) : value_(std::move(other)), is_null_(false) {}
40 String(String&& other) : is_null_(true) { Swap(&other); }
43 static String From(const U& other) {
44 return TypeConverter<String, U>::Convert(other);
49 return TypeConverter<U, String>::Convert(*this);
52 String& operator=(const mojo::String& str) {
57 String& operator=(const std::string& str) {
62 String& operator=(const char* chars) {
72 String& operator=(std::string&& other) {
77 String& operator=(String&& other) {
93 const std::string& get() const { return value_; }
94 operator const std::string&() const { return value_; }
96 // Returns a const reference to the |std::string| managed by this class. If
97 // the string is null, this will be an empty std::string.
98 const std::string& storage() const { return value_; }
100 // Passes the underlying storage and resets this string to null.
101 std::string PassStorage() {
106 void Swap(String* other) {
111 void Swap(std::string* other) {
117 typedef std::string String::*Testable;
120 operator Testable() const { return is_null_ ? 0 : &String::value_; }
123 std::string value_;
127 inline bool operator==(const String& a, const String& b) {
130 inline bool operator==(const char* a, const String& b) {
133 inline bool operator==(const String& a, const char* b) {
136 inline bool operator!=(const String& a, const String& b) {
139 inline bool operator!=(const char* a, const String& b) {
142 inline bool operator!=(const String& a, const char* b) {
146 inline std::ostream& operator<<(std::ostream& out, const String& s) {
150 inline bool operator<(const String& a, const String& b) {
162 struct TypeConverter<String, std::string> {
163 static String Convert(const std::string& input) { return String(input); }
167 struct TypeConverter<std::string, String> {
168 static std::string Convert(const String& input) { return input; }
172 struct TypeConverter<String, char[N]> {
173 static String Convert(const char input[N]) {
175 return String(input, N - 1);
181 struct TypeConverter<String, const char[N]> {
182 static String Convert(const char input[N]) {
184 return String(input, N - 1);
189 struct TypeConverter<String, const char*> {
190 // |input| may be null, in which case a null String will be returned.
191 static String Convert(const char* input) { return String(input); }