7 #ifndef ZEN_XML_CONVERT_STRUC_HEADER_018727409908342709743
8 #define ZEN_XML_CONVERT_STRUC_HEADER_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 std::for_each(value.begin(), value.end(),
125 [&](
const typename T::value_type & childVal)
127 XmlElement& newChild = output.addChild(
"Item");
131 bool readStruc(
const XmlElement& input, T& value)
const
136 auto iterPair = input.getChildren(
"Item");
137 for (
auto iter = iterPair.first; iter != iterPair.second; ++iter)
139 typename T::value_type childVal;
141 value.insert(value.end(), childVal);
152 struct ConvertElement<T, VALUE_TYPE_STL_PAIR>
154 void writeStruc(
const T& value, XmlElement& output)
const
156 XmlElement& child1 = output.addChild(
"one");
159 XmlElement& child2 = output.addChild(
"two");
162 bool readStruc(
const XmlElement& input, T& value)
const
165 const XmlElement* child1 = input.getChild(
"one");
169 const XmlElement* child2 = input.getChild(
"two");
180 struct ConvertElement<T, VALUE_TYPE_OTHER>
182 void writeStruc(
const T& value, XmlElement& output)
const
186 output.setValue(tmp);
188 bool readStruc(
const XmlElement& input, T& value)
const
191 input.getValue(rawStr);
197 template <
class T>
inline
200 ConvertElement<T, GetValueType<T>::value>().
writeStruc(value, output);
204 template <
class T>
inline
207 return ConvertElement<T, GetValueType<T>::value>().
readStruc(input, value);
211 #endif //ZEN_XML_CONVERT_STRUC_HEADER_018727409908342709743
bool readText(const std::string &input, T &value)
Convert text to user data - used by XML elements and attributes.
Definition: cvrt_text.h:216
An XML element.
Definition: dom.h:21
bool readStruc(const XmlElement &input, T &value)
Convert XML element to structured user data.
Definition: cvrt_struc.h:205
void writeStruc(const T &value, XmlElement &output)
Convert structured user data into an XML element.
Definition: cvrt_struc.h:198
void writeText(const T &value, std::string &output)
Convert user data into text - used by XML elements and attributes.
Definition: cvrt_text.h:209