3 | | ////////////////////////////////////////////////////////////////////////////////////////////// |
4 | | ////////////////////////////////////////// BASIC VALUED USER INFOS /////////////////////////// |
5 | | ////////////////////////////////////////////////////////////////////////////////////////////// |
6 | | |
7 | | class BoolUI: public ValuedUserInfo<bool> |
8 | | { |
9 | | private: |
10 | | |
11 | | bool* AssemblyInstance() |
12 | | { |
13 | | if( value == "true" ) |
14 | | return new bool( true ); |
15 | | else |
16 | | return new bool( false ); |
17 | | } |
18 | | |
19 | | bool DisassemblyInstance(bool &instance) |
20 | | { |
21 | | if( instance ) |
22 | | value = "true"; |
23 | | else |
24 | | value = "false"; |
25 | | return true; |
26 | | } |
27 | | |
28 | | public: |
29 | | |
30 | | BoolUI() |
31 | | : ValuedUserInfo<bool>("bool") |
32 | | { |
33 | | } |
34 | | }; |
35 | | |
36 | | template<> const TypedUserInfo<bool>& TypedUserInfo<bool>::instance = BoolUI(); |
37 | | |
38 | | |
39 | | class IntUI: public ValuedUserInfo<int> |
40 | | { |
41 | | private: |
42 | | |
43 | | int* AssemblyInstance() |
44 | | { |
45 | | return new int( atoi( value.c_str()) ); |
46 | | } |
47 | | |
48 | | bool DisassemblyInstance(int &instance) |
49 | | { |
50 | | char buff[30]; |
51 | | sprintf(buff, "%d", instance ); |
52 | | value = buff; |
53 | | return true; |
54 | | } |
55 | | |
56 | | public: |
57 | | IntUI():ValuedUserInfo<int>("int") |
58 | | { |
59 | | } |
60 | | }; |
61 | | |
62 | | template<> const TypedUserInfo<int>& TypedUserInfo<int>::instance = IntUI(); |
63 | | |
64 | | |
65 | | class DoubleUI: public ValuedUserInfo<double> |
66 | | { |
67 | | private: |
68 | | |
69 | | double* AssemblyInstance() |
70 | | { |
71 | | return new double( atof( value.c_str()) ); |
72 | | } |
73 | | |
74 | | bool DisassemblyInstance(double &instance) |
75 | | { |
76 | | char buff[30]; |
77 | | sprintf(buff, "%f", instance ); |
78 | | value = buff; |
79 | | return true; |
80 | | } |
81 | | |
82 | | public: |
83 | | DoubleUI():ValuedUserInfo<double>("double") |
84 | | { |
85 | | } |
86 | | }; |
87 | | |
88 | | template<> const TypedUserInfo<double>& TypedUserInfo<double>::instance = DoubleUI(); |
89 | | |
90 | | class StringUI: public ValuedUserInfo<string> |
91 | | { |
92 | | private: |
93 | | string* AssemblyInstance() |
94 | | { |
95 | | return new string( value ); |
96 | | } |
97 | | |
98 | | bool DisassemblyInstance(string &instance) |
99 | | { |
100 | | value = instance; |
101 | | return true; |
102 | | } |
103 | | |
104 | | public: |
105 | | StringUI():ValuedUserInfo<string>("string") |
106 | | { |
107 | | } |
108 | | }; |
109 | | |
110 | | template<> const TypedUserInfo<string>& TypedUserInfo<string>::instance = StringUI(); |