1+ // =======================
2+ // AUTHOR : Peize Lin
3+ // DATE : 2021-12-13
4+ // =======================
5+
6+ #ifndef READ_TXT_INPUT_ITEM_H
7+ #define READ_TXT_INPUT_ITEM_H
8+
9+ #include " read_txt_input_value.h"
10+
11+ #include < vector>
12+ #include < map>
13+ #include < string>
14+ #include < functional>
15+
16+ #ifdef USE_CEREAL_SERIALIZATION
17+ #include < cereal/access.hpp>
18+ #endif
19+
20+ namespace Read_Txt_Input
21+ {
22+ class Input_Item
23+ {
24+ public:
25+ // call these functions
26+ Input_Item (const std::string &label_in) :label(label_in) {}
27+ template <typename T>
28+ void default_1 (const T &value);
29+ template <typename T_head, typename ... T_tail>
30+ void default_1 (const T_head &value_head, const T_tail... values_tail);
31+
32+ // set these variables and functions
33+ std::string annotation;
34+ std::function<void (Input_Item&)> check_transform
35+ = [](Input_Item&self){};
36+ std::function<void (Input_Item&, const std::map<std::string, Input_Item>&)> default_2
37+ = [](Input_Item&self, const std::map<std::string, Input_Item>&list){};
38+ std::function<void (const Input_Item&)> convert
39+ = [](const Input_Item&item){};
40+
41+ std::vector<Input_Value> values;
42+
43+ void check_values_size (const int lower_limit, const int upper_limit)
44+ { values_size_lower_limit=lower_limit; values_size_upper_limit=upper_limit; }
45+
46+ private:
47+ std::string label;
48+ std::vector<std::string> values_type;
49+
50+ int values_size_read = -1 ;
51+ int values_size_lower_limit = 0 ;
52+ int values_size_upper_limit = 0 ;
53+
54+ friend class Input_List ;
55+ friend class Input_Process ;
56+
57+ template <typename T>
58+ void set_value (const T &value);
59+
60+ #ifdef USE_CEREAL_SERIALIZATION
61+ public:
62+ Input_Item () = default;
63+ private:
64+ friend class cereal ::access;
65+ template <class Archive > void serialize ( Archive & ar );
66+ #endif
67+ };
68+ }
69+
70+ #include " read_txt_input_item-template.h"
71+
72+ #endif
0 commit comments