/** @brief Reads node elements to the buffer with the specified format.
- Usually it is more convenient to use operator `>>` instead of this method.
- @param fmt Specification of each array element. See @ref format_spec "format specification"
- @param vec Pointer to the destination array.
- @param len Number of elements to read. If it is greater than number of remaining elements then all
- of them will be read.
+ Usually it is more convenient to use operator `>>` instead of this method.
+ @param fmt Specification of each array element. See @ref format_spec "format specification"
+ @param vec Pointer to the destination array.
+ @param 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.
*/
- void readRaw( const String& fmt, uchar* vec, size_t len ) const;
+ void readRaw( const String& fmt, void* vec, size_t len ) const;
- //! reads the registered object and returns pointer to it
- void* readObj() const;
+ /** Internal method used when reading FileStorage.
+ Sets the type (int, real or string) and value of the previously created node.
+ */
+ void setValue( int type, const void* value, int len=-1 );
//! Simplified reading API to use with bindings.
CV_WRAP double real() const;
/** @brief Reads node elements to the buffer with the specified format.
- Usually it is more convenient to use operator `>>` instead of this method.
- @param fmt Specification of each array element. See @ref format_spec "format specification"
- @param vec Pointer to the destination array.
- @param maxCount Number of elements to read. If it is greater than number of remaining elements then
- all of them will be read.
+ Usually it is more convenient to use operator `>>` instead of this method.
+ @param fmt Specification of each array element. See @ref format_spec "format specification"
+ @param vec Pointer to the destination array.
+ @param 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.
-
*/
- FileNodeIterator& readRaw( const String& fmt, uchar* vec,
+ FileNodeIterator& readRaw( const String& fmt, void* vec,
- size_t maxCount=(size_t)INT_MAX );
+ size_t len=(size_t)INT_MAX );
- struct SeqReader
- {
- int header_size;
- void* seq; /* sequence, beign read; CvSeq */
- void* block; /* current block; CvSeqBlock */
- schar* ptr; /* pointer to element be read next */
- schar* block_min; /* pointer to the beginning of block */
- schar* block_max; /* pointer to the end of block */
- int delta_index;/* = seq->first->start_index */
- schar* prev_elem; /* pointer to previous element */
- };
+ //! returns the number of remaining (not read yet) elements
+ size_t remaining() const;
+
+ bool equalTo(const FileNodeIterator& it) const;
- const CvFileStorage* fs;
- const CvFileNode* container;
- SeqReader reader;
- size_t remaining;
+protected:
+ const FileStorage* fs;
+ size_t blockIdx;
+ size_t ofs;
+ size_t blockSize;
+ size_t nodeNElems;
+ size_t idx;
};
//! @} core_xml
cv::Mat _em_out, _em_in;
cv::Mat _2d_out, _2d_in;
cv::Mat _nd_out, _nd_in;
- cv::Mat _rd_out(64, 64, CV_64FC1), _rd_in;
+ cv::Mat _rd_out(8, 16, CV_64FC1), _rd_in;
- bool no_type_id = true;
-
{ /* init */
/* a normal mat */
fs["normal_nd_mat"] >> _nd_in;
fs["random_mat"] >> _rd_in;
- if ( !fs["empty_2d_mat"]["type_id"].empty() ||
- !fs["normal_2d_mat"]["type_id"].empty() ||
- !fs["normal_nd_mat"]["type_id"].empty() ||
- !fs[ "random_mat"]["type_id"].empty() )
- no_type_id = false;
-
/* raw data */
- std::vector<data_t>(1000).swap(rawdata);
- fs["rawdata"].readRaw(data_t::signature(), &rawdata[0], 1000*sizeof(rawdata[0]));
+ std::vector<data_t>(rawdata_N).swap(rawdata);
+ fs["rawdata"].readRaw(data_t::signature(), (uchar*)&rawdata[0], rawdata.size() * sizeof(data_t));
fs.release();
}