19 SerializableXmlReader00::SerializableXmlReader00(
20 CSerializableXmlFile* file) { m_file = file; }
22 SerializableXmlReader00::~SerializableXmlReader00() {}
25 SerializableXmlReader00::read_scalar_wrapped(
28 xmlNode* m = m_file->m_stack_stream.back();
32 if ((xml_buf = xmlNodeGetContent(m)) == NULL)
return false;
33 const char* buf = (
const char*) xml_buf;
42 if (strcmp(buf, STR_TRUE) == 0) *(
bool*) param =
true;
43 else if (strcmp(buf, STR_FALSE) == 0) *(
bool*) param =
false;
48 if (sscanf(buf,
"%c", (
char*) param) != 1)
52 if (sscanf(buf,
"%" SCNi8, (int8_t*) param) != 1)
56 if (sscanf(buf,
"%" SCNu8, (uint8_t*) param) != 1)
60 if (sscanf(buf,
"%" SCNi16, (int16_t*) param) != 1)
64 if (sscanf(buf,
"%" SCNu16, (uint16_t*) param) != 1)
68 if (sscanf(buf,
"%" SCNi32, (int32_t*) param) != 1)
72 if (sscanf(buf,
"%" SCNu32, (uint32_t*) param) != 1)
76 if (sscanf(buf,
"%" SCNi64, (int64_t*) param) != 1)
80 if (sscanf(buf,
"%" SCNu64, (uint64_t*) param) != 1)
94 if (sscanf(buf,
"(%lg,%lg)", &c_real, &c_imag) != 2)
96 #if defined(HAVE_CXX0X) || defined(HAVE_CXX11) || defined(_LIBCPP_VERSION)
106 SG_ERROR(
"read_scalar_wrapped(): Implementation error during"
107 " reading XmlFile!");
116 SerializableXmlReader00::read_cont_begin_wrapped(
119 xmlNode* m = m_file->m_stack_stream.back();
124 case CT_SCALAR:
break;
125 case CT_VECTOR:
case CT_SGVECTOR:
126 *len_read_y = xmlChildElementCount(m);
128 case CT_MATRIX:
case CT_SGMATRIX:
129 *len_read_x = xmlChildElementCount(m);
131 for (xmlNode* cur=m->children; cur != NULL; cur=cur->next) {
132 if (cur->type != XML_ELEMENT_NODE)
continue;
134 if (*len_read_y == 0)
135 *len_read_y = xmlChildElementCount(cur);
137 if (*len_read_y != (
index_t) xmlChildElementCount(cur))
149 SerializableXmlReader00::read_cont_end_wrapped(
152 if (len_read_y > 0) m_file->pop_node();
156 if (len_read_y*len_read_x>0)
164 SerializableXmlReader00::read_string_begin_wrapped(
167 xmlNode* m = m_file->m_stack_stream.back();
169 *length = xmlChildElementCount(m);
175 SerializableXmlReader00::read_string_end_wrapped(
178 if (length > 0) m_file->pop_node();
184 SerializableXmlReader00::read_stringentry_begin_wrapped(
188 if (!m_file->join_node(BAD_CAST STR_STRING))
return false;
192 if (!m_file->next_node(BAD_CAST STR_STRING))
return false;
198 SerializableXmlReader00::read_stringentry_end_wrapped(
205 SerializableXmlReader00::read_sparse_begin_wrapped(
212 SerializableXmlReader00::read_sparse_end_wrapped(
215 if (length > 0) m_file->pop_node();
221 SerializableXmlReader00::read_sparseentry_begin_wrapped(
229 if (!m_file->join_node(BAD_CAST STR_SPARSE))
return false;
231 if (!m_file->next_node(BAD_CAST STR_SPARSE))
return false;
234 if ((buf = xmlGetProp(m_file->m_stack_stream.back(), BAD_CAST
235 STR_PROP_FEATINDEX)) == NULL)
return false;
236 if (sscanf((
const char*) buf,
"%" PRIi32, feat_index) != 1)
238 xmlFree(buf);
if (!result)
return false;
244 SerializableXmlReader00::read_sparseentry_end_wrapped(
252 SerializableXmlReader00::read_item_begin_wrapped(
258 case CT_SCALAR:
break;
259 case CT_VECTOR:
case CT_SGVECTOR:
261 if (!m_file->join_node(BAD_CAST STR_ITEM))
return false;
265 case CT_MATRIX:
case CT_SGMATRIX:
268 if (x != 0) { m_file->pop_node(); m_file->pop_node(); }
271 if (!m_file->join_node(BAD_CAST buf_x))
return false;
272 if (!m_file->join_node(BAD_CAST STR_ITEM))
return false;
280 if (!m_file->next_node(BAD_CAST STR_ITEM))
return false;
286 SerializableXmlReader00::read_item_end_wrapped(
293 SerializableXmlReader00::read_sgserializable_begin_wrapped(
294 const TSGDataType* type,
char* sgserializable_name,
295 EPrimitiveType*
generic)
297 xmlNode* m = m_file->m_stack_stream.back();
300 if ((buf = xmlGetProp(m, BAD_CAST STR_PROP_IS_NULL)) != NULL) {
302 *sgserializable_name =
'\0';
306 if ((buf = xmlGetProp(m, BAD_CAST STR_PROP_INSTANCE_NAME)) == NULL)
308 strncpy(sgserializable_name, (
const char*) buf,
STRING_LEN);
311 if ((buf = xmlGetProp(m, BAD_CAST STR_PROP_GENERIC_NAME))
322 SerializableXmlReader00::read_sgserializable_end_wrapped(
323 const TSGDataType* type,
const char* sgserializable_name,
324 EPrimitiveType
generic)
330 SerializableXmlReader00::read_type_begin_wrapped(
331 const TSGDataType* type,
const char* name,
const char* prefix)
337 if (!m_file->join_node(BAD_CAST name))
return false;
341 if ((t = xmlGetProp(m_file->m_stack_stream.back(),
342 BAD_CAST STR_PROP_TYPE)) == NULL)
return false;
343 if (xmlStrcmp(BAD_CAST buf, t) != 0) result =
false;
344 xmlFree(t);
if (!result)
return false;
350 SerializableXmlReader00::read_type_end_wrapped(
351 const TSGDataType* type,
const char* name,
const char* prefix)
static bool strtof(const char *str, float32_t *float_result)
std::complex< float64_t > complex128_t
static bool string_to_ptype(EPrimitiveType *ptype, const char *str)
static bool strtod(const char *str, float64_t *double_result)
#define SG_NOTIMPLEMENTED
Datatypes that shogun supports.
void to_string(char *dest, size_t n) const
all of classes and functions are contained in the shogun namespace
template class SGSparseVectorEntry
char string_t[STRING_LEN]
static bool strtold(const char *str, floatmax_t *long_double_result)