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
3 // found in the LICENSE file.
5 #ifndef BASE_STRINGS_NULLABLE_STRING16_H_
6 #define BASE_STRINGS_NULLABLE_STRING16_H_
10 #include "base/base_export.h"
11 #include "base/strings/string16.h"
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
17 // empty is meaningful.
18 class NullableString16
{
20 NullableString16() : is_null_(true) { }
21 NullableString16(const string16
& string
, bool is_null
)
22 : string_(string
), is_null_(is_null
) {
25 const string16
& string() const { return string_
; }
26 bool is_null() const { return is_null_
; }
33 inline bool operator==(const NullableString16
& a
, const NullableString16
& b
) {
34 return a
.is_null() == b
.is_null() && a
.string() == b
.string();
37 inline bool operator!=(const NullableString16
& a
, const NullableString16
& b
) {
41 BASE_EXPORT
std::ostream
& operator<<(std::ostream
& out
,
42 const NullableString16
& value
);
46 #endif // BASE_STRINGS_NULLABLE_STRING16_H_