michael@0: // Copyright (c) 2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_STRINGS_NULLABLE_STRING16_H_ michael@0: #define BASE_STRINGS_NULLABLE_STRING16_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/strings/string16.h" michael@0: michael@0: namespace base { michael@0: michael@0: // This class is a simple wrapper for string16 which also contains a null michael@0: // state. This should be used only where the difference between null and michael@0: // empty is meaningful. michael@0: class NullableString16 { michael@0: public: michael@0: NullableString16() : is_null_(true) { } michael@0: NullableString16(const string16& string, bool is_null) michael@0: : string_(string), is_null_(is_null) { michael@0: } michael@0: michael@0: const string16& string() const { return string_; } michael@0: bool is_null() const { return is_null_; } michael@0: michael@0: private: michael@0: string16 string_; michael@0: bool is_null_; michael@0: }; michael@0: michael@0: inline bool operator==(const NullableString16& a, const NullableString16& b) { michael@0: return a.is_null() == b.is_null() && a.string() == b.string(); michael@0: } michael@0: michael@0: inline bool operator!=(const NullableString16& a, const NullableString16& b) { michael@0: return !(a == b); michael@0: } michael@0: michael@0: BASE_EXPORT std::ostream& operator<<(std::ostream& out, michael@0: const NullableString16& value); michael@0: michael@0: } // namespace michael@0: michael@0: #endif // BASE_STRINGS_NULLABLE_STRING16_H_