1#ifndef FTXUI_UTIL_REF_HPP
2#define FTXUI_UTIL_REF_HPP
16 const T&
operator*()
const {
return address_ ? *address_ : owned_; }
17 const T&
operator()()
const {
return address_ ? *address_ : owned_; }
18 const T*
operator->()
const {
return address_ ? address_ : &owned_; }
22 const T* address_ =
nullptr;
30 Ref(
const T& t) : owned_(t) {}
31 Ref(T&& t) : owned_(std::forward<T>(t)) {}
32 Ref(T* t) : address_(t) {}
33 T&
operator*() {
return address_ ? *address_ : owned_; }
34 T&
operator()() {
return address_ ? *address_ : owned_; }
35 T*
operator->() {
return address_ ? address_ : &owned_; }
39 T* address_ =
nullptr;
47 StringRef(std::string ref) : owned_(std::move(ref)) {}
50 std::string&
operator*() {
return address_ ? *address_ : owned_; }
51 std::string*
operator->() {
return address_ ? address_ : &owned_; }
55 std::string* address_ =
nullptr;
69 const std::string&
operator*()
const {
return address_ ? *address_ : owned_; }
71 return address_ ? address_ : &owned_;
75 const std::string owned_;
76 const std::string* address_ =
nullptr;
85 size_t size()
const {
return ref_ ? ref_->size() : ref_wide_->size(); }
87 return ref_ ? (*ref_)[i] :
to_string((*ref_wide_)[i]);
91 const std::vector<std::string>* ref_ =
nullptr;
92 const std::vector<std::wstring>* ref_wide_ =
nullptr;
An adapter. Own or reference an immutable object.
const T & operator*() const
const T * operator->() const
const T & operator()() const
An adapter. Reference a list of strings.
ConstStringListRef(const std::vector< std::wstring > *ref)
ConstStringListRef(const std::vector< std::string > *ref)
std::string operator[](size_t i) const
An adapter. Own or reference a constant string. For convenience, this class convert multiple immutabl...
ConstStringRef(const char *ref)
ConstStringRef(const std::string *ref)
const std::string & operator*() const
const std::string * operator->() const
ConstStringRef(std::wstring ref)
ConstStringRef(const std::wstring *ref)
ConstStringRef(std::string ref)
ConstStringRef(const wchar_t *ref)
An adapter. Own or reference an mutable object.
An adapter. Own or reference a constant string. For convenience, this class convert multiple mutable ...
std::string * operator->()
StringRef(const char *ref)
StringRef(const wchar_t *ref)
StringRef(std::string ref)
std::string & operator*()
StringRef(std::string *ref)
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.