提交 74882fe1 编写于 作者: V Vadim Pisarevsky

replaced "string FileStorage::release()" with 2 methods to preserve backward compatibility.

上级 48c3cfdf
...@@ -3976,7 +3976,9 @@ public: ...@@ -3976,7 +3976,9 @@ public:
//! returns true if the object is associated with currently opened file. //! returns true if the object is associated with currently opened file.
CV_WRAP virtual bool isOpened() const; CV_WRAP virtual bool isOpened() const;
//! closes the file and releases all the memory buffers //! 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 //! returns the first element of the top-level mapping
CV_WRAP FileNode getFirstTopLevelNode() const; CV_WRAP FileNode getFirstTopLevelNode() const;
......
...@@ -5154,19 +5154,25 @@ bool FileStorage::isOpened() const ...@@ -5154,19 +5154,25 @@ bool FileStorage::isOpened() const
return !fs.empty() && fs.obj->is_opened; 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(); fs.release();
structs.clear(); structs.clear();
state = UNDEFINED; 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 FileNode FileStorage::root(int streamidx) const
{ {
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode(); return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
......
...@@ -180,7 +180,8 @@ protected: ...@@ -180,7 +180,8 @@ protected:
fs.writeObj("test_graph",graph); fs.writeObj("test_graph",graph);
CvGraph* graph2 = (CvGraph*)cvClone(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))) if(!fs.open(mem ? content : filename, FileStorage::READ + (mem ? FileStorage::MEMORY : 0)))
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册