| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| 12 #include "mojo/public/cpp/bindings/type_converter.h" | 13 #include "mojo/public/cpp/bindings/type_converter.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 | 17 |
| 17 class String { | 18 class String { |
| 18 public: | 19 public: |
| 20 typedef internal::String_Data Data_; |
| 21 |
| 19 String() : is_null_(true) {} | 22 String() : is_null_(true) {} |
| 20 String(const std::string& str) : value_(str), is_null_(false) {} | 23 String(const std::string& str) : value_(str), is_null_(false) {} |
| 21 String(const char* chars) : is_null_(!chars) { | 24 String(const char* chars) : is_null_(!chars) { |
| 22 if (chars) | 25 if (chars) |
| 23 value_ = chars; | 26 value_ = chars; |
| 24 } | 27 } |
| 25 String(const char* chars, size_t num_chars) | 28 String(const char* chars, size_t num_chars) |
| 26 : value_(chars, num_chars), | 29 : value_(chars, num_chars), |
| 27 is_null_(false) { | 30 is_null_(false) { |
| 28 } | 31 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 public: | 145 public: |
| 143 // |input| may be null, in which case a null String will be returned. | 146 // |input| may be null, in which case a null String will be returned. |
| 144 static String ConvertFrom(const char* input) { | 147 static String ConvertFrom(const char* input) { |
| 145 return String(input); | 148 return String(input); |
| 146 } | 149 } |
| 147 }; | 150 }; |
| 148 | 151 |
| 149 } // namespace mojo | 152 } // namespace mojo |
| 150 | 153 |
| 151 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ | 154 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ |
| OLD | NEW |