WriteStructContext treats state of fs
This commit is contained in:
parent
b96762a48f
commit
a43ef9a6cd
@ -697,9 +697,8 @@ void write(FileStorage& fs, const String& name, const Range& r )
|
|||||||
template<typename _Tp> static inline
|
template<typename _Tp> static inline
|
||||||
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
|
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
|
||||||
{
|
{
|
||||||
fs << (DataType<_Tp>::fmt != 0 ? "[:" : "[");
|
internal::WriteStructContext ws(fs, name, FileNode::SEQ+(DataType<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||||
write(fs, vec);
|
write(fs, vec);
|
||||||
fs << "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
@ -5486,11 +5486,28 @@ internal::WriteStructContext::WriteStructContext(FileStorage& _fs,
|
|||||||
{
|
{
|
||||||
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
|
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
|
||||||
!typeName.empty() ? typeName.c_str() : 0);
|
!typeName.empty() ? typeName.c_str() : 0);
|
||||||
|
if ((flags & FileNode::TYPE_MASK) == FileNode::SEQ)
|
||||||
|
{
|
||||||
|
fs->elname = String();
|
||||||
|
fs->state = FileStorage::VALUE_EXPECTED;
|
||||||
|
fs->structs.push_back('[');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs->elname = String();
|
||||||
|
fs->state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP;
|
||||||
|
fs->structs.push_back('{');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal::WriteStructContext::~WriteStructContext()
|
internal::WriteStructContext::~WriteStructContext()
|
||||||
{
|
{
|
||||||
cvEndWriteStruct(**fs);
|
cvEndWriteStruct(**fs);
|
||||||
|
fs->structs.pop_back();
|
||||||
|
fs->state = fs->structs.empty() || fs->structs.back() == '{' ?
|
||||||
|
FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP :
|
||||||
|
FileStorage::VALUE_EXPECTED;
|
||||||
|
fs->elname = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user