1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/strings/nullable_string16.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_STRINGS_NULLABLE_STRING16_H_ 1.9 +#define BASE_STRINGS_NULLABLE_STRING16_H_ 1.10 + 1.11 +#include <iosfwd> 1.12 + 1.13 +#include "base/base_export.h" 1.14 +#include "base/strings/string16.h" 1.15 + 1.16 +namespace base { 1.17 + 1.18 +// This class is a simple wrapper for string16 which also contains a null 1.19 +// state. This should be used only where the difference between null and 1.20 +// empty is meaningful. 1.21 +class NullableString16 { 1.22 + public: 1.23 + NullableString16() : is_null_(true) { } 1.24 + NullableString16(const string16& string, bool is_null) 1.25 + : string_(string), is_null_(is_null) { 1.26 + } 1.27 + 1.28 + const string16& string() const { return string_; } 1.29 + bool is_null() const { return is_null_; } 1.30 + 1.31 + private: 1.32 + string16 string_; 1.33 + bool is_null_; 1.34 +}; 1.35 + 1.36 +inline bool operator==(const NullableString16& a, const NullableString16& b) { 1.37 + return a.is_null() == b.is_null() && a.string() == b.string(); 1.38 +} 1.39 + 1.40 +inline bool operator!=(const NullableString16& a, const NullableString16& b) { 1.41 + return !(a == b); 1.42 +} 1.43 + 1.44 +BASE_EXPORT std::ostream& operator<<(std::ostream& out, 1.45 + const NullableString16& value); 1.46 + 1.47 +} // namespace 1.48 + 1.49 +#endif // BASE_STRINGS_NULLABLE_STRING16_H_