OpenCV  3.2.0-dev
Open Source Computer Vision
cv::FileNode Class Reference

File Storage Node class. More...

#include "persistence.hpp"

Collaboration diagram for cv::FileNode:

Public Types

enum  Type {
  NONE = 0,
  INT = 1,
  REAL = 2,
  FLOAT = REAL,
  STR = 3,
  STRING = STR,
  REF = 4,
  SEQ = 5,
  MAP = 6,
  TYPE_MASK = 7,
  FLOW = 8,
  USER = 16,
  EMPTY = 32,
  NAMED = 64
}
 type of the file storage node More...
 

Public Member Functions

 FileNode ()
 The constructors. More...
 
 FileNode (const CvFileStorage *fs, const CvFileNode *node)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 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. More...
 
FileNodeIterator begin () const
 returns iterator pointing to the first node element More...
 
bool empty () const
 returns true if the node is empty More...
 
FileNodeIterator end () const
 returns iterator pointing to the element following the last node element More...
 
bool isInt () const
 returns true if the node is an integer More...
 
bool isMap () const
 returns true if the node is a mapping More...
 
bool isNamed () const
 returns true if the node has a name More...
 
bool isNone () const
 returns true if the node is a "none" object More...
 
bool isReal () const
 returns true if the node is a floating-point number More...
 
bool isSeq () const
 returns true if the node is a sequence More...
 
bool isString () const
 returns true if the node is a text string More...
 
Mat mat () const
 Simplified reading API to use with bindings. More...
 
String name () const
 returns the node name or an empty string if the node is nameless More...
 
 operator double () const
 returns the node content as double More...
 
 operator float () const
 returns the node content as float More...
 
 operator std::string () const
 
 operator String () const
 returns the node content as text string More...
 
CvFileNodeoperator* ()
 returns pointer to the underlying file node More...
 
const CvFileNodeoperator* () const
 returns pointer to the underlying file node More...
 
FileNode operator[] (const String &nodename) const
 Returns element of a mapping node or a sequence node. More...
 
FileNode 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. More...
 
FileNode operator[] (int i) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void * readObj () const
 reads the registered object and returns pointer to it More...
 
void readRaw (const String &fmt, uchar *vec, size_t len) const
 Reads node elements to the buffer with the specified format. More...
 
double real () const
 Simplified reading API to use with bindings. More...
 
size_t size () const
 returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. More...
 
String string () const
 Simplified reading API to use with bindings. More...
 
int type () const
 Returns type of the node. More...
 

Public Attributes

const CvFileStoragefs
 
const CvFileNodenode
 

Related Functions

(Note that these are not member functions.)

void read (const FileNode &node, int &value, int default_value)
 
void read (const FileNode &node, float &value, float default_value)
 
void read (const FileNode &node, double &value, double default_value)
 
void read (const FileNode &node, String &value, const String &default_value)
 
void read (const FileNode &node, Mat &mat, const Mat &default_mat=Mat())
 
void read (const FileNode &node, SparseMat &mat, const SparseMat &default_mat=SparseMat())
 
void read (const FileNode &node, std::vector< KeyPoint > &keypoints)
 
void read (const FileNode &node, std::vector< DMatch > &matches)
 
template<typename _Tp >
static void read (const FileNode &node, Point_< _Tp > &value, const Point_< _Tp > &default_value)
 
template<typename _Tp >
static void read (const FileNode &node, Point3_< _Tp > &value, const Point3_< _Tp > &default_value)
 
template<typename _Tp >
static void read (const FileNode &node, Size_< _Tp > &value, const Size_< _Tp > &default_value)
 
template<typename _Tp >
static void read (const FileNode &node, Complex< _Tp > &value, const Complex< _Tp > &default_value)
 
template<typename _Tp >
static void read (const FileNode &node, Rect_< _Tp > &value, const Rect_< _Tp > &default_value)
 
template<typename _Tp , int cn>
static void read (const FileNode &node, Vec< _Tp, cn > &value, const Vec< _Tp, cn > &default_value)
 
template<typename _Tp >
static void read (const FileNode &node, Scalar_< _Tp > &value, const Scalar_< _Tp > &default_value)
 
static void read (const FileNode &node, Range &value, const Range &default_value)
 
static void read (const FileNode &node, bool &value, bool default_value)
 
