Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
41703451
Commit
41703451
authored
Nov 05, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15851 from alalek:fixup_15842
parents
a165f555
dcf72e49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
persistence.cpp
modules/core/src/persistence.cpp
+9
-8
persistence_yml.cpp
modules/core/src/persistence_yml.cpp
+2
-1
test_io.cpp
modules/core/test/test_io.cpp
+12
-2
No files found.
modules/core/src/persistence.cpp
View file @
41703451
...
...
@@ -1900,18 +1900,19 @@ int FileStorage::getFormat() const
FileNode
FileStorage
::
operator
[](
const
char
*
key
)
const
{
if
(
p
->
roots
.
empty
()
)
return
FileNode
();
return
p
->
roots
[
0
][
key
];
return
this
->
operator
[](
std
::
string
(
key
));
}
FileNode
FileStorage
::
operator
[](
const
std
::
string
&
key
)
const
{
if
(
p
->
roots
.
empty
()
)
return
FileNode
();
return
p
->
roots
[
0
][
key
];
FileNode
res
;
for
(
size_t
i
=
0
;
i
<
p
->
roots
.
size
();
i
++
)
{
res
=
p
->
roots
[
i
][
key
];
if
(
!
res
.
empty
())
break
;
}
return
res
;
}
String
FileStorage
::
releaseAndGetString
()
...
...
modules/core/src/persistence_yml.cpp
View file @
41703451
...
...
@@ -770,7 +770,7 @@ public:
bool
first
=
true
;
bool
ok
=
true
;
FileNode
root_collection
(
fs
->
getFS
(),
0
,
0
);
FileNode
root_node
=
fs
->
addNode
(
root_collection
,
std
::
string
(),
FileNode
::
NONE
);
for
(;;)
{
// 0. skip leading comments and directives and ...
...
...
@@ -821,6 +821,7 @@ public:
if
(
memcmp
(
ptr
,
"..."
,
3
)
!=
0
)
{
// 2. parse the collection
FileNode
root_node
=
fs
->
addNode
(
root_collection
,
std
::
string
(),
FileNode
::
NONE
);
ptr
=
parseValue
(
ptr
,
root_node
,
0
,
false
);
if
(
!
root_node
.
isMap
()
&&
!
root_node
.
isSeq
()
)
...
...
modules/core/test/test_io.cpp
View file @
41703451
...
...
@@ -1654,9 +1654,19 @@ TEST(Core_InputOutput, FileStorage_YAML_parse_multiple_documents)
fs
.
release
();
fs
.
open
(
filename
,
FileStorage
::
READ
);
ASSERT_EQ
(
42
,
(
int
)
fs
[
"a"
]);
ASSERT_EQ
(
1988
,
(
int
)
fs
[
"b"
]);
EXPECT_EQ
(
42
,
(
int
)
fs
[
"a"
]);
EXPECT_EQ
(
1988
,
(
int
)
fs
[
"b"
]);
EXPECT_EQ
(
42
,
(
int
)
fs
.
root
(
0
)[
"a"
]);
EXPECT_TRUE
(
fs
.
root
(
0
)[
"b"
].
empty
());
EXPECT_TRUE
(
fs
.
root
(
1
)[
"a"
].
empty
());
EXPECT_EQ
(
1988
,
(
int
)
fs
.
root
(
1
)[
"b"
]);
fs
.
release
();
ASSERT_EQ
(
0
,
std
::
remove
(
filename
.
c_str
()));
}
}}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment