Loading...
Searching...
No Matches
view_or_value.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <string>
#include <bsoncxx/string/view_or_value-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/view_or_value.hpp> // IWYU pragma: export
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace string {
class view_or_value : public v_noabi::view_or_value<stdx::string_view, std::string> {
public:
using v_noabi::view_or_value<stdx::string_view, std::string>::view_or_value;
view_or_value() = default;
view_or_value(char const* str) : v_noabi::view_or_value<stdx::string_view, std::string>(stdx::string_view(str)) {}
view_or_value(std::string const& str)
: v_noabi::view_or_value<stdx::string_view, std::string>(stdx::string_view(str)) {}
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(view_or_value) terminated() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(char const*) data() const;
};
inline bool operator==(view_or_value const& lhs, char const* rhs) {
return lhs.view() == stdx::string_view(rhs);
}
inline bool operator!=(view_or_value const& lhs, char const* rhs) {
return !(lhs == rhs);
}
inline bool operator==(char const* lhs, view_or_value const& rhs) {
return rhs == lhs;
}
inline bool operator!=(char const* lhs, view_or_value const& rhs) {
return !(rhs == lhs);
}
} // namespace string
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
namespace string {
using v_noabi::string::operator==;
using v_noabi::string::operator!=;
} // namespace string
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
#define BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to BSONCXX_ABI_EXPORT_UNSTABLE with BSONCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::string::view_or_value::view_or_value
view_or_value()=default
Default constructor, equivalent to using an empty string.
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
bsoncxx::v_noabi::string::view_or_value::view_or_value
view_or_value(std::string const &str)
Allow construction with an l-value reference to a std::string. The resulting view_or_value will keep ...
Definition view_or_value.hpp:72
bsoncxx::v_noabi::string::view_or_value::view_or_value
view_or_value()=default
Default constructor, equivalent to using an empty string.
bsoncxx::v_noabi::string::view_or_value::operator!=
bool operator!=(char const *lhs, view_or_value const &rhs)
Comparison operators for comparing string::view_or_value directly with char const*.
Definition view_or_value.hpp:118
bsoncxx::v_noabi::string::view_or_value::operator!=
bool operator!=(view_or_value const &lhs, char const *rhs)
Comparison operators for comparing string::view_or_value directly with char const*.
Definition view_or_value.hpp:108
bsoncxx::v_noabi::string::view_or_value::view_or_value
view_or_value(char const *str)
Construct a string::view_or_value using a null-terminated const char *. The resulting view_or_value w...
Definition view_or_value.hpp:60
bsoncxx::v_noabi::string::view_or_value::data
char const * data() const
Call data() on this view_or_value's string_view. This method is not guaranteed to return a null-termi...
bsoncxx::v_noabi::string::view_or_value::operator==
bool operator==(char const *lhs, view_or_value const &rhs)
Comparison operators for comparing string::view_or_value directly with char const*.
Definition view_or_value.hpp:113
bsoncxx::v_noabi::string::view_or_value::terminated
view_or_value terminated() const
Return a string_view_or_value that is guaranteed to hold a null-terminated string....
bsoncxx::v_noabi::string::view_or_value::operator==
bool operator==(view_or_value const &lhs, char const *rhs)
Comparison operators for comparing string::view_or_value directly with char const*.
Definition view_or_value.hpp:103
bsoncxx::v_noabi::view_or_value
A view-or-value variant type.
Definition view_or_value.hpp:32
bsoncxx::v_noabi::view_or_value< stdx::string_view, std::string >::string_view
operator stdx::string_view() const
Definition view_or_value.hpp:126
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx::v_noabi::string
Declares entities related to handling string types.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
view_or_value-fwd.hpp
Declares bsoncxx::v_noabi::string::view_or_value.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
view_or_value.hpp
Provides bsoncxx::v_noabi::view_or_value.