static void read (const FileNode &node, uchar &value, uchar default_value)
 
static void read (const FileNode &node, schar &value, schar default_value)
 
static void read (const FileNode &node, ushort &value, ushort default_value)
 
static void read (const FileNode &node, short &value, short default_value)
 
template<typename _Tp >
static void read (FileNodeIterator &it, std::vector< _Tp > &vec, size_t maxCount=(size_t) INT_MAX)
 
template<typename _Tp >
static void read (const FileNode &node, std::vector< _Tp > &vec, const std::vector< _Tp > &default_value=std::vector< _Tp >())
 
template<typename _Tp >
static void operator>> (const FileNode &n, _Tp &value)
 Reads data from a file storage. More...
 
template<typename _Tp >
static void operator>> (const FileNode &n, std::vector< _Tp > &vec)
 Reads data from a file storage. More...
 
static void operator>> (const FileNode &n, std::vector< KeyPoint > &vec)
 Reads KeyPoint from a file storage. More...
 
static void operator>> (const FileNode &n, std::vector< DMatch > &vec)
 Reads DMatch from a file storage. More...
 

Detailed Description

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.

Examples:
filestorage.cpp.

Member Enumeration Documentation

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

REF 

integer of size size_t.

Typically used for storing complex dynamic structures where some elements reference the others

SEQ 

sequence

MAP 

mapping

TYPE_MASK 
FLOW 

compact representation of a sequence or mapping.

Used only by YAML writer

USER 

a registered object (e.g.

a matrix)

EMPTY 

empty structure (sequence or mapping)

NAMED 

the node has a name (i.e.

it is element of a mapping)

Constructor & Destructor Documentation

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.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

