MCPcopy Create free account
hub / github.com/creatale/node-dv / icvXMLParse

Function icvXMLParse

deps/opencv/modules/core/src/persistence.cpp:2239–2293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2237
2238
2239static void
2240icvXMLParse( CvFileStorage* fs )
2241{
2242 char* ptr = fs->buffer_start;
2243 CvStringHashNode *key = 0, *key2 = 0;
2244 CvAttrList* list = 0;
2245 int tag_type = 0;
2246
2247 // CV_XML_INSIDE_TAG is used to prohibit leading comments
2248 ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG );
2249
2250 if( memcmp( ptr, "<?xml", 5 ) != 0 )
2251
2252 CV_PARSE_ERROR( "Valid XML should start with \'<?xml ...?>\'" );
2253
2254 ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type );
2255
2256 /*{
2257 const char* version = cvAttrValue( list, "version" );
2258 if( version && strncmp( version, "1.", 2 ) != 0 )
2259 CV_Error( CV_StsParseError, "Unsupported version of XML" );
2260 }*/
2261 // we support any 8-bit encoding, so we do not need to check the actual encoding.
2262 // we do not support utf-16, but in the case of utf-16 we will not get here anyway.
2263 /*{
2264 const char* encoding = cvAttrValue( list, "encoding" );
2265 if( encoding && strcmp( encoding, "ASCII" ) != 0 &&
2266 strcmp( encoding, "UTF-8" ) != 0 &&
2267 strcmp( encoding, "utf-8" ) != 0 )
2268 CV_PARSE_ERROR( "Unsupported encoding" );
2269 }*/
2270
2271 while( *ptr != '\0' )
2272 {
2273 ptr = icvXMLSkipSpaces( fs, ptr, 0 );
2274
2275 if( *ptr != '\0' )
2276 {
2277 CvFileNode* root_node;
2278 ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type );
2279 if( tag_type != CV_XML_OPENING_TAG ||
2280 strcmp(key->str.ptr,"opencv_storage") != 0 )
2281 CV_PARSE_ERROR( "<opencv_storage> tag is missing" );
2282
2283 root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 );
2284 ptr = icvXMLParseValue( fs, ptr, root_node, CV_NODE_NONE );
2285 ptr = icvXMLParseTag( fs, ptr, &key2, &list, &tag_type );
2286 if( tag_type != CV_XML_CLOSING_TAG || key != key2 )
2287 CV_PARSE_ERROR( "</opencv_storage> tag is missing" );
2288 ptr = icvXMLSkipSpaces( fs, ptr, 0 );
2289 }
2290 }
2291
2292 assert( fs->dummy_eof != 0 );
2293}
2294
2295
2296/****************************************************************************************\

Callers 1

persistence.cppFile · 0.85

Calls 4

icvXMLSkipSpacesFunction · 0.85
icvXMLParseTagFunction · 0.85
cvSeqPushFunction · 0.85
icvXMLParseValueFunction · 0.85

Tested by

no test coverage detected