//! returns true if the object is associated with currently opened file.
CV_WRAP virtual bool isOpened() const;
//! closes the file and releases all the memory buffers
- CV_WRAP virtual string release();
+ CV_WRAP virtual void release();
+ //! closes the file, releases all the memory buffers and returns the text string
+ CV_WRAP_AS(releaseAndGetString) virtual void release(CV_OUT string& buf);
//! returns the first element of the top-level mapping
CV_WRAP FileNode getFirstTopLevelNode() const;
return !fs.empty() && fs.obj->is_opened;
}
-string FileStorage::release()
+void FileStorage::release()
{
- string buf;
-
- if( fs.obj && fs.obj->outbuf )
- icvClose(fs.obj, &buf);
-
fs.release();
structs.clear();
state = UNDEFINED;
- return buf;
}
+void FileStorage::release(string& buf)
+{
+ if( fs.obj && fs.obj->outbuf )
+ icvClose(fs.obj, &buf);
+ else
+ buf.clear();
+
+ fs.release();
+ structs.clear();
+ state = UNDEFINED;
+}
+
FileNode FileStorage::root(int streamidx) const
{
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
fs.writeObj("test_graph",graph);
CvGraph* graph2 = (CvGraph*)cvClone(graph);
- string content = fs.release();
+ string content;
+ fs.release(content);
if(!fs.open(mem ? content : filename, FileStorage::READ + (mem ? FileStorage::MEMORY : 0)))
{