OpenCV
3.1.0
Open Source Computer Vision
|
XML/YAML file storage class that encapsulates all the information necessary for writing or reading data to/from a file. More...
#include "persistence.hpp"
Public Types | |
enum | { UNDEFINED = 0, VALUE_EXPECTED = 1, NAME_EXPECTED = 2, INSIDE_MAP = 4 } |
enum | Mode { READ = 0, WRITE = 1, APPEND = 2, MEMORY = 4, FORMAT_MASK = (7<<3), FORMAT_AUTO = 0, FORMAT_XML = (1<<3), FORMAT_YAML = (2<<3) } |
file storage mode More... | |
Public Member Functions | |
FileStorage () | |
The constructors. More... | |
FileStorage (const String &source, int flags, const String &encoding=String()) | |
FileStorage (CvFileStorage *fs, bool owning=true) | |
virtual | ~FileStorage () |
the destructor. calls release() More... | |
FileNode | getFirstTopLevelNode () const |
Returns the first element of the top-level mapping. More... | |
virtual bool | isOpened () const |
Checks whether the file is opened. More... | |
virtual bool | open (const String &filename, int flags, const String &encoding=String()) |
Opens a file. More... | |
CvFileStorage * | operator* () |
Returns the obsolete C FileStorage structure. More... | |
const CvFileStorage * | operator* () const |
FileNode | operator[] (const String &nodename) const |
Returns the specified element of the top-level mapping. More... | |
FileNode | operator[] (const char *nodename) const |
virtual void | release () |
Closes the file and releases all the memory buffers. More... | |
virtual String | releaseAndGetString () |
Closes the file and releases all the memory buffers. More... | |
FileNode | root (int streamidx=0) const |
Returns the top-level mapping. More... | |
void | writeObj (const String &name, const void *obj) |
Writes the registered C structure (CvMat, CvMatND, CvSeq). More... | |
void | writeRaw (const String &fmt, const uchar *vec, size_t len) |
Writes multiple numbers. More... | |
Static Public Member Functions | |
static String | getDefaultObjectName (const String &filename) |
Returns the normalized object name for the specified name of a file. More... | |
Public Attributes | |
String | elname |
the currently written element More... | |
Ptr< CvFileStorage > | fs |
the underlying C FileStorage structure More... | |
int | state |
the writer state More... | |
std::vector< char > | structs |
the stack of written structures More... | |
Related Functions | |
(Note that these are not member functions.) | |
FileStorage & | operator<< (FileStorage &fs, const String &str) |
Writes string to a file storage. More... | |
void | write (FileStorage &fs, const String &name, int value) |
void | write (FileStorage &fs, const String &name, float value) |
void | write (FileStorage &fs, const String &name, double value) |
void | write (FileStorage &fs, const String &name, const String &value) |
void | write (FileStorage &fs, const String &name, const Mat &value) |
void | write (FileStorage &fs, const String &name, const SparseMat &value) |
void | write (FileStorage &fs, const String &name, const std::vector< KeyPoint > &value) |
void | write (FileStorage &fs, const String &name, const std::vector< DMatch > &value) |
void | writeScalar (FileStorage &fs, int value) |
void | writeScalar (FileStorage &fs, float value) |
void | writeScalar (FileStorage &fs, double value) |
void | writeScalar (FileStorage &fs, const String &value) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const _Tp &value) |
template<> | |
void | write (FileStorage &fs, const int &value) |
template<> | |
void | write (FileStorage &fs, const float &value) |
template<> | |
void | write (FileStorage &fs, const double &value) |
template<> | |
void | write (FileStorage &fs, const String &value) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Point_< _Tp > &pt) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Point3_< _Tp > &pt) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Size_< _Tp > &sz) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Complex< _Tp > &c) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Rect_< _Tp > &r) |
template<typename _Tp , int cn> | |
static void | write (FileStorage &fs, const Vec< _Tp, cn > &v) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const Scalar_< _Tp > &s) |
static void | write (FileStorage &fs, const Range &r) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const std::vector< _Tp > &vec) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Point_< _Tp > &pt) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Point3_< _Tp > &pt) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Size_< _Tp > &sz) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Complex< _Tp > &c) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Rect_< _Tp > &r) |
template<typename _Tp , int cn> | |
static void | write (FileStorage &fs, const String &name, const Vec< _Tp, cn > &v) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const Scalar_< _Tp > &s) |
static void | write (FileStorage &fs, const String &name, const Range &r) |
template<typename _Tp > | |
static void | write (FileStorage &fs, const String &name, const std::vector< _Tp > &vec) |
template<typename _Tp > | |
static FileStorage & | operator<< (FileStorage &fs, const _Tp &value) |
Writes data to a file storage. More... | |
static FileStorage & | operator<< (FileStorage &fs, const char *str) |
Writes data to a file storage. More... | |
static FileStorage & | operator<< (FileStorage &fs, char *value) |
Writes data to a file storage. More... | |
XML/YAML file storage class that encapsulates all the information necessary for writing or reading data to/from a file.
cv::FileStorage::FileStorage | ( | ) |
The constructors.
The full constructor opens the file. Alternatively you can use the default constructor and then call FileStorage::open.
cv::FileStorage::FileStorage | ( | const String & | source, |
int | flags, | ||
const String & | encoding = String() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
source | Name of the file to open or the text string to read the data from. Extension of the file (.xml or .yml/.yaml) determines its format (XML or YAML respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.). |
flags | Mode of operation. See FileStorage::Mode |
encoding | Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it. |
cv::FileStorage::FileStorage | ( | CvFileStorage * | fs, |
bool | owning = true |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
virtual |
the destructor. calls release()
Returns the normalized object name for the specified name of a file.
filename | Name of a file |
FileNode cv::FileStorage::getFirstTopLevelNode | ( | ) | const |
Returns the first element of the top-level mapping.
|
virtual |
Checks whether the file is opened.
|
virtual |
Opens a file.
See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release before opening the file.
filename | Name of the file to open or the text string to read the data from. Extension of the file (.xml or .yml/.yaml) determines its format (XML or YAML respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.). |
flags | Mode of operation. One of FileStorage::Mode |
encoding | Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it. |
|
inline |
Returns the obsolete C FileStorage structure.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the specified element of the top-level mapping.
nodename | Name of the file node. |
FileNode cv::FileStorage::operator[] | ( | const char * | nodename | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
virtual |
Closes the file and releases all the memory buffers.
Call this method after all I/O operations with the storage are finished.
|
virtual |
Closes the file and releases all the memory buffers.
Call this method after all I/O operations with the storage are finished. If the storage was opened for writing data and FileStorage::WRITE was specified
FileNode cv::FileStorage::root | ( | int | streamidx = 0 | ) | const |
Returns the top-level mapping.
streamidx | Zero-based index of the stream. In most cases there is only one stream in the file. However, YAML supports multiple streams and so there can be several. |
void cv::FileStorage::writeObj | ( | const String & | name, |
const void * | obj | ||
) |
Writes multiple numbers.
Writes one or more numbers of the specified format to the currently written structure. Usually it is more convenient to use operator <<
instead of this method.
fmt | Specification of each array element, see format specification |
vec | Pointer to the written array. |
len | Number of the uchar elements to write. |
|
related |
Writes string to a file storage.
|
related |
Writes data to a file storage.
|
related |
Writes data to a file storage.
|
related |
Writes data to a file storage.
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
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
std::vector<char> cv::FileStorage::structs |
the stack of written structures