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

Function icvXMLWriteScalar

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

Source from the content-addressed store, hash-verified

2471
2472
2473static void
2474icvXMLWriteScalar( CvFileStorage* fs, const char* key, const char* data, int len )
2475{
2476 if( CV_NODE_IS_MAP(fs->struct_flags) ||
2477 (!CV_NODE_IS_COLLECTION(fs->struct_flags) && key) )
2478 {
2479 icvXMLWriteTag( fs, key, CV_XML_OPENING_TAG, cvAttrList(0,0) );
2480 char* ptr = icvFSResizeWriteBuffer( fs, fs->buffer, len );
2481 memcpy( ptr, data, len );
2482 fs->buffer = ptr + len;
2483 icvXMLWriteTag( fs, key, CV_XML_CLOSING_TAG, cvAttrList(0,0) );
2484 }
2485 else
2486 {
2487 char* ptr = fs->buffer;
2488 int new_offset = (int)(ptr - fs->buffer_start) + len;
2489
2490 if( key )
2491 CV_Error( CV_StsBadArg, "elements with keys can not be written to sequence" );
2492
2493 fs->struct_flags = CV_NODE_SEQ;
2494
2495 if( (new_offset > fs->wrap_margin && new_offset - fs->struct_indent > 10) ||
2496 (ptr > fs->buffer_start && ptr[-1] == '>' && !CV_NODE_IS_EMPTY(fs->struct_flags)) )
2497 {
2498 ptr = icvXMLFlush(fs);
2499 }
2500 else if( ptr > fs->buffer_start + fs->struct_indent && ptr[-1] != '>' )
2501 *ptr++ = ' ';
2502
2503 memcpy( ptr, data, len );
2504 fs->buffer = ptr + len;
2505 }
2506}
2507
2508
2509static void

Callers 4

icvXMLWriteIntFunction · 0.85
icvXMLWriteRealFunction · 0.85
icvXMLWriteStringFunction · 0.85
cvWriteRawDataFunction · 0.85

Calls 2

icvXMLWriteTagFunction · 0.85
icvFSResizeWriteBufferFunction · 0.85

Tested by

no test coverage detected