WebCFace 2.9.0
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
arg.h
Go to the documentation of this file.
1#pragma once
2#include <vector>
3#include <optional>
5
6#ifdef min
7// clang-format off
8#pragma message("warning: Disabling macro definition of 'min' and 'max', since they conflicts in webcface/arg.h.")
9// clang-format on
10#undef min
11#undef max
12#endif
13
15
16namespace message {
17struct Arg;
18}
19namespace internal {
20struct FuncInfo;
21}
22
31 std::shared_ptr<message::Arg> msg_data;
32
37 ValType type_ = ValType::none_;
38
43 std::shared_ptr<message::Arg> initMsg();
44
45 public:
46 friend struct internal::FuncInfo;
51 void mergeConfig(const Arg &other);
56 explicit Arg(ValType type = ValType::none_);
61 explicit Arg(const std::shared_ptr<message::Arg> &msg_data);
62
67 explicit Arg(const SharedString &name);
73 Arg(StringInitializer name) : Arg(static_cast<SharedString &>(name)) {}
74
81 StringView name() const;
89 WStringView nameW() const;
94 ValType type() const;
99 Arg &type(ValType type);
104 std::optional<ValAdaptor> init() const;
109 template <typename T>
110 Arg &init(const T &init) {
111 return this->init(ValAdaptor(init));
112 }
116 template <std::size_t N>
117 Arg &init(const char (&init)[N]) {
118 return this->init(ValAdaptor(init));
119 }
123 template <std::size_t N>
124 Arg &init(const wchar_t (&init)[N]) {
125 return this->init(ValAdaptor(init));
126 }
127 Arg &init(const ValAdaptor &init);
132 std::optional<double> min() const;
141 Arg &min(double min);
146 std::optional<double> max() const;
155 Arg &max(double max);
160 std::vector<ValAdaptor> option() const;
161 Arg &option(std::vector<ValAdaptor> option);
168 template <typename T>
169 Arg &option(std::initializer_list<T> option) {
170 std::vector<ValAdaptor> option_v;
171 for (const auto &v : option) {
172 option_v.emplace_back(ValAdaptor(v));
173 }
174 return this->option(std::move(option_v));
175 }
176};
177WEBCFACE_DLL std::ostream &WEBCFACE_CALL operator<<(std::ostream &os,
178 const Arg &arg);
引数の情報を表す。
Definition arg.h:30
Arg(StringInitializer name)
引数名を設定する。
Definition arg.h:73
Arg & init(const wchar_t(&init)[N])
Definition arg.h:124
Arg & init(const char(&init)[N])
Definition arg.h:117
Arg & option(std::initializer_list< T > option)
引数の選択肢を設定する。
Definition arg.h:169
Arg & init(const T &init)
デフォルト値を設定する。
Definition arg.h:110
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:159
SharedString のpublicなコンストラクタインタフェース (入力専用)
Definition encoding.h:215
webcfaceで管理されている文字列を参照するstring_view
Definition encoding.h:60
数値、文字列などの値を相互変換するクラス
Definition val_adaptor.h:87
ValType
引数や戻り値の型を表すenum
Definition val_adaptor.h:21
関数1つの情報を表す。関数の実体も持つ
Definition func_internal.h:142
client(member)->server->client func登録
Definition func.h:91
#define WEBCFACE_DLL
Definition webcface-config.h:69
#define WEBCFACE_CALL
Definition webcface-config.h:106
#define WEBCFACE_NS_END
Definition webcface-config.h:118
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:117