security/sandbox/chromium/base/strings/nullable_string16.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_STRINGS_NULLABLE_STRING16_H_
michael@0 6 #define BASE_STRINGS_NULLABLE_STRING16_H_
michael@0 7
michael@0 8 #include <iosfwd>
michael@0 9
michael@0 10 #include "base/base_export.h"
michael@0 11 #include "base/strings/string16.h"
michael@0 12
michael@0 13 namespace base {
michael@0 14
michael@0 15 // This class is a simple wrapper for string16 which also contains a null
michael@0 16 // state. This should be used only where the difference between null and
michael@0 17 // empty is meaningful.
michael@0 18 class NullableString16 {
michael@0 19 public:
michael@0 20 NullableString16() : is_null_(true) { }
michael@0 21 NullableString16(const string16& string, bool is_null)
michael@0 22 : string_(string), is_null_(is_null) {
michael@0 23 }
michael@0 24
michael@0 25 const string16& string() const { return string_; }
michael@0 26 bool is_null() const { return is_null_; }
michael@0 27
michael@0 28 private:
michael@0 29 string16 string_;
michael@0 30 bool is_null_;
michael@0 31 };
michael@0 32
michael@0 33 inline bool operator==(const NullableString16& a, const NullableString16& b) {
michael@0 34 return a.is_null() == b.is_null() && a.string() == b.string();
michael@0 35 }
michael@0 36
michael@0 37 inline bool operator!=(const NullableString16& a, const NullableString16& b) {
michael@0 38 return !(a == b);
michael@0 39 }
michael@0 40
michael@0 41 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
michael@0 42 const NullableString16& value);
michael@0 43
michael@0 44 } // namespace
michael@0 45
michael@0 46 #endif // BASE_STRINGS_NULLABLE_STRING16_H_

mercurial