File Storage Node class. More...
#include <persistence.hpp>
Public Types | |
enum | { NONE = 0 , INT = 1 , REAL = 2 , FLOAT = REAL , STR = 3 , STRING = STR , SEQ = 4 , MAP = 5 , TYPE_MASK = 7 , FLOW = 8 , UNIFORM = 8 , EMPTY = 16 , NAMED = 32 } |
type of the file storage node More... | |
Public Member Functions | |
CV_WRAP | FileNode () |
The constructors. More... | |
FileNode (const FileStorage *fs, size_t blockIdx, size_t ofs) | |
FileNode (const FileNode &node) | |
FileNode & | operator= (const FileNode &node) |
FileNode | operator[] (const String &nodename) const |
Returns element of a mapping node or a sequence node. More... | |
CV_WRAP_AS (getNode) FileNode operator[](const char *nodename) const | |
CV_WRAP_AS (at) FileNode operator[](int i) const | |
CV_WRAP std::vector< String > | keys () const |
Returns keys of a mapping node. More... | |
CV_WRAP int | type () const |
Returns type of the node. More... | |
CV_WRAP bool | empty () const |
returns true if the node is empty More... | |
CV_WRAP bool | isNone () const |
returns true if the node is a "none" object More... | |
CV_WRAP bool | isSeq () const |
returns true if the node is a sequence More... | |
CV_WRAP bool | isMap () const |
returns true if the node is a mapping More... | |
CV_WRAP bool | isInt () const |
returns true if the node is an integer More... | |
CV_WRAP bool | isReal () const |
returns true if the node is a floating-point number More... | |
CV_WRAP bool | isString () const |
returns true if the node is a text string More... | |
CV_WRAP bool | isNamed () const |
returns true if the node has a name More... | |
CV_WRAP std::string | name () const |
returns the node name or an empty string if the node is nameless More... | |
CV_WRAP size_t | size () const |
returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. More... | |
CV_WRAP size_t | rawSize () const |
returns raw size of the FileNode in bytes More... | |
operator int () const | |
returns the node content as an integer. If the node stores floating-point number, it is rounded. More... | |
operator float () const | |
returns the node content as float More... | |
operator double () const | |
returns the node content as double More... | |
operator std::string () const | |
returns the node content as text string More... | |
uchar * | ptr () |
const uchar * | ptr () const |
FileNodeIterator | begin () const |
returns iterator pointing to the first node element More... | |
FileNodeIterator | end () const |
returns iterator pointing to the element following the last node element More... | |
void | readRaw (const String &fmt, void *vec, size_t len) const |
Reads node elements to the buffer with the specified format. More... | |
void | setValue (int type, const void *value, int len=-1) |
CV_WRAP double | real () const |
Simplified reading API to use with bindings. More... | |
CV_WRAP std::string | string () const |
Simplified reading API to use with bindings. More... | |
CV_WRAP Mat | mat () const |
Simplified reading API to use with bindings. More... | |
FileNode (FileStorage::Impl *fs, size_t blockIdx, size_t ofs) | |
Static Public Member Functions | |
static bool | isMap (int flags) |
static bool | isSeq (int flags) |
static bool | isCollection (int flags) |
static bool | isEmptyCollection (int flags) |
static bool | isFlow (int flags) |
Public Attributes | |
FileStorage::Impl * | fs |
size_t | blockIdx |
size_t | ofs |
File Storage Node class.
The node is used to store each and every element of the file storage opened for reading. When XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of other nodes. There can be named collections (mappings) where each element has a name and it is accessed by a name, and ordered collections (sequences) where elements do not have names but rather accessed by index. Type of the file node can be determined using FileNode::type method.
Note that file nodes are only used for navigating file storages opened for reading. When a file storage is opened for writing, no data is stored in memory after it is written.
anonymous enum |
type of the file storage node
Enumerator | |
---|---|
NONE | empty node |
INT | an integer |
REAL | floating-point number |
FLOAT | synonym or REAL |
STR | text string in UTF-8 encoding |
STRING | synonym for STR |
SEQ | sequence |
MAP | mapping |
TYPE_MASK | |
FLOW | compact representation of a sequence or mapping. Used only by YAML writer |
UNIFORM | UNIFORM is used only when reading FileStorage; FLOW is used only when writing. So they share the same bit. if set, means that all the collection elements are numbers of the same type (real's or int's). |
EMPTY | empty structure (sequence or mapping) |
NAMED | the node has a name (i.e. it is element of a mapping). |
CV_WRAP cv::FileNode::FileNode | ( | ) |
The constructors.
These constructors are used to create a default file node, construct it from obsolete structures or from the another file node.
cv::FileNode::FileNode | ( | const FileStorage * | fs, |
size_t | blockIdx, | ||
size_t | ofs | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
fs | Pointer to the file storage structure. |
blockIdx | Index of the memory block where the file node is stored |
ofs | Offset in bytes from the beginning of the serialized storage |
cv::FileNode::FileNode | ( | const FileNode & | node | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
node | File node to be used as initialization for the created file node. |
cv::FileNode::FileNode | ( | FileStorage::Impl * | fs, |
size_t | blockIdx, | ||
size_t | ofs | ||
) |
FileNodeIterator cv::FileNode::begin | ( | ) | const |
returns iterator pointing to the first node element
cv::FileNode::CV_WRAP_AS | ( | at | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
i | Index of an element in the sequence node. |
cv::FileNode::CV_WRAP_AS | ( | getNode | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nodename | Name of an element in the mapping node. |
CV_WRAP bool cv::FileNode::empty | ( | ) | const |
returns true if the node is empty
FileNodeIterator cv::FileNode::end | ( | ) | const |
returns iterator pointing to the element following the last node element
|
static |
|
static |
|
static |
CV_WRAP bool cv::FileNode::isInt | ( | ) | const |
returns true if the node is an integer
CV_WRAP bool cv::FileNode::isMap | ( | ) | const |
returns true if the node is a mapping
|
static |
CV_WRAP bool cv::FileNode::isNamed | ( | ) | const |
returns true if the node has a name
CV_WRAP bool cv::FileNode::isNone | ( | ) | const |
returns true if the node is a "none" object
CV_WRAP bool cv::FileNode::isReal | ( | ) | const |
returns true if the node is a floating-point number
CV_WRAP bool cv::FileNode::isSeq | ( | ) | const |
returns true if the node is a sequence
|
static |
CV_WRAP bool cv::FileNode::isString | ( | ) | const |
returns true if the node is a text string
CV_WRAP std::vector<String> cv::FileNode::keys | ( | ) | const |
Returns keys of a mapping node.
CV_WRAP std::string cv::FileNode::name | ( | ) | const |
returns the node name or an empty string if the node is nameless
cv::FileNode::operator double | ( | ) | const |
returns the node content as double
cv::FileNode::operator float | ( | ) | const |
returns the node content as float
cv::FileNode::operator int | ( | ) | const |
returns the node content as an integer. If the node stores floating-point number, it is rounded.
|
inline |
returns the node content as text string
Returns element of a mapping node or a sequence node.
nodename | Name of an element in the mapping node. |
uchar* cv::FileNode::ptr | ( | ) |
const uchar* cv::FileNode::ptr | ( | ) | const |
void cv::FileNode::readRaw | ( | const String & | fmt, |
void * | vec, | ||
size_t | len | ||
) | const |
Reads node elements to the buffer with the specified format.
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 destination array. |
len | Number of bytes to read (buffer size limit). If it is greater than number of remaining elements then all of them will be read. |
CV_WRAP double cv::FileNode::real | ( | ) | const |
Simplified reading API to use with bindings.
void cv::FileNode::setValue | ( | int | type, |
const void * | value, | ||
int | len = -1 |
||
) |
Internal method used when reading FileStorage. Sets the type (int, real or string) and value of the previously created node.
CV_WRAP size_t cv::FileNode::size | ( | ) | const |
returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.
CV_WRAP std::string cv::FileNode::string | ( | ) | const |
Simplified reading API to use with bindings.
CV_WRAP int cv::FileNode::type | ( | ) | const |
Returns type of the node.
size_t cv::FileNode::blockIdx |
FileStorage::Impl* cv::FileNode::fs |
size_t cv::FileNode::ofs |