Boring changes - core.
This and several following commits contain the "boring" changes required to support the new Ptr. These are changes like: * new T -> makePtr<T> or .reset(new T) or Ptr<T>(new T) (depending on the situation) * p.empty() -> !p * delete_obj -> DefaultDeleter::operator() and similar changes that are numerous, but primitive.
This commit is contained in:
@@ -5147,8 +5147,8 @@ FileStorage::~FileStorage()
|
||||
bool FileStorage::open(const String& filename, int flags, const String& encoding)
|
||||
{
|
||||
release();
|
||||
fs = Ptr<CvFileStorage>(cvOpenFileStorage( filename.c_str(), 0, flags,
|
||||
!encoding.empty() ? encoding.c_str() : 0));
|
||||
fs.reset(cvOpenFileStorage( filename.c_str(), 0, flags,
|
||||
!encoding.empty() ? encoding.c_str() : 0));
|
||||
bool ok = isOpened();
|
||||
state = ok ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED;
|
||||
return ok;
|
||||
@@ -5156,7 +5156,7 @@ bool FileStorage::open(const String& filename, int flags, const String& encoding
|
||||
|
||||
bool FileStorage::isOpened() const
|
||||
{
|
||||
return !fs.empty() && fs.obj->is_opened;
|
||||
return fs && fs->is_opened;
|
||||
}
|
||||
|
||||
void FileStorage::release()
|
||||
@@ -5169,8 +5169,8 @@ void FileStorage::release()
|
||||
String FileStorage::releaseAndGetString()
|
||||
{
|
||||
String buf;
|
||||
if( fs.obj && fs.obj->outbuf )
|
||||
icvClose(fs.obj, &buf);
|
||||
if( fs && fs->outbuf )
|
||||
icvClose(fs, &buf);
|
||||
|
||||
release();
|
||||
return buf;
|
||||
@@ -5479,7 +5479,7 @@ void write( FileStorage& fs, const String& name, const Mat& value )
|
||||
// TODO: the 4 functions below need to be implemented more efficiently
|
||||
void write( FileStorage& fs, const String& name, const SparseMat& value )
|
||||
{
|
||||
Ptr<CvSparseMat> mat = cvCreateSparseMat(value);
|
||||
Ptr<CvSparseMat> mat(cvCreateSparseMat(value));
|
||||
cvWrite( *fs, name.size() ? name.c_str() : 0, mat );
|
||||
}
|
||||
|
||||
@@ -5529,8 +5529,8 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
|
||||
default_mat.copyTo(mat);
|
||||
return;
|
||||
}
|
||||
Ptr<CvSparseMat> m = (CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node);
|
||||
CV_Assert(CV_IS_SPARSE_MAT(m.obj));
|
||||
Ptr<CvSparseMat> m((CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node));
|
||||
CV_Assert(CV_IS_SPARSE_MAT(m));
|
||||
m->copyToSparseMat(mat);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user