WebCFace 2.5.2
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);
72 Arg(std::string_view name) : Arg(SharedString::encode(name)) {}
77 Arg(std::wstring_view name) : Arg(SharedString::encode(name)) {}
78
83 const std::string &name() const;
88 const std::wstring &nameW() const;
93 ValType type() const;
98 Arg &type(ValType type);
103 std::optional<ValAdaptor> init() const;
108 template <typename T>
109 Arg &init(const T &init) {
110 return this->init(ValAdaptor(init));
111 }
112 Arg &init(const ValAdaptor &init);
117 std::optional<double> min() const;
126 Arg &min(double min);
131 std::optional<double> max() const;
140 Arg &max(double max);
145 const std::vector<ValAdaptor> &option() const;
146 Arg &option(std::vector<ValAdaptor> option);
153 template <typename T>
154 Arg &option(std::initializer_list<T> option) {
155 std::vector<ValAdaptor> option_v;
156 for (const auto &v : option) {
157 option_v.emplace_back(ValAdaptor(v));
158 }
159 return this->option(std::move(option_v));
160 }
161};
162WEBCFACE_DLL std::ostream &WEBCFACE_CALL operator<<(std::ostream &os,
163 const Arg &arg);
引数の情報を表す。
Definition arg.h:30
Arg(std::string_view name)
引数名を設定する。
Definition arg.h:72
Arg(std::wstring_view name)
引数名を設定する。(wstring)
Definition arg.h:77
Arg & option(std::initializer_list< T > option)
引数の選択肢を設定する。
Definition arg.h:154
Arg & init(const T &init)
デフォルト値を設定する。
Definition arg.h:109
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
数値、文字列などの値を相互変換するクラス
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: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