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
e31eb461
Unverified
Commit
e31eb461
authored
Nov 12, 2018
by
Alexander Alekhin
Committed by
GitHub
Nov 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13123 from dkurt:fs_keys
parents
326be0d7
a7f30391
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
persistence.hpp
modules/core/include/opencv2/core/persistence.hpp
+5
-0
persistence.cpp
modules/core/src/persistence.cpp
+13
-0
test_io.cpp
modules/core/test/test_io.cpp
+6
-0
No files found.
modules/core/include/opencv2/core/persistence.hpp
View file @
e31eb461
...
...
@@ -526,6 +526,11 @@ public:
*/
CV_WRAP_AS
(
at
)
FileNode
operator
[](
int
i
)
const
;
/** @brief Returns keys of a mapping node.
@returns Keys of a mapping node.
*/
CV_WRAP
std
::
vector
<
String
>
keys
()
const
;
/** @brief Returns type of the node.
@returns Type of the node. See FileNode::Type
*/
...
...
modules/core/src/persistence.cpp
View file @
e31eb461
...
...
@@ -2083,6 +2083,19 @@ FileNode FileNode::operator[](int i) const
return
*
it
;
}
std
::
vector
<
String
>
FileNode
::
keys
()
const
{
CV_Assert
(
isMap
());
std
::
vector
<
String
>
res
;
res
.
reserve
(
size
());
for
(
FileNodeIterator
it
=
begin
();
it
!=
end
();
++
it
)
{
res
.
push_back
((
*
it
).
name
());
}
return
res
;
}
int
FileNode
::
type
()
const
{
const
uchar
*
p
=
ptr
();
...
...
modules/core/test/test_io.cpp
View file @
e31eb461
...
...
@@ -1565,6 +1565,12 @@ TEST(Core_InputOutput, FileStorage_json_bool)
ASSERT_EQ
((
int
)
fs
[
"map_value"
][
"bool_true"
],
1
);
ASSERT_EQ
((
std
::
string
)
fs
[
"map_value"
][
"str_false"
],
"false"
);
ASSERT_EQ
((
int
)
fs
[
"bool_false"
],
0
);
std
::
vector
<
String
>
keys
=
fs
[
"map_value"
].
keys
();
ASSERT_EQ
((
int
)
keys
.
size
(),
3
);
ASSERT_EQ
(
keys
[
0
],
"int_value"
);
ASSERT_EQ
(
keys
[
1
],
"bool_true"
);
ASSERT_EQ
(
keys
[
2
],
"str_false"
);
fs
.
release
();
}
...
...
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