Scope
ScopeValue.cpp
1 #include "StdAfx.h"
2 #include "ScopeValue.h"
3 
4 namespace scope {
5 
9 template<>
10 void ScopeValue<bool>::SetFromString(const std::wstring& str) {
11  Set( (str == L"true") );
12 }
13 
15 template<>
16 void ScopeValue<Uint16Range>::SetFromString(const std::wstring& str) {
17  Set(Uint16Range(str));
18 }
19 
21 template<>
22 void ScopeValue<ScannerType>::SetFromString(const std::wstring& str) {
23  Set(ScannerType(str));
24 }
25 
27 template<>
28 void ScopeValue<ScannerVectorType>::SetFromString(const std::wstring& str) {
29  Set(ScannerVectorType(str));
30 }
31 
33 template<>
34 void ScopeValue<RunState>::SetFromString(const std::wstring& str) {
35  Set(RunState(str));
36 }
37 
39 template<>
40 void ScopeValue<ZDevice>::SetFromString(const std::wstring& str) {
41  Set(ZDevice(str));
42 }
43 
45 template<>
46 void ScopeValue<BehaviorMode>::SetFromString(const std::wstring& str) {
47  Set(BehaviorMode(str));
48 }
49 
51 template<>
52 void ScopeValue<DaqMode>::SetFromString(const std::wstring& str) {
53  Set(DaqMode(str));
54 }
55 
57 template<>
58 void ScopeValue<DaqTiming>::SetFromString(const std::wstring& str) {
59  Set(DaqTiming(str));
60 }
61 
63 template<>
64 void ScopeValue<DaqSampling>::SetFromString(const std::wstring& str) {
65  Set(DaqSampling(str));
66 }
67 
69 template<>
70 void ScopeValue<double>::SetFromString(const std::wstring& str) {
71  double tmp = 0.0;
72  Set( !(std::wstringstream(str) >> tmp) ? 0.0 : tmp ); // operator! returns failbit, if failbit==false return tmp
73 }
74 
76 template<>
77 void ScopeValue<uint8_t>::SetFromString(const std::wstring& str) {
78  uint16_t tmp = 0; // Workaround, using uint8_t (which is unsigned char!) gives problems
79  Set( !(std::wstringstream(str) >> tmp) ? 0 : tmp ); // operator! returns failbit, if failbit==false return tmp
80 }
81 
83 template<>
84 void ScopeValue<uint16_t>::SetFromString(const std::wstring& str) {
85  uint16_t tmp = 0;
86  Set( !(std::wstringstream(str) >> tmp) ? 0 : tmp ); // operator! returns failbit, if failbit==false return tmp
87 }
88 
90 template<>
91 void ScopeValue<int32_t>::SetFromString(const std::wstring& str) {
92  int32_t tmp = 0;
93  Set( !(std::wstringstream(str) >> tmp) ? 0 : tmp ); // operator! returns failbit, if failbit==false return tmp
94 }
95 
97 template<>
98 void ScopeValue<uint32_t>::SetFromString(const std::wstring& str) {
99  uint32_t tmp = 0;
100  Set( !(std::wstringstream(str) >> tmp) ? 0 : tmp ); // operator! returns failbit, if failbit==false return tmp
101 }
102 
104 template<>
105 void ScopeValue<uint64_t>::SetFromString(const std::wstring& str) {
106  uint64_t tmp = 0;
107  Set( !(std::wstringstream(str) >> tmp) ? 0 : tmp ); // operator! returns failbit, if failbit==false return tmp
108 }
109 
111 template<>
112 void ScopeValue<std::wstring>::SetFromString(const std::wstring& str) {
113  Set(str);
114 }
115 
116 
117 
119 template<>
120 std::wstring ScopeValue<bool>::ToChar() const {
121  return (Value())?L"true":L"false";
122 }
123 
125 template<>
126 std::wstring ScopeValue<Uint16Range>::ToChar() const {
127  return Value().operator std::wstring();
128 }
129 
131 template<>
132 std::wstring ScopeValue<ScannerType>::ToChar() const {
133  return Value().operator std::wstring();
134 }
135 
137 template<>
138 std::wstring ScopeValue<ScannerVectorType>::ToChar() const {
139  return Value().operator std::wstring();
140 }
141 
143 template<>
144 std::wstring ScopeValue<RunState>::ToChar() const {
145  return Value().operator std::wstring();
146 }
147 
149 template<>
150 std::wstring ScopeValue<ZDevice>::ToChar() const {
151  return Value().operator std::wstring();
152 }
153 
155 template<>
156 std::wstring ScopeValue<BehaviorMode>::ToChar() const {
157  return Value().operator std::wstring();
158 }
159 
161 template<>
162 std::wstring ScopeValue<DaqMode>::ToChar() const {
163  return Value().operator std::wstring();
164 }
165 
167 template<>
168 std::wstring ScopeValue<DaqSampling>::ToChar() const {
169  return Value().operator std::wstring();
170 }
171 
173 template<>
174 std::wstring ScopeValue<DaqTiming>::ToChar() const {
175  return Value().operator std::wstring();
176 }
177 
179 template<>
180 std::wstring ScopeValue<double>::ToChar() const {
181  std::wstringstream stream;
182  stream << Value();
183  return stream.str();
184 }
185 
187 template<>
188 std::wstring ScopeValue<uint8_t>::ToChar() const {
189  std::wstringstream stream;
190  stream << Value();
191  return stream.str();
192 }
193 
195 template<>
196 std::wstring ScopeValue<uint16_t>::ToChar() const {
197  std::wstringstream stream;
198  stream << Value();
199  return stream.str();
200 }
201 
203 template<>
204 std::wstring ScopeValue<int32_t>::ToChar() const {
205  std::wstringstream stream;
206  stream << Value();
207  return stream.str();
208 }
209 
211 template<>
212 std::wstring ScopeValue<uint32_t>::ToChar() const {
213  std::wstringstream stream;
214  stream << Value();
215  return stream.str();
216 }
217 
219 template<>
220 std::wstring ScopeValue<uint64_t>::ToChar() const {
221  std::wstringstream stream;
222  stream << Value();
223  return stream.str();
224 }
225 
227 template<>
228 std::wstring ScopeValue<std::wstring>::ToChar() const {
229  return Value();
230 }
231 
235 }
236 
This is the include file for standard system include files, or project specific include files that ar...
std::wstring ToChar() const
Converts value into a wstring.
void SetFromString(const std::wstring &str)
Parses a wstring and sets the value accordingly.