| // Copyright 2014 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| Any::Any(const Any& rhs) : data_buffer_(rhs.data_buffer_) { |
| Any& Any::operator=(const Any& rhs) { |
| data_buffer_ = rhs.data_buffer_; |
| const std::type_info& Any::GetType() const { |
| return data_buffer_.GetDataPtr()->GetType(); |
| struct NullType {}; // Special helper type representing an empty variant. |
| void Any::Swap(Any& other) { |
| std::swap(data_buffer_, other.data_buffer_); |
| bool Any::IsEmpty() const { |
| return data_buffer_.IsEmpty(); |
| bool Any::IsConvertibleToInteger() const { |
| return !IsEmpty() && data_buffer_.GetDataPtr()->IsConvertibleToInteger(); |
| intmax_t Any::GetAsInteger() const { |
| CHECK(!IsEmpty()) << "Must not be called on an empty Any"; |
| return data_buffer_.GetDataPtr()->GetAsInteger(); |