11#include "webcface/common/webcface-config.h"
33 friend struct InputRefState;
48 template <
typename F,
typename std::enable_if_t<std::is_invocable_v<F>,
49 std::
nullptr_t> =
nullptr>
52 [callback = std::move(callback)](
const auto &) { callback(); });
63 onChange(std::forward<T>(callback));
83 std::optional<ValAdaptor> tryGet()
const;
93 typename std::enable_if_t<std::is_convertible_v<ValAdaptor, T>,
94 std::nullptr_t> =
nullptr>
96 return static_cast<T
>(get());
102 bool empty()
const {
return get().empty(); }
110 const std::string &
asStringRef()
const {
return get().asStringRef(); }
115 const std::wstring &
asWStringRef()
const {
return get().asWStringRef(); }
120 std::string
asString()
const {
return get().asString(); }
125 std::wstring
asWString()
const {
return get().asWString(); }
130 double asDouble()
const {
return get().asDouble(); }
135 int asInt()
const {
return get().asInt(); }
140 long long asLLong()
const {
return get().asLLong(); }
145 bool asBool()
const {
return get().asBool(); }
147 template <
typename T,
148 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
149 std::nullptr_t> =
nullptr>
151 return get() == other;
153 template <
typename T,
154 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
155 std::nullptr_t> =
nullptr>
157 return get() != other;
160 template <
typename T,
typename std::enable_if_t<std::is_same_v<T, Variant>,
161 std::
nullptr_t> =
nullptr>
163 return static_cast<Field>(*this) ==
static_cast<Field>(other);
165 template <
typename T,
typename std::enable_if_t<std::is_same_v<T, Variant>,
166 std::
nullptr_t> =
nullptr>
168 return static_cast<Field>(*this) !=
static_cast<Field>(other);
190 using Field::lastName;
248 template <
typename F,
249 typename std::enable_if_t<std::is_invocable_v<F, Text>,
250 std::nullptr_t> =
nullptr>
253 [callback = std::move(callback)](
const Variant &base) {
254 callback(
Text(base));
264 template <
typename F,
typename std::enable_if_t<std::is_invocable_v<F>,
265 std::
nullptr_t> =
nullptr>
268 [callback = std::move(callback)](
const auto &) { callback(); });
278 template <
typename T>
280 onChange(std::forward<T>(callback));
335 std::optional<std::string> tryGet()
const;
340 std::optional<std::wstring> tryGetW()
const;
350 const std::string &get()
const;
358 const std::wstring &getW()
const;
360 operator const std::string &()
const {
return get(); }
361 operator const std::wstring &()
const {
return getW(); }
377 [[deprecated]] std::chrono::system_clock::time_point time()
const;
383 const Text &free()
const;
385 bool operator==(std::string_view rhs)
const {
return this->get() == rhs; }
386 bool operator!=(std::string_view rhs)
const {
return this->get() != rhs; }
387 bool operator==(std::wstring_view rhs)
const {
return this->getW() == rhs; }
388 bool operator!=(std::wstring_view rhs)
const {
return this->getW() != rhs; }
398 template <
typename T,
typename std::enable_if_t<std::is_same_v<T, Text>,
399 std::
nullptr_t> =
nullptr>
401 return static_cast<Field>(*this) ==
static_cast<Field>(other);
403 template <
typename T,
typename std::enable_if_t<std::is_same_v<T, Text>,
404 std::
nullptr_t> =
nullptr>
406 return static_cast<Field>(*this) !=
static_cast<Field>(other);
440 std::shared_ptr<internal::InputRefState> state;
442 void lockTo(
const Variant &target);
473 template <
typename T,
474 typename std::enable_if_t<std::is_convertible_v<ValAdaptor, T>,
475 std::nullptr_t> =
nullptr>
477 return static_cast<T
>(get());
484 bool empty()
const {
return get().empty(); }
495 const std::string &
asStringRef()
const {
return get().asStringRef(); }
501 const std::wstring &
asWStringRef()
const {
return get().asWStringRef(); }
506 std::string
asString()
const {
return get().asString(); }
511 std::wstring
asWString()
const {
return get().asWString(); }
516 double asDouble()
const {
return get().asDouble(); }
521 int asInt()
const {
return get().asInt(); }
526 long long asLLong()
const {
return get().asLLong(); }
537 template <
typename T>
538 [[deprecated(
"use asDouble(), asInt() or asLLong() instead")]]
540 return get().as<T>();
547 bool asBool()
const {
return get().asBool(); }
549 template <
typename T,
550 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
551 std::nullptr_t> =
nullptr>
553 return get() == other;
555 template <
typename T,
556 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
557 std::nullptr_t> =
nullptr>
559 return get() != other;
564 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
565 std::nullptr_t> =
nullptr>
567 return ref.
get() == other;
570 typename std::enable_if_t<std::is_constructible_v<ValAdaptor, T>,
571 std::nullptr_t> =
nullptr>
573 return ref.
get() != other;
576 return os << ref.
get();
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
Viewを構築するときに使う一時的なViewComponent.
Definition component_view.h:267
文字列の送受信データを表すクラス
Definition text.h:183
const Text & operator=(std::wstring_view v) const
文字列をセットする (wstring)
Definition text.h:314
bool operator==(const T &other) const
Textの参照先を比較
Definition text.h:400
Text operator[](const char *field) const
Definition text.h:226
bool operator!=(std::string_view rhs) const
Definition text.h:386
const Text & set(std::wstring_view v) const
文字列をセットする (wstring)
Definition text.h:297
bool operator>(const Text &) const =delete
const Text & request() const
文字列をリクエストする
Definition text.h:324
Text child(std::string_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition text.h:198
Text operator[](std::wstring_view field) const
Definition text.h:221
bool operator>=(const Text &) const =delete
const Text & operator=(std::string_view v) const
文字列をセットする
Definition text.h:306
Text child(std::wstring_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField (wstring)
Definition text.h:205
Text child(int index) const
Definition text.h:211
Text parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition text.h:240
bool operator==(std::wstring_view rhs) const
Definition text.h:387
const Text & set(std::string_view v) const
文字列をセットする
Definition text.h:289
bool operator!=(const T &other) const
Definition text.h:405
bool operator==(std::string_view rhs) const
Definition text.h:385
Text(const Field &base, const SharedString &field)
Definition text.h:187
Text operator[](int index) const
Definition text.h:235
void appendListener(T &&callback) const
Definition text.h:279
bool operator<=(const Text &) const =delete
const Text & onChange(F callback) const
値が変化したときに呼び出されるコールバックを設定
Definition text.h:251
Text(const Field &base)
Definition text.h:186
bool operator<(const Text &) const =delete
Text operator[](const wchar_t *field) const
Definition text.h:230
Text operator[](std::string_view field) const
Definition text.h:216
bool operator!=(std::wstring_view rhs) const
Definition text.h:388
数値、文字列などの値を相互変換するクラス
Definition val_adaptor.h:87
文字列、数値などの型を送受信するクラス
Definition text.h:25
bool operator<=(const Variant &) const =delete
bool operator==(const T &other) const
Definition text.h:150
std::string asString() const
文字列として返す(コピー)
Definition text.h:120
const Variant & request() const
値をリクエストする
Definition text.cc:40
const std::wstring & asWStringRef() const
文字列として返す (wstring)
Definition text.h:115
bool empty() const
値が空かどうか調べる
Definition text.h:102
const std::string & asStringRef() const
文字列として返す
Definition text.h:110
long long asLLong() const
long long型の整数として返す
Definition text.h:140
const Variant & onChange(std::function< void(Variant)> callback) const
値が変化したときに呼び出されるコールバックを設定
Definition text.cc:63
bool operator!=(const T &other) const
Definition text.h:156
void appendListener(T &&callback) const
Definition text.h:62
bool asBool() const
bool値を返す
Definition text.h:145
int asInt() const
int型の整数として返す
Definition text.h:135
const Variant & onChange(F callback) const
値が変化したときに呼び出されるコールバックを設定
Definition text.h:50
const Variant & set(const ValAdaptor &v) const
値をセットする
Definition text.cc:50
double asDouble() const
実数として返す
Definition text.h:130
bool operator>(const Variant &) const =delete
Variant(const Field &base, const SharedString &field)
Definition text.h:29
bool operator>=(const Variant &) const =delete
std::wstring asWString() const
文字列として返す(コピー) (wstring)
Definition text.h:125
bool operator<(const Variant &) const =delete
std::ostream & operator<<(std::ostream &os, const Arg &arg)
Definition func_info.cc:96
bool operator==(const T &other, const InputRef &ref)
Definition text.h:566
bool operator!=(const T &other, const InputRef &ref)
Definition text.h:572
ClientDataの参照とメンバ名とデータ名を持つクラス
Definition field.h:70
Field parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition field.cc:33
Field child(const SharedString &field) const
Definition field.cc:42
#define WEBCFACE_DLL
Definition webcface-config.h:60
#define WEBCFACE_CALL
Definition webcface-config.h:97
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103
#define WEBCFACE_CALL_FP
Definition webcface-config.h:98