1 // Copyright (c) 2013 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. 4 5 #include "base/strings/nullable_string16.h" 6 7 #include <ostream> 8 #include <utility> 9 10 namespace base { 11 NullableString16::NullableString16() = default; 12 NullableString16::NullableString16(const NullableString16& other) = default; 13 NullableString16::NullableString16(NullableString16&& other) = default; 14 NullableString16(const string16 & string,bool is_null)15NullableString16::NullableString16(const string16& string, bool is_null) { 16 if (!is_null) 17 string_.emplace(string); 18 } 19 NullableString16(Optional<string16> optional_string16)20NullableString16::NullableString16(Optional<string16> optional_string16) 21 : string_(std::move(optional_string16)) {} 22 23 NullableString16::~NullableString16() = default; 24 NullableString16& NullableString16::operator=(const NullableString16& other) = 25 default; 26 NullableString16& NullableString16::operator=(NullableString16&& other) = 27 default; 28 operator <<(std::ostream & out,const NullableString16 & value)29std::ostream& operator<<(std::ostream& out, const NullableString16& value) { 30 return value.is_null() ? out << "(null)" : out << value.string(); 31 } 32 33 } // namespace base 34