OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 BASE_STRINGS_NULLABLE_STRING16_H_ | 5 #ifndef BASE_STRINGS_NULLABLE_STRING16_H_ |
6 #define BASE_STRINGS_NULLABLE_STRING16_H_ | 6 #define BASE_STRINGS_NULLABLE_STRING16_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 // This class is a simple wrapper for string16 which also contains a null | 15 // This class is a simple wrapper for string16 which also contains a null |
16 // state. This should be used only where the difference between null and | 16 // state. This should be used only where the difference between null and |
17 // empty is meaningful. | 17 // empty is meaningful. |
18 class NullableString16 { | 18 class NullableString16 { |
19 public: | 19 public: |
20 NullableString16() : is_null_(true) { } | 20 NullableString16() : is_null_(true) { } |
21 explicit NullableString16(bool is_null) : is_null_(is_null) { } | |
michaeln
2013/06/17 23:48:12
i guess we never construct the oddball non-null em
| |
22 NullableString16(const string16& string, bool is_null) | 21 NullableString16(const string16& string, bool is_null) |
23 : string_(string), is_null_(is_null) { | 22 : string_(string), is_null_(is_null) { |
24 } | 23 } |
25 | 24 |
26 const string16& string() const { return string_; } | 25 const string16& string() const { return string_; } |
27 bool is_null() const { return is_null_; } | 26 bool is_null() const { return is_null_; } |
28 | 27 |
29 private: | 28 private: |
30 string16 string_; | 29 string16 string_; |
31 bool is_null_; | 30 bool is_null_; |
(...skipping 10 matching lines...) Expand all Loading... | |
42 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 41 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
43 const NullableString16& value); | 42 const NullableString16& value); |
44 | 43 |
45 } // namespace | 44 } // namespace |
46 | 45 |
47 // TODO(avi) update users of NullableString16 to use the namespace and remove | 46 // TODO(avi) update users of NullableString16 to use the namespace and remove |
48 // this "using". | 47 // this "using". |
49 using base::NullableString16; | 48 using base::NullableString16; |
50 | 49 |
51 #endif // BASE_STRINGS_NULLABLE_STRING16_H_ | 50 #endif // BASE_STRINGS_NULLABLE_STRING16_H_ |
OLD | NEW |