18 #ifndef FOEDUS_EXTERNALIZE_TINYXML_WRAPPER_HPP_
19 #define FOEDUS_EXTERNALIZE_TINYXML_WRAPPER_HPP_
29 namespace externalize {
37 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, T* out);
40 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element,
bool *out) {
41 return element->QueryBoolText(out);
46 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, int64_t *out) {
47 return element->QueryLongLongText(out);
51 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, uint64_t *out) {
52 return element->QueryUnsignedLongLongText(out);
56 template <
typename T,
typename LARGEST_TYPE,
typename LARGEST_GETTER>
59 LARGEST_GETTER largest_getter;
60 tinyxml2::XMLError ret = largest_getter(element, &tmp);
61 if (ret != tinyxml2::XML_SUCCESS) {
64 *out =
static_cast<T
>(tmp);
65 if (static_cast<LARGEST_TYPE>(*out) != tmp) {
66 return tinyxml2::XML_CAN_NOT_CONVERT_TEXT;
68 return tinyxml2::XML_SUCCESS;
73 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, int32_t *out) {
74 return get_smaller_int<int32_t, int64_t, TinyxmlGetter<int64_t> >(element, out);
78 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, uint32_t *out) {
79 return get_smaller_int<uint32_t, uint64_t, TinyxmlGetter<uint64_t> >(element, out);
83 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, int16_t *out) {
84 return get_smaller_int<int16_t, int64_t, TinyxmlGetter<int64_t> >(element, out);
88 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, uint16_t *out) {
89 return get_smaller_int<uint16_t, uint64_t, TinyxmlGetter<uint64_t> >(element, out);
93 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, int8_t *out) {
94 return get_smaller_int<int8_t, int64_t, TinyxmlGetter<int64_t> >(element, out);
98 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, uint8_t *out) {
99 return get_smaller_int<uint8_t, uint64_t, TinyxmlGetter<uint64_t> >(element, out);
104 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element, std::string *out) {
105 const char* text = element->GetText();
111 return tinyxml2::XML_SUCCESS;
114 template <u
int MAXLEN,
typename CHAR>
117 const tinyxml2::XMLElement *element,
119 const char* text = element->GetText();
125 return tinyxml2::XML_SUCCESS;
129 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element,
double *out) {
130 return element->QueryDoubleText(out);
134 tinyxml2::XMLError
operator()(
const tinyxml2::XMLElement *element,
float *out) {
135 return element->QueryFloatText(out);
146 void operator()(tinyxml2::XMLElement *element,
const T &value) {
147 element->SetText(value);
151 void operator()(tinyxml2::XMLElement *element,
const std::string &value) {
152 element->SetText(value.c_str());
155 template <u
int MAXLEN,
typename CHAR>
158 element->SetText(value.
str().c_str());
165 #endif // FOEDUS_EXTERNALIZE_TINYXML_WRAPPER_HPP_
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, bool *out)
Functor to help use tinyxml2's Element SetText().
void operator()(tinyxml2::XMLElement *element, const assorted::FixedString< MAXLEN, CHAR > &value)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, int8_t *out)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, uint32_t *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, float *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, int16_t *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, uint64_t *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, double *out)
Functor to help use tinyxml2's Element QueryXxxText().
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, uint8_t *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, T *out)
void operator()(tinyxml2::XMLElement *element, const std::string &value)
std::basic_string< CHAR > str() const
Convert to a std::string object.
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, int32_t *out)
void operator()(tinyxml2::XMLElement *element, const T &value)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, std::string *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, assorted::FixedString< MAXLEN, CHAR > *out)
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, int64_t *out)
tinyxml2::XMLError get_smaller_int(const tinyxml2::XMLElement *element, T *out)
void clear() noexcept
Clear string.
An embedded string object of fixed max-length, which uses no external memory.
tinyxml2::XMLError operator()(const tinyxml2::XMLElement *element, uint16_t *out)