7 #ifndef CVRT_STRUC_H_018727409908342709743
8 #define CVRT_STRUC_H_018727409908342709743
26 template <
class T>
bool readStruc(
const XmlElement& input, T& value);
32 template <
class T>
void writeStruc(
const T& value, XmlElement& output);
51 namespace impl_2384343
53 ZEN_INIT_DETECT_MEMBER_TYPE(value_type);
54 ZEN_INIT_DETECT_MEMBER_TYPE(iterator);
55 ZEN_INIT_DETECT_MEMBER_TYPE(const_iterator);
57 ZEN_INIT_DETECT_MEMBER(begin)
58 ZEN_INIT_DETECT_MEMBER(end)
59 ZEN_INIT_DETECT_MEMBER(insert)
63 struct IsStlContainer :
65 impl_2384343::HasMemberType_value_type <T>::value&&
66 impl_2384343::HasMemberType_iterator <T>::value&&
67 impl_2384343::HasMemberType_const_iterator<T>::value&&
68 impl_2384343::HasMember_begin <T>::value&&
69 impl_2384343::HasMember_end <T>::value&&
70 impl_2384343::HasMember_insert <T>::value> {};
73 namespace impl_2384343
75 ZEN_INIT_DETECT_MEMBER_TYPE(first_type);
76 ZEN_INIT_DETECT_MEMBER_TYPE(second_type);
78 ZEN_INIT_DETECT_MEMBER(first)
79 ZEN_INIT_DETECT_MEMBER(second)
85 impl_2384343::HasMemberType_first_type <T>::value&&
86 impl_2384343::HasMemberType_second_type<T>::value&&
87 impl_2384343::HasMember_first <T>::value&&
88 impl_2384343::HasMember_second <T>::value> {};
95 VALUE_TYPE_STL_CONTAINER,
101 struct GetValueType : StaticEnum<ValueType,
102 GetTextType<T>::value != TEXT_TYPE_OTHER ? VALUE_TYPE_OTHER :
103 IsStlContainer<T>::value ? VALUE_TYPE_STL_CONTAINER :
104 IsStlPair<T>::value ? VALUE_TYPE_STL_PAIR :
105 VALUE_TYPE_OTHER> {};
108 template <
class T, ValueType type>
109 struct ConvertElement;
120 struct ConvertElement<T, VALUE_TYPE_STL_CONTAINER>
122 void writeStruc(
const T& value, XmlElement& output)
const
124 for (
const typename T::value_type& childVal : value)
126 XmlElement& newChild = output.addChild(
"Item");
130 bool readStruc(
const XmlElement& input, T& value)
const
135 auto itPair = input.getChildren(
"Item");
136 for (
auto it = itPair.first; it != itPair.second; ++it)
138 typename T::value_type childVal;
140 value.insert(value.end(), childVal);
151 struct ConvertElement<T, VALUE_TYPE_STL_PAIR>
153 void writeStruc(
const T& value, XmlElement& output)
const
155 XmlElement& child1 = output.addChild(
"one");
158 XmlElement& child2 = output.addChild(
"two");
161 bool readStruc(
const XmlElement& input, T& value)
const
164 const XmlElement* child1 = input.getChild(
"one");
168 const XmlElement* child2 = input.getChild(
"two");
179 struct ConvertElement<T, VALUE_TYPE_OTHER>
181 void writeStruc(
const T& value, XmlElement& output)
const
185 output.setValue(tmp);
187 bool readStruc(
const XmlElement& input, T& value)
const
190 input.getValue(rawStr);
196 template <
class T>
inline
199 ConvertElement<T, GetValueType<T>::value>().
writeStruc(value, output);
203 template <
class T>
inline
206 return ConvertElement<T, GetValueType<T>::value>().
readStruc(input, value);
210 #endif //CVRT_STRUC_H_018727409908342709743
bool readText(const std::string &input, T &value)
Convert text to user data - used by XML elements and attributes.
Definition: cvrt_text.h:214
An XML element.
Definition: dom.h:20
The zen::Xml namespace.
Definition: bind.h:15
bool readStruc(const XmlElement &input, T &value)
Convert XML element to structured user data.
Definition: cvrt_struc.h:204
void writeStruc(const T &value, XmlElement &output)
Convert structured user data into an XML element.
Definition: cvrt_struc.h:197
void writeText(const T &value, std::string &output)
Convert user data into text - used by XML elements and attributes.
Definition: cvrt_text.h:207