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

Function icvYMLParse

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

Source from the content-addressed store, hash-verified

1369
1370
1371static void
1372icvYMLParse( CvFileStorage* fs )
1373{
1374 char* ptr = fs->buffer_start;
1375 int is_first = 1;
1376
1377 for(;;)
1378 {
1379 // 0. skip leading comments and directives and ...
1380 // 1. reach the first item
1381 for(;;)
1382 {
1383 ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX );
1384 if( !ptr )
1385 return;
1386
1387 if( *ptr == '%' )
1388 {
1389 if( memcmp( ptr, "%YAML:", 6 ) == 0 &&
1390 memcmp( ptr, "%YAML:1.", 8 ) != 0 )
1391 CV_PARSE_ERROR( "Unsupported YAML version (it must be 1.x)" );
1392 *ptr = '\0';
1393 }
1394 else if( *ptr == '-' )
1395 {
1396 if( memcmp(ptr, "---", 3) == 0 )
1397 {
1398 ptr += 3;
1399 break;
1400 }
1401 else if( is_first )
1402 break;
1403 }
1404 else if( cv_isalnum(*ptr) || *ptr=='_')
1405 {
1406 if( !is_first )
1407 CV_PARSE_ERROR( "The YAML streams must start with '---', except the first one" );
1408 break;
1409 }
1410 else if( fs->dummy_eof )
1411 break;
1412 else
1413 CV_PARSE_ERROR( "Invalid or unsupported syntax" );
1414 }
1415
1416 ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX );
1417 if( memcmp( ptr, "...", 3 ) != 0 )
1418 {
1419 // 2. parse the collection
1420 CvFileNode* root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 );
1421
1422 ptr = icvYMLParseValue( fs, ptr, root_node, CV_NODE_NONE, 0 );
1423 if( !CV_NODE_IS_COLLECTION(root_node->tag) )
1424 CV_PARSE_ERROR( "Only collections as YAML streams are supported by this parser" );
1425
1426 // 3. parse until the end of file or next collection
1427 ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX );
1428 if( !ptr )

Callers 1

persistence.cppFile · 0.85

Calls 4

icvYMLSkipSpacesFunction · 0.85
cv_isalnumFunction · 0.85
cvSeqPushFunction · 0.85
icvYMLParseValueFunction · 0.85

Tested by

no test coverage detected