• Home
  • Raw
  • Download

Lines Matching refs:fs

108 typedef void (*CvStartWriteStruct)( struct CvFileStorage* fs, const char* key,
110 typedef void (*CvEndWriteStruct)( struct CvFileStorage* fs );
111 typedef void (*CvWriteInt)( struct CvFileStorage* fs, const char* key, int value );
112 typedef void (*CvWriteReal)( struct CvFileStorage* fs, const char* key, double value );
113 typedef void (*CvWriteString)( struct CvFileStorage* fs, const char* key,
115 typedef void (*CvWriteComment)( struct CvFileStorage* fs, const char* comment, int eol_comment );
116 typedef void (*CvStartNextStream)( struct CvFileStorage* fs );
163 #define CV_IS_FILE_STORAGE(fs) ((fs) != 0 && (fs)->flags == CV_FILE_STORAGE) argument
165 #define CV_CHECK_FILE_STORAGE(fs) \ argument
167 if( !CV_IS_FILE_STORAGE(fs) ) \
168 CV_ERROR( (fs) ? CV_StsBadArg : CV_StsNullPtr, \
172 #define CV_CHECK_OUTPUT_FILE_STORAGE(fs) \ argument
174 CV_CHECK_FILE_STORAGE(fs); \
175 if( !fs->write_mode ) \
231 icvParseError( fs, cvFuncName, (errmsg), __FILE__, __LINE__ ); \
237 icvParseError( CvFileStorage* fs, const char* func_name, in icvParseError() argument
241 sprintf( buf, "%s(%d): %s", fs->filename, fs->lineno, err_msg ); in icvParseError()
247 icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection ) in icvFSCreateCollection() argument
257 assert( fs->is_xml != 0 ); in icvFSCreateCollection()
262 sizeof(CvFileMapNode), fs->memstorage, 16 )); in icvFSCreateCollection()
267 CV_CALL( seq = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvFileNode), fs->memstorage )); in icvFSCreateCollection()
311 icvFSDoResize( CvFileStorage* fs, char* ptr, int len ) in icvFSDoResize() argument
318 int written_len = (int)(ptr - fs->buffer_start); in icvFSDoResize()
319 int new_size = (int)((fs->buffer_end - fs->buffer_start)*3/2); in icvFSDoResize()
322 fs->buffer = new_ptr + (fs->buffer - fs->buffer_start); in icvFSDoResize()
324 memcpy( new_ptr, fs->buffer_start, written_len ); in icvFSDoResize()
325 fs->buffer_start = new_ptr; in icvFSDoResize()
326 fs->buffer_end = fs->buffer_start + new_size; in icvFSDoResize()
335 inline char* icvFSResizeWriteBuffer( CvFileStorage* fs, char* ptr, int len ) in icvFSResizeWriteBuffer() argument
337 return ptr + len < fs->buffer_end ? ptr : icvFSDoResize( fs, ptr, len ); in icvFSResizeWriteBuffer()
342 icvFSFlush( CvFileStorage* fs ) in icvFSFlush() argument
344 char* ptr = fs->buffer; in icvFSFlush()
347 if( ptr > fs->buffer_start + fs->space ) in icvFSFlush()
351 fputs( fs->buffer_start, fs->file ); in icvFSFlush()
352 fs->buffer = fs->buffer_start; in icvFSFlush()
355 indent = fs->struct_indent; in icvFSFlush()
357 if( fs->space != indent ) in icvFSFlush()
359 if( fs->space < indent ) in icvFSFlush()
360 memset( fs->buffer_start + fs->space, ' ', indent - fs->space ); in icvFSFlush()
361 fs->space = indent; in icvFSFlush()
364 ptr = fs->buffer = fs->buffer_start + fs->space; in icvFSFlush()
383 CvFileStorage* fs = *p_fs; in cvReleaseFileStorage() local
386 if( fs->write_mode && fs->file ) in cvReleaseFileStorage()
388 if( fs->write_stack ) in cvReleaseFileStorage()
390 while( fs->write_stack->total > 0 ) in cvReleaseFileStorage()
391 cvEndWriteStruct(fs); in cvReleaseFileStorage()
393 icvFSFlush(fs); in cvReleaseFileStorage()
394 if( fs->is_xml ) in cvReleaseFileStorage()
395 fputs("</opencv_storage>\n", fs->file ); in cvReleaseFileStorage()
400 if( fs->file ) in cvReleaseFileStorage()
402 fclose( fs->file ); in cvReleaseFileStorage()
403 fs->file = 0; in cvReleaseFileStorage()
406 cvReleaseMemStorage( &fs->strstorage ); in cvReleaseFileStorage()
408 cvFree( &fs->buffer_start ); in cvReleaseFileStorage()
409 cvReleaseMemStorage( &fs->memstorage ); in cvReleaseFileStorage()
411 memset( fs, 0, sizeof(*fs) ); in cvReleaseFileStorage()
412 cvFree( &fs ); in cvReleaseFileStorage()
422 cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing ) in cvGetHashedKey() argument
431 CvStringHash* map = fs->str_hash; in cvGetHashedKey()
433 if( !fs ) in cvGetHashedKey()
476 cvGetFileNode( CvFileStorage* fs, CvFileNode* _map_node, in cvGetFileNode() argument
488 if( !fs ) in cvGetFileNode()
491 CV_CHECK_FILE_STORAGE(fs); in cvGetFileNode()
498 if( !fs->roots ) in cvGetFileNode()
500 attempts = fs->roots->total; in cvGetFileNode()
511 map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k ); in cvGetFileNode()
558 cvGetFileNodeByName( const CvFileStorage* fs, const CvFileNode* _map_node, const char* str ) in cvGetFileNodeByName() argument
569 if( !fs ) in cvGetFileNodeByName()
572 CV_CHECK_FILE_STORAGE(fs); in cvGetFileNodeByName()
584 if( !fs->roots ) in cvGetFileNodeByName()
586 attempts = fs->roots->total; in cvGetFileNodeByName()
596 map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k ); in cvGetFileNodeByName()
635 cvGetRootFileNode( const CvFileStorage* fs, int stream_index ) in cvGetRootFileNode() argument
642 CV_CHECK_FILE_STORAGE(fs); in cvGetRootFileNode()
644 if( !fs->roots || (unsigned)stream_index >= (unsigned)fs->roots->total ) in cvGetRootFileNode()
647 value = (CvFileNode*)cvGetSeqElem( fs->roots, stream_index ); in cvGetRootFileNode()
776 icvProcessSpecialDouble( CvFileStorage* fs, char* buf, double* value, char** endptr ) in icvProcessSpecialDouble() argument
807 static double icv_strtod( CvFileStorage* fs, char* ptr, char** endptr ) in icv_strtod() argument
823 icvProcessSpecialDouble( fs, ptr, &fval, endptr ); in icv_strtod()
834 icvYMLSkipSpaces( CvFileStorage* fs, char* ptr, int min_indent, int max_comment_indent ) in icvYMLSkipSpaces() argument
846 if( ptr - fs->buffer_start > max_comment_indent ) in icvYMLSkipSpaces()
852 if( ptr - fs->buffer_start < min_indent ) in icvYMLSkipSpaces()
858 int max_size = (int)(fs->buffer_end - fs->buffer_start); in icvYMLSkipSpaces()
859 ptr = fgets( fs->buffer_start, max_size, fs->file ); in icvYMLSkipSpaces()
863 ptr = fs->buffer_start; in icvYMLSkipSpaces()
866 fs->dummy_eof = 1; in icvYMLSkipSpaces()
872 if( ptr[l-1] != '\n' && ptr[l-1] != '\r' && !feof(fs->file) ) in icvYMLSkipSpaces()
876 fs->lineno++; in icvYMLSkipSpaces()
889 icvYMLParseKey( CvFileStorage* fs, char* ptr, in icvYMLParseKey() argument
917 CV_CALL( str_hash_node = cvGetHashedKey( fs, ptr, (int)(endptr - ptr), 1 )); in icvYMLParseKey()
918 CV_CALL( *value_placeholder = cvGetFileNode( fs, map_node, str_hash_node, 1 )); in icvYMLParseKey()
928 icvYMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node, in icvYMLParseValue() argument
985 CV_CALL( ptr = icvYMLSkipSpaces( fs, endptr, min_indent, INT_MAX )); in icvYMLParseValue()
1012 fval = icv_strtod( fs, ptr, &endptr ); in icvYMLParseValue()
1098 CV_CALL( node->data.str = cvMemStorageAllocString( fs->memstorage, buf, len )); in icvYMLParseValue()
1106 CV_CALL( icvFSCreateCollection( fs, CV_NODE_TYPE(struct_flags) + in icvYMLParseValue()
1115 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, new_min_indent, INT_MAX )); in icvYMLParseValue()
1128 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr + 1, new_min_indent, INT_MAX )); in icvYMLParseValue()
1133 CV_CALL( ptr = icvYMLParseKey( fs, ptr, node, &elem )); in icvYMLParseValue()
1134 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, new_min_indent, INT_MAX )); in icvYMLParseValue()
1142 CV_CALL( ptr = icvYMLParseValue( fs, ptr, elem, struct_flags, new_min_indent )); in icvYMLParseValue()
1183 … CV_CALL( node->data.str = cvMemStorageAllocString( fs->memstorage, ptr, (int)(str_end - ptr) )); in icvYMLParseValue()
1192 CV_CALL( icvFSCreateCollection( fs, struct_flags + in icvYMLParseValue()
1195 indent = (int)(ptr - fs->buffer_start); in icvYMLParseValue()
1204 CV_CALL( ptr = icvYMLParseKey( fs, ptr, node, &elem )); in icvYMLParseValue()
1215 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, indent + 1, INT_MAX )); in icvYMLParseValue()
1216 CV_CALL( ptr = icvYMLParseValue( fs, ptr, elem, struct_flags, indent + 1 )); in icvYMLParseValue()
1221 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX )); in icvYMLParseValue()
1222 if( ptr - fs->buffer_start != indent ) in icvYMLParseValue()
1224 if( ptr - fs->buffer_start < indent ) in icvYMLParseValue()
1243 icvYMLParse( CvFileStorage* fs ) in icvYMLParse() argument
1249 char* ptr = fs->buffer_start; in icvYMLParse()
1258 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX )); in icvYMLParse()
1289 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX )); in icvYMLParse()
1293 CvFileNode* root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 ); in icvYMLParse()
1295 CV_CALL( ptr = icvYMLParseValue( fs, ptr, root_node, CV_NODE_NONE, 0 )); in icvYMLParse()
1300 CV_CALL( ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX )); in icvYMLParse()
1305 if( fs->dummy_eof ) in icvYMLParse()
1320 icvYMLWrite( CvFileStorage* fs, const char* key, const char* data, const char* cvFuncName ) in icvYMLWrite() argument
1331 struct_flags = fs->struct_flags; in icvYMLWrite()
1344 fs->is_first = 0; in icvYMLWrite()
1364 ptr = fs->buffer; in icvYMLWrite()
1367 new_offset = (int)(ptr - fs->buffer_start) + keylen + datalen; in icvYMLWrite()
1368 if( new_offset > fs->wrap_margin && new_offset - fs->struct_indent > 10 ) in icvYMLWrite()
1370 fs->buffer = ptr; in icvYMLWrite()
1371 ptr = icvFSFlush(fs); in icvYMLWrite()
1378 ptr = icvFSFlush(fs); in icvYMLWrite()
1392 ptr = icvFSResizeWriteBuffer( fs, ptr, keylen ); in icvYMLWrite()
1411 ptr = icvFSResizeWriteBuffer( fs, ptr, datalen ); in icvYMLWrite()
1416 fs->buffer = ptr; in icvYMLWrite()
1417 fs->struct_flags = struct_flags & ~CV_NODE_EMPTY; in icvYMLWrite()
1424 icvYMLStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
1460 CV_CALL( icvYMLWrite( fs, key, data, cvFuncName ));
1462 parent_flags = fs->struct_flags;
1463 cvSeqPush( fs->write_stack, &parent_flags );
1464 fs->struct_flags = struct_flags;
1467 fs->struct_indent += CV_YML_INDENT + CV_NODE_IS_FLOW(struct_flags);
1474 icvYMLEndWriteStruct( CvFileStorage* fs ) in icvYMLEndWriteStruct() argument
1483 struct_flags = fs->struct_flags; in icvYMLEndWriteStruct()
1484 if( fs->write_stack->total == 0 ) in icvYMLEndWriteStruct()
1487 cvSeqPop( fs->write_stack, &parent_flags ); in icvYMLEndWriteStruct()
1491 ptr = fs->buffer; in icvYMLEndWriteStruct()
1492 if( ptr > fs->buffer_start + fs->struct_indent && !CV_NODE_IS_EMPTY(struct_flags) ) in icvYMLEndWriteStruct()
1495 fs->buffer = ptr; in icvYMLEndWriteStruct()
1499 ptr = icvFSFlush(fs); in icvYMLEndWriteStruct()
1501 fs->buffer = ptr + 2; in icvYMLEndWriteStruct()
1505 fs->struct_indent -= CV_YML_INDENT + CV_NODE_IS_FLOW(struct_flags); in icvYMLEndWriteStruct()
1506 assert( fs->struct_indent >= 0 ); in icvYMLEndWriteStruct()
1508 fs->struct_flags = parent_flags; in icvYMLEndWriteStruct()
1515 icvYMLStartNextStream( CvFileStorage* fs ) in icvYMLStartNextStream() argument
1521 if( !fs->is_first ) in icvYMLStartNextStream()
1523 while( fs->write_stack->total > 0 ) in icvYMLStartNextStream()
1524 icvYMLEndWriteStruct(fs); in icvYMLStartNextStream()
1526 fs->struct_indent = 0; in icvYMLStartNextStream()
1527 icvFSFlush(fs); in icvYMLStartNextStream()
1528 fputs( "...\n", fs->file ); in icvYMLStartNextStream()
1529 fputs( "---\n", fs->file ); in icvYMLStartNextStream()
1530 fs->buffer = fs->buffer_start; in icvYMLStartNextStream()
1538 icvYMLWriteInt( CvFileStorage* fs, const char* key, int value ) in icvYMLWriteInt() argument
1545 CV_CALL( icvYMLWrite( fs, key, icv_itoa( value, buf, 10 ), cvFuncName )); in icvYMLWriteInt()
1552 icvYMLWriteReal( CvFileStorage* fs, const char* key, double value ) in icvYMLWriteReal() argument
1559 CV_CALL( icvYMLWrite( fs, key, icvDoubleToString( buf, value ), cvFuncName )); in icvYMLWriteReal()
1566 icvYMLWriteString( CvFileStorage* fs, const char* key,
1627 CV_CALL( icvYMLWrite( fs, key, data, cvFuncName ));
1634 icvYMLWriteComment( CvFileStorage* fs, const char* comment, int eol_comment ) in icvYMLWriteComment() argument
1651 ptr = fs->buffer; in icvYMLWriteComment()
1654 fs->buffer_end - ptr < len || ptr == fs->buffer_start ) in icvYMLWriteComment()
1655 ptr = icvFSFlush( fs ); in icvYMLWriteComment()
1665 ptr = icvFSResizeWriteBuffer( fs, ptr, (int)(eol - comment) + 1 ); in icvYMLWriteComment()
1667 fs->buffer = ptr + (eol - comment); in icvYMLWriteComment()
1674 ptr = icvFSResizeWriteBuffer( fs, ptr, len ); in icvYMLWriteComment()
1676 fs->buffer = ptr + len; in icvYMLWriteComment()
1679 ptr = icvFSFlush( fs ); in icvYMLWriteComment()
1695 icvXMLSkipSpaces( CvFileStorage* fs, char* ptr, int mode ) in icvXMLSkipSpaces() argument
1750 int max_size = (int)(fs->buffer_end - fs->buffer_start); in icvXMLSkipSpaces()
1753 ptr = fgets( fs->buffer_start, max_size, fs->file ); in icvXMLSkipSpaces()
1756 ptr = fs->buffer_start; in icvXMLSkipSpaces()
1758 fs->dummy_eof = 1; in icvXMLSkipSpaces()
1764 if( ptr[l-1] != '\n' && ptr[l-1] != '\r' && !feof(fs->file) ) in icvXMLSkipSpaces()
1767 fs->lineno++; in icvXMLSkipSpaces()
1778 icvXMLParseTag( CvFileStorage* fs, char* ptr, CvStringHashNode** _tag,
1782 icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node, in icvXMLParseValue() argument
1803 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, 0 )); in icvXMLParseValue()
1823 CV_CALL( ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type )); in icvXMLParseValue()
1852 CV_CALL( icvFSCreateCollection( fs, is_noname ? CV_NODE_SEQ : CV_NODE_MAP, node )); in icvXMLParseValue()
1861 CV_CALL( elem = cvGetFileNode( fs, node, key, 1 )); in icvXMLParseValue()
1863 CV_CALL( ptr = icvXMLParseValue( fs, ptr, elem, elem_type)); in icvXMLParseValue()
1868 CV_CALL( ptr = icvXMLParseTag( fs, ptr, &key2, &list, &tag_type )); in icvXMLParseValue()
1882 CV_CALL( icvFSCreateCollection( fs, CV_NODE_SEQ, node )); in icvXMLParseValue()
1899 fval = icv_strtod( fs, ptr, &endptr ); in icvXMLParseValue()
1993 CV_CALL( elem->data.str = cvMemStorageAllocString( fs->memstorage, buf, i )); in icvXMLParseValue()
2007 CV_CALL( icvFSCreateCollection( fs, CV_NODE_IS_MAP(value_type) ? in icvXMLParseValue()
2027 icvXMLParseTag( CvFileStorage* fs, char* ptr, CvStringHashNode** _tag, in icvXMLParseTag() argument
2080 CV_CALL( attrname = cvGetHashedKey( fs, ptr, (int)(endptr - ptr), 1 )); in icvXMLParseTag()
2094 CV_CALL( chunk = (CvAttrList*)cvMemStorageAlloc( fs->memstorage, attr_buf_size )); in icvXMLParseTag()
2112 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG )); in icvXMLParseTag()
2120 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG )); in icvXMLParseTag()
2125 ptr = icvXMLParseValue( fs, ptr, &stub, CV_NODE_STRING ); in icvXMLParseTag()
2136 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG )); in icvXMLParseTag()
2176 icvXMLParse( CvFileStorage* fs ) in icvXMLParse() argument
2182 char* ptr = fs->buffer_start; in icvXMLParse()
2188 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG )); in icvXMLParse()
2193 CV_CALL( ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type )); in icvXMLParse()
2208 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, 0 )); in icvXMLParse()
2213 CV_CALL( ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type )); in icvXMLParse()
2218 root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 ); in icvXMLParse()
2219 CV_CALL( ptr = icvXMLParseValue( fs, ptr, root_node, CV_NODE_NONE )); in icvXMLParse()
2220 CV_CALL( ptr = icvXMLParseTag( fs, ptr, &key2, &list, &tag_type )); in icvXMLParse()
2223 CV_CALL( ptr = icvXMLSkipSpaces( fs, ptr, 0 )); in icvXMLParse()
2227 assert( fs->dummy_eof != 0 ); in icvXMLParse()
2240 icvXMLWriteTag( CvFileStorage* fs, const char* key, int tag_type, CvAttrList list ) in icvXMLWriteTag() argument
2246 char* ptr = fs->buffer; in icvXMLWriteTag()
2248 int struct_flags = fs->struct_flags; in icvXMLWriteTag()
2264 fs->is_first = 0; in icvXMLWriteTag()
2268 ptr = icvXMLFlush(fs); in icvXMLWriteTag()
2288 ptr = icvFSResizeWriteBuffer( fs, ptr, len ); in icvXMLWriteTag()
2307 ptr = icvFSResizeWriteBuffer( fs, ptr, len0 + len1 + 4 ); in icvXMLWriteTag()
2325 fs->buffer = ptr; in icvXMLWriteTag()
2326 fs->struct_flags = struct_flags & ~CV_NODE_EMPTY; in icvXMLWriteTag()
2333 icvXMLStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
2356 CV_CALL( icvXMLWriteTag( fs, key, CV_XML_OPENING_TAG, cvAttrList(attr,0) ));
2358 parent.struct_flags = fs->struct_flags & ~CV_NODE_EMPTY;
2359 parent.struct_indent = fs->struct_indent;
2360 parent.struct_tag = fs->struct_tag;
2361 cvSaveMemStoragePos( fs->strstorage, &parent.pos );
2362 cvSeqPush( fs->write_stack, &parent );
2364 fs->struct_indent += CV_XML_INDENT;
2366 icvXMLFlush( fs );
2368 fs->struct_flags = struct_flags;
2371 CV_CALL( fs->struct_tag = cvMemStorageAllocString( fs->strstorage, (char*)key, -1 ));
2375 fs->struct_tag.ptr = 0;
2376 fs->struct_tag.len = 0;
2384 icvXMLEndWriteStruct( CvFileStorage* fs ) in icvXMLEndWriteStruct() argument
2392 if( fs->write_stack->total == 0 ) in icvXMLEndWriteStruct()
2395 CV_CALL( icvXMLWriteTag( fs, fs->struct_tag.ptr, CV_XML_CLOSING_TAG, cvAttrList(0,0) )); in icvXMLEndWriteStruct()
2396 cvSeqPop( fs->write_stack, &parent ); in icvXMLEndWriteStruct()
2398 fs->struct_indent = parent.struct_indent; in icvXMLEndWriteStruct()
2399 fs->struct_flags = parent.struct_flags; in icvXMLEndWriteStruct()
2400 fs->struct_tag = parent.struct_tag; in icvXMLEndWriteStruct()
2401 cvRestoreMemStoragePos( fs->strstorage, &parent.pos ); in icvXMLEndWriteStruct()
2408 icvXMLStartNextStream( CvFileStorage* fs ) in icvXMLStartNextStream() argument
2414 if( !fs->is_first ) in icvXMLStartNextStream()
2416 while( fs->write_stack->total > 0 ) in icvXMLStartNextStream()
2417 icvXMLEndWriteStruct(fs); in icvXMLStartNextStream()
2419 fs->struct_indent = 0; in icvXMLStartNextStream()
2420 icvXMLFlush(fs); in icvXMLStartNextStream()
2424 fputs( "\n<!-- next stream -->\n", fs->file ); in icvXMLStartNextStream()
2427 fs->buffer = fs->buffer_start; in icvXMLStartNextStream()
2435 icvXMLWriteScalar( CvFileStorage* fs, const char* key, const char* data, int len ) in icvXMLWriteScalar() argument
2441 if( CV_NODE_IS_MAP(fs->struct_flags) || in icvXMLWriteScalar()
2442 (!CV_NODE_IS_COLLECTION(fs->struct_flags) && key) ) in icvXMLWriteScalar()
2444 icvXMLWriteTag( fs, key, CV_XML_OPENING_TAG, cvAttrList(0,0) ); in icvXMLWriteScalar()
2445 char* ptr = icvFSResizeWriteBuffer( fs, fs->buffer, len ); in icvXMLWriteScalar()
2447 fs->buffer = ptr + len; in icvXMLWriteScalar()
2448 icvXMLWriteTag( fs, key, CV_XML_CLOSING_TAG, cvAttrList(0,0) ); in icvXMLWriteScalar()
2452 char* ptr = fs->buffer; in icvXMLWriteScalar()
2453 int new_offset = (int)(ptr - fs->buffer_start) + len; in icvXMLWriteScalar()
2458 fs->struct_flags = CV_NODE_SEQ; in icvXMLWriteScalar()
2460 if( (new_offset > fs->wrap_margin && new_offset - fs->struct_indent > 10) || in icvXMLWriteScalar()
2461 (ptr > fs->buffer_start && ptr[-1] == '>' && !CV_NODE_IS_EMPTY(fs->struct_flags)) ) in icvXMLWriteScalar()
2463 ptr = icvXMLFlush(fs); in icvXMLWriteScalar()
2465 else if( ptr > fs->buffer_start + fs->struct_indent && ptr[-1] != '>' ) in icvXMLWriteScalar()
2469 fs->buffer = ptr + len; in icvXMLWriteScalar()
2477 icvXMLWriteInt( CvFileStorage* fs, const char* key, int value ) in icvXMLWriteInt() argument
2485 icvXMLWriteScalar( fs, key, ptr, len ); in icvXMLWriteInt()
2492 icvXMLWriteReal( CvFileStorage* fs, const char* key, double value ) in icvXMLWriteReal() argument
2500 icvXMLWriteScalar( fs, key, buf, len ); in icvXMLWriteReal()
2507 icvXMLWriteString( CvFileStorage* fs, const char* key, const char* str, int quote ) in icvXMLWriteString() argument
2587 icvXMLWriteScalar( fs, key, data, len ); in icvXMLWriteString()
2594 icvXMLWriteComment( CvFileStorage* fs, const char* comment, int eol_comment ) in icvXMLWriteComment() argument
2614 ptr = fs->buffer; in icvXMLWriteComment()
2616 if( multiline || !eol_comment || fs->buffer_end - ptr < len + 5 ) in icvXMLWriteComment()
2617 ptr = icvXMLFlush( fs ); in icvXMLWriteComment()
2618 else if( ptr > fs->buffer_start + fs->struct_indent ) in icvXMLWriteComment()
2623 ptr = icvFSResizeWriteBuffer( fs, ptr, len + 9 ); in icvXMLWriteComment()
2633 fs->buffer = ptr + len; in icvXMLWriteComment()
2634 ptr = icvXMLFlush(fs); in icvXMLWriteComment()
2642 ptr = icvFSResizeWriteBuffer( fs, ptr, (int)(eol - comment) + 1 ); in icvXMLWriteComment()
2651 ptr = icvFSResizeWriteBuffer( fs, ptr, len ); in icvXMLWriteComment()
2656 fs->buffer = ptr; in icvXMLWriteComment()
2657 ptr = icvXMLFlush( fs ); in icvXMLWriteComment()
2660 fs->buffer = ptr + 3; in icvXMLWriteComment()
2661 icvXMLFlush( fs ); in icvXMLWriteComment()
2675 CvFileStorage* fs = 0; in cvOpenFileStorage() local
2688 CV_CALL( fs = (CvFileStorage*)cvAlloc( sizeof(*fs) )); in cvOpenFileStorage()
2689 memset( fs, 0, sizeof(*fs)); in cvOpenFileStorage()
2691 CV_CALL( fs->memstorage = cvCreateMemStorage( default_block_size )); in cvOpenFileStorage()
2692 fs->dststorage = dststorage ? dststorage : fs->memstorage; in cvOpenFileStorage()
2694 CV_CALL( fs->filename = (char*)cvMemStorageAlloc( fs->memstorage, strlen(filename)+1 )); in cvOpenFileStorage()
2695 strcpy( fs->filename, filename ); in cvOpenFileStorage()
2697 fs->flags = CV_FILE_STORAGE; in cvOpenFileStorage()
2698 fs->write_mode = (flags & 3) != 0; in cvOpenFileStorage()
2699 fs->file = fopen( fs->filename, !fs->write_mode ? "rt" : !append ? "wt" : "a+t" ); in cvOpenFileStorage()
2700 if( !fs->file ) in cvOpenFileStorage()
2703 fs->roots = 0; in cvOpenFileStorage()
2704 fs->struct_indent = 0; in cvOpenFileStorage()
2705 fs->struct_flags = 0; in cvOpenFileStorage()
2706 fs->wrap_margin = 71; in cvOpenFileStorage()
2708 if( fs->write_mode ) in cvOpenFileStorage()
2712 int buf_size = CV_FS_MAX_LEN*(fs->is_xml ? 6 : 4) + 1024; in cvOpenFileStorage()
2714 char* dot_pos = strrchr( fs->filename, '.' ); in cvOpenFileStorage()
2715 fs->is_xml = dot_pos && (strcmp( dot_pos, ".xml" ) == 0 || in cvOpenFileStorage()
2719 fseek( fs->file, 0, SEEK_END ); in cvOpenFileStorage()
2721 fs->write_stack = cvCreateSeq( 0, sizeof(CvSeq), fs->is_xml ? in cvOpenFileStorage()
2722 sizeof(CvXMLStackRecord) : sizeof(int), fs->memstorage ); in cvOpenFileStorage()
2723 fs->is_first = 1; in cvOpenFileStorage()
2724 fs->struct_indent = 0; in cvOpenFileStorage()
2725 fs->struct_flags = CV_NODE_EMPTY; in cvOpenFileStorage()
2726 CV_CALL( fs->buffer_start = fs->buffer = (char*)cvAlloc( buf_size + 1024 )); in cvOpenFileStorage()
2727 fs->buffer_end = fs->buffer_start + buf_size; in cvOpenFileStorage()
2728 if( fs->is_xml ) in cvOpenFileStorage()
2730 int file_size = (int)ftell( fs->file ); in cvOpenFileStorage()
2731 CV_CALL( fs->strstorage = cvCreateChildMemStorage( fs->memstorage )); in cvOpenFileStorage()
2734 fputs( "<?xml version=\"1.0\"?>\n", fs->file ); in cvOpenFileStorage()
2735 fputs( "<opencv_storage>\n", fs->file ); in cvOpenFileStorage()
2743 fseek( fs->file, -xml_buf_size, SEEK_END ); in cvOpenFileStorage()
2748 int line_offset = ftell( fs->file ); in cvOpenFileStorage()
2749 char* ptr0 = fgets( xml_buf, xml_buf_size, fs->file ), *ptr; in cvOpenFileStorage()
2764 fclose( fs->file ); in cvOpenFileStorage()
2765 fs->file = fopen( fs->filename, "r+t" ); in cvOpenFileStorage()
2766 fseek( fs->file, last_occurence, SEEK_SET ); in cvOpenFileStorage()
2768 fputs( " <!-- resumed -->", fs->file ); in cvOpenFileStorage()
2769 fseek( fs->file, 0, SEEK_END ); in cvOpenFileStorage()
2770 fputs( "\n", fs->file ); in cvOpenFileStorage()
2772 fs->start_write_struct = icvXMLStartWriteStruct; in cvOpenFileStorage()
2773 fs->end_write_struct = icvXMLEndWriteStruct; in cvOpenFileStorage()
2774 fs->write_int = icvXMLWriteInt; in cvOpenFileStorage()
2775 fs->write_real = icvXMLWriteReal; in cvOpenFileStorage()
2776 fs->write_string = icvXMLWriteString; in cvOpenFileStorage()
2777 fs->write_comment = icvXMLWriteComment; in cvOpenFileStorage()
2778 fs->start_next_stream = icvXMLStartNextStream; in cvOpenFileStorage()
2783 fputs( "%YAML:1.0\n", fs->file ); in cvOpenFileStorage()
2785 fputs( "...\n---\n", fs->file ); in cvOpenFileStorage()
2786 fs->start_write_struct = icvYMLStartWriteStruct; in cvOpenFileStorage()
2787 fs->end_write_struct = icvYMLEndWriteStruct; in cvOpenFileStorage()
2788 fs->write_int = icvYMLWriteInt; in cvOpenFileStorage()
2789 fs->write_real = icvYMLWriteReal; in cvOpenFileStorage()
2790 fs->write_string = icvYMLWriteString; in cvOpenFileStorage()
2791 fs->write_comment = icvYMLWriteComment; in cvOpenFileStorage()
2792 fs->start_next_stream = icvYMLStartNextStream; in cvOpenFileStorage()
2800 fgets( buf, sizeof(buf)-2, fs->file ); in cvOpenFileStorage()
2801 fs->is_xml = strncmp( buf, yaml_signature, strlen(yaml_signature) ) != 0; in cvOpenFileStorage()
2803 fseek( fs->file, 0, SEEK_END ); in cvOpenFileStorage()
2804 buf_size = ftell( fs->file ); in cvOpenFileStorage()
2805 fseek( fs->file, 0, SEEK_SET ); in cvOpenFileStorage()
2810 CV_CALL( fs->str_hash = cvCreateMap( 0, sizeof(CvStringHash), in cvOpenFileStorage()
2811 sizeof(CvStringHashNode), fs->memstorage, 256 )); in cvOpenFileStorage()
2813 CV_CALL( fs->roots = cvCreateSeq( 0, sizeof(CvSeq), in cvOpenFileStorage()
2814 sizeof(CvFileNode), fs->memstorage )); in cvOpenFileStorage()
2816 CV_CALL( fs->buffer = fs->buffer_start = (char*)cvAlloc( buf_size + 256 )); in cvOpenFileStorage()
2817 fs->buffer_end = fs->buffer_start + buf_size; in cvOpenFileStorage()
2818 fs->buffer[0] = '\n'; in cvOpenFileStorage()
2819 fs->buffer[1] = '\0'; in cvOpenFileStorage()
2823 if( fs->is_xml ) in cvOpenFileStorage()
2824 icvXMLParse( fs ); in cvOpenFileStorage()
2826 icvYMLParse( fs ); in cvOpenFileStorage()
2830 cvFree( &fs->buffer_start ); in cvOpenFileStorage()
2831 fs->buffer = fs->buffer_end = 0; in cvOpenFileStorage()
2836 if( fs ) in cvOpenFileStorage()
2838 if( cvGetErrStatus() < 0 || !fs->file ) in cvOpenFileStorage()
2840 cvReleaseFileStorage( &fs ); in cvOpenFileStorage()
2842 else if( !fs->write_mode ) in cvOpenFileStorage()
2844 fclose( fs->file ); in cvOpenFileStorage()
2845 fs->file = 0; in cvOpenFileStorage()
2851 return fs; in cvOpenFileStorage()
2856 cvStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags, in cvStartWriteStruct() argument
2863 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvStartWriteStruct()
2864 CV_CALL( fs->start_write_struct( fs, key, struct_flags, type_name )); in cvStartWriteStruct()
2871 cvEndWriteStruct( CvFileStorage* fs ) in cvEndWriteStruct() argument
2877 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvEndWriteStruct()
2878 CV_CALL( fs->end_write_struct( fs )); in cvEndWriteStruct()
2885 cvWriteInt( CvFileStorage* fs, const char* key, int value ) in cvWriteInt() argument
2891 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvWriteInt()
2892 CV_CALL( fs->write_int( fs, key, value )); in cvWriteInt()
2899 cvWriteReal( CvFileStorage* fs, const char* key, double value ) in cvWriteReal() argument
2905 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvWriteReal()
2906 CV_CALL( fs->write_real( fs, key, value )); in cvWriteReal()
2913 cvWriteString( CvFileStorage* fs, const char* key, const char* value, int quote ) in cvWriteString() argument
2919 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvWriteString()
2920 CV_CALL( fs->write_string( fs, key, value, quote )); in cvWriteString()
2927 cvWriteComment( CvFileStorage* fs, const char* comment, int eol_comment ) in cvWriteComment() argument
2933 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvWriteComment()
2934 CV_CALL( fs->write_comment( fs, comment, eol_comment )); in cvWriteComment()
2941 cvStartNextStream( CvFileStorage* fs ) in cvStartNextStream() argument
2947 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvStartNextStream()
2948 CV_CALL( fs->start_next_stream( fs )); in cvStartNextStream()
3083 cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt ) in cvWriteRawData() argument
3095 CV_CHECK_OUTPUT_FILE_STORAGE( fs ); in cvWriteRawData()
3167 if( fs->is_xml ) in cvWriteRawData()
3170 CV_CALL( icvXMLWriteScalar( fs, 0, ptr, buf_len )); in cvWriteRawData()
3173 CV_CALL( icvYMLWrite( fs, 0, ptr, cvFuncName )); in cvWriteRawData()
3185 cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, CvSeqReader* reader ) in cvStartReadRawData() argument
3192 CV_CHECK_FILE_STORAGE( fs ); in cvStartReadRawData()
3222 cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, in cvReadRawDataSlice() argument
3233 CV_CHECK_FILE_STORAGE( fs ); in cvReadRawDataSlice()
3375 cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, in cvReadRawData() argument
3387 CV_CALL( cvStartReadRawData( fs, src, &reader )); in cvReadRawData()
3388 cvReadRawDataSlice( fs, &reader, CV_NODE_IS_SEQ(src->tag) ? in cvReadRawData()
3396 icvWriteFileNode( CvFileStorage* fs, const char* name, const CvFileNode* node );
3399 icvWriteCollection( CvFileStorage* fs, const CvFileNode* node ) in icvWriteCollection() argument
3414 icvWriteFileNode( fs, name, &elem->value ); in icvWriteCollection()
3421 icvWriteFileNode( CvFileStorage* fs, const char* name, const CvFileNode* node ) in icvWriteFileNode() argument
3430 fs->write_int( fs, name, node->data.i ); in icvWriteFileNode()
3433 fs->write_real( fs, name, node->data.f ); in icvWriteFileNode()
3436 fs->write_string( fs, name, node->data.str.ptr, 0 ); in icvWriteFileNode()
3440 fs->start_write_struct( fs, name, CV_NODE_TYPE(node->tag) + in icvWriteFileNode()
3443 icvWriteCollection( fs, node ); in icvWriteFileNode()
3444 fs->end_write_struct( fs ); in icvWriteFileNode()
3447 fs->start_write_struct( fs, name, CV_NODE_SEQ, 0 ); in icvWriteFileNode()
3448 fs->end_write_struct( fs ); in icvWriteFileNode()
3459 cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, in cvWriteFileNode() argument
3468 CV_CHECK_OUTPUT_FILE_STORAGE(fs); in cvWriteFileNode()
3475 CV_CALL( icvWriteCollection( fs, node )); in cvWriteFileNode()
3479 CV_CALL( icvWriteFileNode( fs, new_node_name, node )); in cvWriteFileNode()
3526 icvWriteMat( CvFileStorage* fs, const char* name, in icvWriteMat() argument
3540 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_MAT )); in icvWriteMat()
3541 cvWriteInt( fs, "rows", mat->rows ); in icvWriteMat()
3542 cvWriteInt( fs, "cols", mat->cols ); in icvWriteMat()
3543 cvWriteString( fs, "dt", icvEncodeFormat( CV_MAT_TYPE(mat->type), dt ), 0 ); in icvWriteMat()
3544 cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteMat()
3554 cvWriteRawData( fs, mat->data.ptr + y*mat->step, size.width, dt ); in icvWriteMat()
3555 cvEndWriteStruct( fs ); in icvWriteMat()
3556 cvEndWriteStruct( fs ); in icvWriteMat()
3571 icvReadMat( CvFileStorage* fs, CvFileNode* node ) in icvReadMat() argument
3583 CV_CALL( rows = cvReadIntByName( fs, node, "rows", 0 )); in icvReadMat()
3584 cols = cvReadIntByName( fs, node, "cols", 0 ); in icvReadMat()
3585 dt = cvReadStringByName( fs, node, "dt", 0 ); in icvReadMat()
3592 data = cvGetFileNodeByName( fs, node, "data" ); in icvReadMat()
3601 CV_CALL( cvReadRawData( fs, data, mat->data.ptr, dt )); in icvReadMat()
3621 icvWriteMatND( CvFileStorage* fs, const char* name, in icvWriteMatND() argument
3636 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_MATND )); in icvWriteMatND()
3638 cvStartWriteStruct( fs, "sizes", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteMatND()
3639 cvWriteRawData( fs, sizes, dims, "i" ); in icvWriteMatND()
3640 cvEndWriteStruct( fs ); in icvWriteMatND()
3641 cvWriteString( fs, "dt", icvEncodeFormat( cvGetElemType(mat), dt ), 0 ); in icvWriteMatND()
3642 cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteMatND()
3647 cvWriteRawData( fs, iterator.ptr[0], iterator.size.width, dt ); in icvWriteMatND()
3649 cvEndWriteStruct( fs ); in icvWriteMatND()
3650 cvEndWriteStruct( fs ); in icvWriteMatND()
3657 icvReadMatND( CvFileStorage* fs, CvFileNode* node ) in icvReadMatND() argument
3671 CV_CALL( sizes_node = cvGetFileNodeByName( fs, node, "sizes" )); in icvReadMatND()
3672 dt = cvReadStringByName( fs, node, "dt", 0 ); in icvReadMatND()
3683 CV_CALL( cvReadRawData( fs, sizes_node, sizes, "i" )); in icvReadMatND()
3686 data = cvGetFileNodeByName( fs, node, "data" ); in icvReadMatND()
3698 CV_CALL( cvReadRawData( fs, data, mat->data.ptr, dt )); in icvReadMatND()
3736 icvWriteSparseMat( CvFileStorage* fs, const char* name, in icvWriteSparseMat() argument
3758 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_SPARSE_MAT )); in icvWriteSparseMat()
3761 cvStartWriteStruct( fs, "sizes", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteSparseMat()
3762 cvWriteRawData( fs, mat->size, dims, "i" ); in icvWriteSparseMat()
3763 cvEndWriteStruct( fs ); in icvWriteSparseMat()
3764 cvWriteString( fs, "dt", icvEncodeFormat( CV_MAT_TYPE(mat->type), dt ), 0 ); in icvWriteSparseMat()
3765 cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteSparseMat()
3792 fs->write_int( fs, 0, k - dims + 1 ); in icvWriteSparseMat()
3795 fs->write_int( fs, 0, idx[k] ); in icvWriteSparseMat()
3801 cvWriteRawData( fs, val, 1, dt ); in icvWriteSparseMat()
3804 cvEndWriteStruct( fs ); in icvWriteSparseMat()
3805 cvEndWriteStruct( fs ); in icvWriteSparseMat()
3814 icvReadSparseMat( CvFileStorage* fs, CvFileNode* node ) in icvReadSparseMat() argument
3831 CV_CALL( sizes_node = cvGetFileNodeByName( fs, node, "sizes" )); in icvReadSparseMat()
3832 dt = cvReadStringByName( fs, node, "dt", 0 ); in icvReadSparseMat()
3844 CV_CALL( cvReadRawData( fs, sizes_node, sizes, "i" )); in icvReadSparseMat()
3847 data = cvGetFileNodeByName( fs, node, "data" ); in icvReadSparseMat()
3856 cvStartReadRawData( fs, data, &reader ); in icvReadSparseMat()
3887 CV_CALL( cvReadRawDataSlice( fs, &reader, cn, val, dt )); in icvReadSparseMat()
3908 icvWriteImage( CvFileStorage* fs, const char* name, in icvWriteImage() argument
3926 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_IMAGE )); in icvWriteImage()
3927 cvWriteInt( fs, "width", image->width ); in icvWriteImage()
3928 cvWriteInt( fs, "height", image->height ); in icvWriteImage()
3929 cvWriteString( fs, "origin", image->origin == IPL_ORIGIN_TL in icvWriteImage()
3931 cvWriteString( fs, "layout", image->dataOrder == IPL_DATA_ORDER_PLANE in icvWriteImage()
3935 cvStartWriteStruct( fs, "roi", CV_NODE_MAP + CV_NODE_FLOW ); in icvWriteImage()
3936 cvWriteInt( fs, "x", image->roi->xOffset ); in icvWriteImage()
3937 cvWriteInt( fs, "y", image->roi->yOffset ); in icvWriteImage()
3938 cvWriteInt( fs, "width", image->roi->width ); in icvWriteImage()
3939 cvWriteInt( fs, "height", image->roi->height ); in icvWriteImage()
3940 cvWriteInt( fs, "coi", image->roi->coi ); in icvWriteImage()
3941 cvEndWriteStruct( fs ); in icvWriteImage()
3947 cvWriteString( fs, "dt", dt, 0 ); in icvWriteImage()
3956 cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteImage()
3958 cvWriteRawData( fs, image->imageData + y*image->widthStep, size.width, dt ); in icvWriteImage()
3959 cvEndWriteStruct( fs ); in icvWriteImage()
3960 cvEndWriteStruct( fs ); in icvWriteImage()
3967 icvReadImage( CvFileStorage* fs, CvFileNode* node ) in icvReadImage() argument
3983 CV_CALL( width = cvReadIntByName( fs, node, "width", 0 )); in icvReadImage()
3984 height = cvReadIntByName( fs, node, "height", 0 ); in icvReadImage()
3985 dt = cvReadStringByName( fs, node, "dt", 0 ); in icvReadImage()
3986 origin = cvReadStringByName( fs, node, "origin", 0 ); in icvReadImage()
3992 data_order = cvReadStringByName( fs, node, "layout", "interleaved" ); in icvReadImage()
3996 data = cvGetFileNodeByName( fs, node, "data" ); in icvReadImage()
4007 roi_node = cvGetFileNodeByName( fs, node, "roi" ); in icvReadImage()
4010 roi.x = cvReadIntByName( fs, roi_node, "x", 0 ); in icvReadImage()
4011 roi.y = cvReadIntByName( fs, roi_node, "y", 0 ); in icvReadImage()
4012 roi.width = cvReadIntByName( fs, roi_node, "width", 0 ); in icvReadImage()
4013 roi.height = cvReadIntByName( fs, roi_node, "height", 0 ); in icvReadImage()
4014 coi = cvReadIntByName( fs, roi_node, "coi", 0 ); in icvReadImage()
4027 cvStartReadRawData( fs, data, &reader ); in icvReadImage()
4030 CV_CALL( cvReadRawDataSlice( fs, &reader, width, in icvReadImage()
4076 icvWriteHeaderData( CvFileStorage* fs, const CvSeq* seq, in icvWriteHeaderData() argument
4102 cvStartWriteStruct( fs, "rect", CV_NODE_MAP + CV_NODE_FLOW ); in icvWriteHeaderData()
4103 cvWriteInt( fs, "x", point_seq->rect.x ); in icvWriteHeaderData()
4104 cvWriteInt( fs, "y", point_seq->rect.y ); in icvWriteHeaderData()
4105 cvWriteInt( fs, "width", point_seq->rect.width ); in icvWriteHeaderData()
4106 cvWriteInt( fs, "height", point_seq->rect.height ); in icvWriteHeaderData()
4107 cvEndWriteStruct( fs ); in icvWriteHeaderData()
4108 cvWriteInt( fs, "color", point_seq->color ); in icvWriteHeaderData()
4115 cvStartWriteStruct( fs, "origin", CV_NODE_MAP + CV_NODE_FLOW ); in icvWriteHeaderData()
4116 cvWriteInt( fs, "x", chain->origin.x ); in icvWriteHeaderData()
4117 cvWriteInt( fs, "y", chain->origin.y ); in icvWriteHeaderData()
4118 cvEndWriteStruct( fs ); in icvWriteHeaderData()
4134 cvWriteString( fs, "header_dt", header_dt, 0 ); in icvWriteHeaderData()
4135 cvStartWriteStruct( fs, "header_user_data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteHeaderData()
4136 cvWriteRawData( fs, (uchar*)seq + sizeof(CvSeq), 1, header_dt ); in icvWriteHeaderData()
4137 cvEndWriteStruct( fs ); in icvWriteHeaderData()
4192 icvWriteSeq( CvFileStorage* fs, const char* name, in icvWriteSeq() argument
4206 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_SEQ )); in icvWriteSeq()
4209 cvWriteInt( fs, "level", level ); in icvWriteSeq()
4212 cvWriteString( fs, "flags", buf, 1 ); in icvWriteSeq()
4213 cvWriteInt( fs, "count", seq->total ); in icvWriteSeq()
4215 cvWriteString( fs, "dt", dt, 0 ); in icvWriteSeq()
4217 CV_CALL( icvWriteHeaderData( fs, seq, &attr, sizeof(CvSeq) )); in icvWriteSeq()
4218 cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); in icvWriteSeq()
4222 cvWriteRawData( fs, block->data, block->count, dt ); in icvWriteSeq()
4226 cvEndWriteStruct( fs ); in icvWriteSeq()
4227 cvEndWriteStruct( fs ); in icvWriteSeq()
4234 icvWriteSeqTree( CvFileStorage* fs, const char* name, in icvWriteSeqTree() argument
4253 CV_CALL( icvWriteSeq( fs, name, seq, attr, -1 )); in icvWriteSeqTree()
4259 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_SEQ_TREE )); in icvWriteSeqTree()
4260 CV_CALL( cvStartWriteStruct( fs, "sequences", CV_NODE_SEQ )); in icvWriteSeqTree()
4267 CV_CALL( icvWriteSeq( fs, 0, tree_iterator.node, attr, tree_iterator.level )); in icvWriteSeqTree()
4271 cvEndWriteStruct( fs ); in icvWriteSeqTree()
4272 cvEndWriteStruct( fs ); in icvWriteSeqTree()
4280 icvReadSeq( CvFileStorage* fs, CvFileNode* node ) in icvReadSeq() argument
4300 CV_CALL( flags_str = cvReadStringByName( fs, node, "flags", 0 )); in icvReadSeq()
4301 total = cvReadIntByName( fs, node, "count", -1 ); in icvReadSeq()
4302 dt = cvReadStringByName( fs, node, "dt", 0 ); in icvReadSeq()
4311 header_dt = cvReadStringByName( fs, node, "header_dt", 0 ); in icvReadSeq()
4312 header_node = cvGetFileNodeByName( fs, node, "header_user_data" ); in icvReadSeq()
4318 rect_node = cvGetFileNodeByName( fs, node, "rect" ); in icvReadSeq()
4319 origin_node = cvGetFileNodeByName( fs, node, "origin" ); in icvReadSeq()
4334 CV_CALL( seq = cvCreateSeq( flags, header_size, elem_size, fs->dststorage )); in icvReadSeq()
4338 CV_CALL( cvReadRawData( fs, header_node, (char*)seq + sizeof(CvSeq), header_dt )); in icvReadSeq()
4343 point_seq->rect.x = cvReadIntByName( fs, rect_node, "x", 0 ); in icvReadSeq()
4344 point_seq->rect.y = cvReadIntByName( fs, rect_node, "y", 0 ); in icvReadSeq()
4345 point_seq->rect.width = cvReadIntByName( fs, rect_node, "width", 0 ); in icvReadSeq()
4346 point_seq->rect.height = cvReadIntByName( fs, rect_node, "height", 0 ); in icvReadSeq()
4347 point_seq->color = cvReadIntByName( fs, node, "color", 0 ); in icvReadSeq()
4352 chain->origin.x = cvReadIntByName( fs, origin_node, "x", 0 ); in icvReadSeq()
4353 chain->origin.y = cvReadIntByName( fs, origin_node, "y", 0 ); in icvReadSeq()
4362 data = cvGetFileNodeByName( fs, node, "data" ); in icvReadSeq()
4369 cvStartReadRawData( fs, data, &reader ); in icvReadSeq()
4373 cvReadRawDataSlice( fs, &reader, delta, block->data, dt ); in icvReadSeq()
4387 icvReadSeqTree( CvFileStorage* fs, CvFileNode* node ) in icvReadSeqTree() argument
4394 CvFileNode *sequences_node = cvGetFileNodeByName( fs, node, "sequences" ); in icvReadSeqTree()
4416 CV_CALL( seq = (CvSeq*)cvRead( fs, elem )); in icvReadSeqTree()
4417 CV_CALL( level = cvReadIntByName( fs, elem, "level", -1 )); in icvReadSeqTree()
4485 icvWriteGraph( CvFileStorage* fs, const char* name, in icvWriteGraph() argument
4521 CV_CALL( cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_GRAPH )); in icvWriteGraph()
4524 cvWriteString( fs, "flags", buf, 1 ); in icvWriteGraph()
4526 cvWriteInt( fs, "vertex_count", vtx_count ); in icvWriteGraph()
4530 cvWriteString( fs, "vertex_dt", vtx_dt, 0 ); in icvWriteGraph()
4532 cvWriteInt( fs, "edge_count", edge_count ); in icvWriteGraph()
4537 cvWriteString( fs, "edge_dt", edge_dt, 0 ); in icvWriteGraph()
4539 CV_CALL( icvWriteHeaderData( fs, (CvSeq*)graph, &attr, sizeof(CvGraph) )); in icvWriteGraph()
4569 cvStartWriteStruct( fs, k == 0 ? "vertices" : "edges", in icvWriteGraph()
4595 cvWriteRawData( fs, write_buf, write_count, dt ); in icvWriteGraph()
4604 cvWriteRawData( fs, write_buf, write_count, dt ); in icvWriteGraph()
4605 cvEndWriteStruct( fs ); in icvWriteGraph()
4609 cvEndWriteStruct( fs ); in icvWriteGraph()
4629 icvReadGraph( CvFileStorage* fs, CvFileNode* node ) in icvReadGraph() argument
4654 CV_CALL( flags_str = cvReadStringByName( fs, node, "flags", 0 )); in icvReadGraph()
4655 vtx_dt = cvReadStringByName( fs, node, "vertex_dt", 0 ); in icvReadGraph()
4656 edge_dt = cvReadStringByName( fs, node, "edge_dt", 0 ); in icvReadGraph()
4657 vtx_count = cvReadIntByName( fs, node, "vertex_count", -1 ); in icvReadGraph()
4658 edge_count = cvReadIntByName( fs, node, "edge_count", -1 ); in icvReadGraph()
4668 header_dt = cvReadStringByName( fs, node, "header_dt", 0 ); in icvReadGraph()
4669 header_node = cvGetFileNodeByName( fs, node, "header_user_data" ); in icvReadGraph()
4722 CV_CALL( graph = cvCreateGraph( flags, header_size, vtx_size, edge_size, fs->dststorage )); in icvReadGraph()
4725 CV_CALL( cvReadRawData( fs, header_node, (char*)graph + sizeof(CvGraph), header_dt )); in icvReadGraph()
4732 vtx_node = cvGetFileNodeByName( fs, node, "vertices" ); in icvReadGraph()
4733 edge_node = cvGetFileNodeByName( fs, node, "edges" ); in icvReadGraph()
4751 cvStartReadRawData( fs, k == 0 ? vtx_node : edge_node, &reader ); in icvReadGraph()
4758 cvReadRawDataSlice( fs, &reader, count, read_buf, dt ); in icvReadGraph()
5047 cvRead( CvFileStorage* fs, CvFileNode* node, CvAttrList* list ) in cvRead() argument
5055 CV_CHECK_FILE_STORAGE( fs ); in cvRead()
5063 CV_CALL( obj = node->info->read( fs, node )); in cvRead()
5076 cvWrite( CvFileStorage* fs, const char* name, in cvWrite() argument
5085 CV_CHECK_OUTPUT_FILE_STORAGE( fs ); in cvWrite()
5097 CV_CALL( info->write( fs, name, ptr, attributes )); in cvWrite()
5108 CvFileStorage* fs = 0; in cvSave() local
5120 CV_CALL( fs = cvOpenFileStorage( filename, 0, CV_STORAGE_WRITE )); in cvSave()
5121 if( !fs ) in cvSave()
5161 CV_CALL( cvWriteComment( fs, comment, 0 )); in cvSave()
5162 CV_CALL( cvWrite( fs, name, struct_ptr, attributes )); in cvSave()
5166 cvReleaseFileStorage( &fs ); in cvSave()
5176 CvFileStorage* fs = 0; in cvLoad() local
5183 CV_CALL( fs = cvOpenFileStorage( filename, memstorage, CV_STORAGE_READ )); in cvLoad()
5185 if( !fs ) in cvLoad()
5190 CV_CALL( node = cvGetFileNodeByName( fs, 0, name )); in cvLoad()
5195 for( k = 0; k < fs->roots->total; k++ ) in cvLoad()
5200 node = (CvFileNode*)cvGetSeqElem( fs->roots, k ); in cvLoad()
5228 CV_CALL( ptr = cvRead( fs, node, 0 )); in cvLoad()
5237 cvReleaseFileStorage( &fs ); in cvLoad()