@@ -1376,9 +1376,9 @@ class FileStorage::Impl : public FileStorage_API
1376
1376
return new_ptr;
1377
1377
}
1378
1378
1379
- unsigned getStringOfs ( const std::string& key )
1379
+ unsigned getStringOfs ( const std::string& key ) const
1380
1380
{
1381
- str_hash_t ::iterator it = str_hash.find (key);
1381
+ str_hash_t ::const_iterator it = str_hash.find (key);
1382
1382
return it != str_hash.end () ? it->second : 0 ;
1383
1383
}
1384
1384
@@ -1468,7 +1468,7 @@ class FileStorage::Impl : public FileStorage_API
1468
1468
writeInt (ptr, (int )rawSize);
1469
1469
}
1470
1470
1471
- void normalizeNodeOfs (size_t & blockIdx, size_t & ofs)
1471
+ void normalizeNodeOfs (size_t & blockIdx, size_t & ofs) const
1472
1472
{
1473
1473
while ( ofs >= fs_data_blksz[blockIdx] )
1474
1474
{
@@ -2048,18 +2048,24 @@ FileStorage& operator << (FileStorage& fs, const String& str)
2048
2048
2049
2049
2050
2050
FileNode::FileNode ()
2051
+ : fs(NULL )
2051
2052
{
2052
- fs = 0 ;
2053
2053
blockIdx = ofs = 0 ;
2054
2054
}
2055
2055
2056
- FileNode::FileNode (const FileStorage* _fs, size_t _blockIdx, size_t _ofs)
2056
+ FileNode::FileNode (FileStorage::Impl* _fs, size_t _blockIdx, size_t _ofs)
2057
+ : fs(_fs)
2057
2058
{
2058
- fs = _fs;
2059
2059
blockIdx = _blockIdx;
2060
2060
ofs = _ofs;
2061
2061
}
2062
2062
2063
+ FileNode::FileNode (const FileStorage* _fs, size_t _blockIdx, size_t _ofs)
2064
+ : FileNode(_fs->p.get(), _blockIdx, _ofs)
2065
+ {
2066
+ // nothing
2067
+ }
2068
+
2063
2069
FileNode::FileNode (const FileNode& node)
2064
2070
{
2065
2071
fs = node.fs ;
@@ -2082,7 +2088,7 @@ FileNode FileNode::operator[](const std::string& nodename) const
2082
2088
2083
2089
CV_Assert ( isMap () );
2084
2090
2085
- unsigned key = fs->p -> getStringOfs (nodename);
2091
+ unsigned key = fs->getStringOfs (nodename);
2086
2092
size_t i, sz = size ();
2087
2093
FileNodeIterator it = begin ();
2088
2094
@@ -2091,7 +2097,7 @@ FileNode FileNode::operator[](const std::string& nodename) const
2091
2097
FileNode n = *it;
2092
2098
const uchar* p = n.ptr ();
2093
2099
unsigned key2 = (unsigned )readInt (p + 1 );
2094
- CV_Assert ( key2 < fs->p -> str_hash_data .size () );
2100
+ CV_Assert ( key2 < fs->str_hash_data .size () );
2095
2101
if ( key == key2 )
2096
2102
return n;
2097
2103
}
@@ -2167,7 +2173,7 @@ std::string FileNode::name() const
2167
2173
if (!p)
2168
2174
return std::string ();
2169
2175
size_t nameofs = p[1 ] | (p[2 ]<<8 ) | (p[3 ]<<16 ) | (p[4 ]<<24 );
2170
- return fs->p -> getName (nameofs);
2176
+ return fs->getName (nameofs);
2171
2177
}
2172
2178
2173
2179
FileNode::operator int () const
@@ -2292,12 +2298,12 @@ size_t FileNode::rawSize() const
2292
2298
2293
2299
uchar* FileNode::ptr ()
2294
2300
{
2295
- return !fs ? 0 : (uchar*)fs->p -> getNodePtr (blockIdx, ofs);
2301
+ return !fs ? 0 : (uchar*)fs->getNodePtr (blockIdx, ofs);
2296
2302
}
2297
2303
2298
2304
const uchar* FileNode::ptr () const
2299
2305
{
2300
- return !fs ? 0 : fs->p -> getNodePtr (blockIdx, ofs);
2306
+ return !fs ? 0 : fs->getNodePtr (blockIdx, ofs);
2301
2307
}
2302
2308
2303
2309
void FileNode::setValue ( int type, const void * value, int len )
@@ -2328,7 +2334,7 @@ void FileNode::setValue( int type, const void* value, int len )
2328
2334
else
2329
2335
CV_Error (Error::StsNotImplemented, " Only scalar types can be dynamically assigned to a file node" );
2330
2336
2331
- p = fs->p -> reserveNodeSpace (*this , sz);
2337
+ p = fs->reserveNodeSpace (*this , sz);
2332
2338
*p++ = (uchar)(type | (tag & NAMED));
2333
2339
if ( tag & NAMED )
2334
2340
p += 4 ;
@@ -2402,8 +2408,8 @@ FileNodeIterator::FileNodeIterator( const FileNode& node, bool seekEnd )
2402
2408
idx = nodeNElems;
2403
2409
}
2404
2410
}
2405
- fs->p -> normalizeNodeOfs (blockIdx, ofs);
2406
- blockSize = fs->p -> fs_data_blksz [blockIdx];
2411
+ fs->normalizeNodeOfs (blockIdx, ofs);
2412
+ blockSize = fs->fs_data_blksz [blockIdx];
2407
2413
}
2408
2414
}
2409
2415
@@ -2430,7 +2436,7 @@ FileNodeIterator& FileNodeIterator::operator=(const FileNodeIterator& it)
2430
2436
2431
2437
FileNode FileNodeIterator::operator *() const
2432
2438
{
2433
- return FileNode (idx < nodeNElems ? fs : 0 , blockIdx, ofs);
2439
+ return FileNode (idx < nodeNElems ? fs : NULL , blockIdx, ofs);
2434
2440
}
2435
2441
2436
2442
FileNodeIterator& FileNodeIterator::operator ++ ()
@@ -2442,8 +2448,8 @@ FileNodeIterator& FileNodeIterator::operator ++ ()
2442
2448
ofs += n.rawSize ();
2443
2449
if ( ofs >= blockSize )
2444
2450
{
2445
- fs->p -> normalizeNodeOfs (blockIdx, ofs);
2446
- blockSize = fs->p -> fs_data_blksz [blockIdx];
2451
+ fs->normalizeNodeOfs (blockIdx, ofs);
2452
+ blockSize = fs->fs_data_blksz [blockIdx];
2447
2453
}
2448
2454
return *this ;
2449
2455
}
0 commit comments