cv::FileNode::FileNode ( const CvFileStorage fs,
const CvFileNode node 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
fsPointer to the obsolete file storage structure.
nodeFile node to be used as initialization for the created file node.
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.

Parameters
nodeFile node to be used as initialization for the created file node.

Member Function Documentation

FileNodeIterator cv::FileNode::begin ( ) const

returns iterator pointing to the first node element

Examples:
filestorage.cpp.

Referenced by cv::FileNodeIterator::operator<(), operator>>(), and read().

Here is the caller graph for this function:

bool cv::FileNode::empty ( ) const

returns true if the node is empty

Examples:
filestorage.cpp.

Referenced by cv::Algorithm::load(), cv::Algorithm::loadFromString(), and cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

FileNodeIterator cv::FileNode::end ( ) const

returns iterator pointing to the element following the last node element

Examples:
filestorage.cpp.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isInt ( ) const

returns true if the node is an integer

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isMap ( ) const

returns true if the node is a mapping

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isNamed ( ) const

returns true if the node has a name

bool cv::FileNode::isNone ( ) const

returns true if the node is a "none" object

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isReal ( ) const

returns true if the node is a floating-point number

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isSeq ( ) const

returns true if the node is a sequence

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

bool cv::FileNode::isString ( ) const

returns true if the node is a text string

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

Mat cv::FileNode::mat ( ) const

Simplified reading API to use with bindings.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

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 std::string ( ) const
cv::FileNode::operator String ( ) const

returns the node content as text string

CvFileNode* cv::FileNode::operator* ( )

returns pointer to the underlying file node

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

const CvFileNode* cv::FileNode::operator* ( ) const

returns pointer to the underlying file node

FileNode cv::FileNode::operator[] ( const String nodename) const

Returns element of a mapping node or a sequence node.

Parameters
nodenameName of an element in the mapping node.
Returns
Returns the element with the given identifier.
FileNode cv::FileNode::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.

Parameters
nodenameName of an element in the mapping node.
FileNode cv::FileNode::operator[] ( int  i) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
iIndex of an element in the sequence node.
void* cv::FileNode::readObj ( ) const

reads the registered object and returns pointer to it

void cv::FileNode::readRaw ( const String fmt,
uchar 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.

Parameters
fmtSpecification of each array element. See format specification
vecPointer to the destination array.
lenNumber of elements to read. If it is greater than number of remaining elements then all of them will be read.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

double cv::FileNode::real ( ) const

Simplified reading API to use with bindings.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

size_t cv::FileNode::size ( ) const

returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.

String cv::FileNode::string ( ) const

Simplified reading API to use with bindings.

Referenced by cv::FileNodeIterator::operator<().

Here is the caller graph for this function:

int cv::FileNode::type ( ) const

Returns type of the node.

Returns
Type of the node. See FileNode::Type
Examples:
filestorage.cpp.

Friends And Related Function Documentation

template<typename _Tp >
static void operator>> ( const FileNode n,
_Tp &  value 
)
related

Reads data from a file storage.

template<typename _Tp >
static void operator>> ( const FileNode n,
std::vector< _Tp > &  vec 
)
related

Reads data from a file storage.

References begin().

Here is the call graph for this function:

static void operator>> ( const FileNode n,
std::vector< KeyPoint > &  vec 
)
related

Reads KeyPoint from a file storage.

static void operator>> ( const FileNode n,
std::vector< DMatch > &  vec 
)
related

Reads DMatch from a file storage.

void read ( const FileNode node,
int &  value,
int  default_value 
)
related
void read ( const FileNode node,
float &  value,
float  default_value 
)
related
void read ( const FileNode node,
double &  value,
double  default_value 
)
related
void read ( const FileNode node,
String value,
const String default_value 
)
related
void read ( const FileNode node,
Mat mat,
const Mat default_mat = Mat() 
)
related
void read ( const FileNode node,
SparseMat mat,
const SparseMat default_mat = SparseMat() 
)
related
void read ( const FileNode node,
std::vector< KeyPoint > &  keypoints 
)
related
void read ( const FileNode node,
std::vector< DMatch > &  matches 
)
related
template<typename _Tp >
static void read ( const FileNode node,
Point_< _Tp > &  value,
const Point_< _Tp > &  default_value 
)
related

References begin(), and cv::saturate_cast().

Here is the call graph for this function:

template<typename _Tp >
static void read ( const FileNode node,
Point3_< _Tp > &  value,
const Point3_< _Tp > &  default_value 
)
related

References begin(), and cv::saturate_cast().

Here is the call graph for this function:

template<typename _Tp >
static void read ( const FileNode node,
Size_< _Tp > &  value,
const Size_< _Tp > &  default_value 
)
related

References begin(), and cv::saturate_cast().

Here is the call graph for this function:

template<typename _Tp >
static void read ( const FileNode node,
Complex< _Tp > &  value,
const Complex< _Tp > &  default_value 
)
related

References begin(), and cv::saturate_cast().

Here is the call graph for this function:

template<typename _Tp >
static void read ( const FileNode node,
Rect_< _Tp > &  value,
const Rect_< _Tp > &  default_value 
)
related

References begin(), cv::saturate_cast(), and cv::Rect_< _Tp >::size().

Here is the call graph for this function:

template<typename _Tp , int cn>
static void read ( const FileNode node,
Vec< _Tp, cn > &  value,
const Vec< _Tp, cn > &  default_value 
)
related

References begin().

Here is the call graph for this function:

template<typename _Tp >
static void read ( const FileNode node,
Scalar_< _Tp > &  value,
const Scalar_< _Tp > &  default_value 
)
related

References begin(), and cv::saturate_cast().

Here is the call graph for this function:

static void read ( const FileNode node,
Range value,
const Range default_value 
)
related
static void read ( const FileNode node,
bool &  value,
bool  default_value 
)
related
static void read ( const FileNode node,
uchar value,
uchar  default_value 
)
related

References cv::saturate_cast().

Here is the call graph for this function:

static void read ( const FileNode node,
schar value,
schar  default_value 
)
related

References cv::saturate_cast().

Here is the call graph for this function:

static void read ( const FileNode node,
ushort value,
ushort  default_value 
)
related

References cv::saturate_cast().

Here is the call graph for this function:

static void read ( const FileNode node,
short &  value,
short  default_value 
)
related

References cv::saturate_cast().

Here is the call graph for this function:

template<typename _Tp >
static void read ( FileNodeIterator it,
std::vector< _Tp > &  vec,
size_t  maxCount = (size_t)INT_MAX 
)
related
template<typename _Tp >
static void read ( const FileNode node,
std::vector< _Tp > &  vec,
const std::vector< _Tp > &  default_value = std::vector<_Tp>() 
)
related

References begin(), and node.

Here is the call graph for this function:

Member Data Documentation

const CvFileStorage* cv::FileNode::fs
const CvFileNode* cv::FileNode::node

The documentation for this class was generated from the following file: