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

Function icvYMLWrite

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

Source from the content-addressed store, hash-verified

1442\****************************************************************************************/
1443
1444static void
1445icvYMLWrite( CvFileStorage* fs, const char* key, const char* data )
1446{
1447 int i, keylen = 0;
1448 int datalen = 0;
1449 int struct_flags;
1450 char* ptr;
1451
1452 struct_flags = fs->struct_flags;
1453
1454 if( key && key[0] == '\0' )
1455 key = 0;
1456
1457 if( CV_NODE_IS_COLLECTION(struct_flags) )
1458 {
1459 if( (CV_NODE_IS_MAP(struct_flags) ^ (key != 0)) )
1460 CV_Error( CV_StsBadArg, "An attempt to add element without a key to a map, "
1461 "or add element with key to sequence" );
1462 }
1463 else
1464 {
1465 fs->is_first = 0;
1466 struct_flags = CV_NODE_EMPTY | (key ? CV_NODE_MAP : CV_NODE_SEQ);
1467 }
1468
1469 if( key )
1470 {
1471 keylen = (int)strlen(key);
1472 if( keylen == 0 )
1473 CV_Error( CV_StsBadArg, "The key is an empty" );
1474
1475 if( keylen > CV_FS_MAX_LEN )
1476 CV_Error( CV_StsBadArg, "The key is too long" );
1477 }
1478
1479 if( data )
1480 datalen = (int)strlen(data);
1481
1482 if( CV_NODE_IS_FLOW(struct_flags) )
1483 {
1484 int new_offset;
1485 ptr = fs->buffer;
1486 if( !CV_NODE_IS_EMPTY(struct_flags) )
1487 *ptr++ = ',';
1488 new_offset = (int)(ptr - fs->buffer_start) + keylen + datalen;
1489 if( new_offset > fs->wrap_margin && new_offset - fs->struct_indent > 10 )
1490 {
1491 fs->buffer = ptr;
1492 ptr = icvFSFlush(fs);
1493 }
1494 else
1495 *ptr++ = ' ';
1496 }
1497 else
1498 {
1499 ptr = icvFSFlush(fs);
1500 if( !CV_NODE_IS_MAP(struct_flags) )
1501 {

Callers 5

icvYMLStartWriteStructFunction · 0.85
icvYMLWriteIntFunction · 0.85
icvYMLWriteRealFunction · 0.85
icvYMLWriteStringFunction · 0.85
cvWriteRawDataFunction · 0.85

Calls 4

icvFSFlushFunction · 0.85
cv_isalphaFunction · 0.85
icvFSResizeWriteBufferFunction · 0.85
cv_isalnumFunction · 0.85

Tested by

no test coverage detected