opencv
2.2.0
|
#include <core.hpp>
Public Types | |
enum | { READ =0, WRITE =1, APPEND =2 } |
file storage mode More... | |
enum | { UNDEFINED =0, VALUE_EXPECTED =1, NAME_EXPECTED =2, INSIDE_MAP =4 } |
Public Member Functions | |
CV_WRAP | FileStorage () |
the default constructor | |
CV_WRAP | FileStorage (const string &filename, int flags) |
the full constructor that opens file storage for reading or writing | |
FileStorage (CvFileStorage *fs) | |
the constructor that takes pointer to the C FileStorage structure | |
CV_WRAP FileNode | getFirstTopLevelNode () const |
returns the first element of the top-level mapping | |
virtual CV_WRAP bool | isOpened () const |
returns true if the object is associated with currently opened file. | |
virtual CV_WRAP bool | open (const string &filename, int flags) |
opens file storage for reading or writing. The previous storage is closed with release() | |
CvFileStorage * | operator* () |
returns pointer to the underlying C FileStorage structure | |
const CvFileStorage * | operator* () const |
returns pointer to the underlying C FileStorage structure | |
FileNode | operator[] (const string &nodename) const |
returns the specified element of the top-level mapping | |
CV_WRAP FileNode | operator[] (const char *nodename) const |
returns the specified element of the top-level mapping | |
virtual CV_WRAP void | release () |
closes the file and releases all the memory buffers | |
CV_WRAP FileNode | root (int streamidx=0) const |
returns the top-level mapping. YAML supports multiple streams | |
void | writeObj (const string &name, const void *obj) |
writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite() | |
void | writeRaw (const string &fmt, const uchar *vec, size_t len) |
writes one or more numbers of the specified format to the currently written structure | |
virtual | ~FileStorage () |
the destructor. calls release() | |
Static Public Member Functions | |
static string | getDefaultObjectName (const string &filename) |
returns the normalized object name for the specified file name | |
Public Attributes | |
string | elname |
the currently written element | |
Ptr< CvFileStorage > | fs |
the underlying C FileStorage structure | |
int | state |
the writer state | |
vector< char > | structs |
the stack of written structures | |
XML/YAML File Storage Class.
The class describes an object associated with XML or YAML file. It can be used to store data to such a file or read and decode the data.
The storage is organized as a tree of nested sequences (or lists) and mappings. Sequence is a heterogenious array, which elements are accessed by indices or sequentially using an iterator. Mapping is analogue of std::map or C structure, which elements are accessed by names. The most top level structure is a mapping. Leaves of the file storage tree are integers, floating-point numbers and text strings.
For example, the following code:
will produce the following file:
%YAML:1.0 test_int: 5 test_real: 3.1000000000000001e+00 test_string: ABCDEFGH test_mat: !!opencv-matrix rows: 3 cols: 3 dt: f data: [ 1., 0., 0., 0., 1., 0., 0., 0., 1. ] test_list: - 1.0000000000000000e-13 - 2 - 3.1415926535897931e+00 - -3435345 - "2-502 2-029 3egegeg" - { month:12, day:31, year:1969 } test_map: x: 1 y: 2 width: 100 height: 200 lbp: [ 0, 1, 1, 0, 1, 1, 0, 1 ]
and to read the file above, the following code can be used:
CV_WRAP cv::FileStorage::FileStorage | ( | ) |
the default constructor
CV_WRAP cv::FileStorage::FileStorage | ( | const string & | filename, |
int | flags | ||
) |
the full constructor that opens file storage for reading or writing
cv::FileStorage::FileStorage | ( | CvFileStorage * | fs | ) |
the constructor that takes pointer to the C FileStorage structure
|
virtual |
the destructor. calls release()
|
static |
returns the normalized object name for the specified file name
|
inline |
returns the first element of the top-level mapping
|
virtual |
returns true if the object is associated with currently opened file.
|
virtual |
opens file storage for reading or writing. The previous storage is closed with release()
|
inline |
returns pointer to the underlying C FileStorage structure
|
inline |
returns pointer to the underlying C FileStorage structure
FileNode cv::FileStorage::operator[] | ( | const string & | nodename | ) | const |
returns the specified element of the top-level mapping
returns the specified element of the top-level mapping
closes the file and releases all the memory buffers
returns the top-level mapping. YAML supports multiple streams
writes one or more numbers of the specified format to the currently written structure
string cv::FileStorage::elname |
the currently written element
Ptr<CvFileStorage> cv::FileStorage::fs |
the underlying C FileStorage structure
int cv::FileStorage::state |
the writer state
vector<char> cv::FileStorage::structs |
the stack of written structures