darin@chromium.org | e5e4dde6 | 2013-06-17 21:36:41 | [diff] [blame] | 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 | |
avi@chromium.org | c3d4a0d | 2013-06-20 19:40:12 | [diff] [blame] | 5 | #include "base/strings/nullable_string16.h" |
darin@chromium.org | e5e4dde6 | 2013-06-17 21:36:41 | [diff] [blame] | 6 | |
| 7 | #include <ostream> |
Sam McNally | 86419ce0 | 2017-05-22 23:29:46 | [diff] [blame] | 8 | #include <utility> |
darin@chromium.org | e5e4dde6 | 2013-06-17 21:36:41 | [diff] [blame] | 9 | |
| 10 | namespace base { |
Sam McNally | 86419ce0 | 2017-05-22 23:29:46 | [diff] [blame] | 11 | NullableString16::NullableString16() = default; |
| 12 | NullableString16::NullableString16(const NullableString16& other) = default; |
| 13 | NullableString16::NullableString16(NullableString16&& other) = default; |
| 14 | |
| 15 | NullableString16::NullableString16(const string16& string, bool is_null) { |
| 16 | if (!is_null) |
| 17 | string_.emplace(string); |
| 18 | } |
| 19 | |
| 20 | NullableString16::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; |
darin@chromium.org | e5e4dde6 | 2013-06-17 21:36:41 | [diff] [blame] | 28 | |
| 29 | std::ostream& operator<<(std::ostream& out, const NullableString16& value) { |
Sam McNally | 86419ce0 | 2017-05-22 23:29:46 | [diff] [blame] | 30 | return value.is_null() ? out << "(null)" : out << value.string(); |
darin@chromium.org | e5e4dde6 | 2013-06-17 21:36:41 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | } // namespace base |