Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
fadca5a8
"git@developer.sourcefind.cn:cnjsdfcy/simbricks.git" did not exist on "eb611e2c64c0124a0c4f183cb508103e68facbb0"
Commit
fadca5a8
authored
Sep 06, 2011
by
Jesse Beder
Browse files
Added overload for operator [] for char * (non-const version)
parent
7e129c9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
include/yaml-cpp/node.h
include/yaml-cpp/node.h
+2
-0
include/yaml-cpp/nodeimpl.h
include/yaml-cpp/nodeimpl.h
+8
-0
test/parsertests.cpp
test/parsertests.cpp
+17
-0
No files found.
include/yaml-cpp/node.h
View file @
fadca5a8
...
...
@@ -77,7 +77,9 @@ namespace YAML
// specific to maps
const
Node
*
FindValue
(
const
char
*
key
)
const
;
const
Node
*
FindValue
(
char
*
key
)
const
;
const
Node
&
operator
[]
(
const
char
*
key
)
const
;
const
Node
&
operator
[]
(
char
*
key
)
const
;
// for tags
const
std
::
string
&
Tag
()
const
{
return
m_tag
;
}
...
...
include/yaml-cpp/nodeimpl.h
View file @
fadca5a8
...
...
@@ -68,10 +68,18 @@ namespace YAML
inline
const
Node
*
Node
::
FindValue
(
const
char
*
key
)
const
{
return
FindValue
(
std
::
string
(
key
));
}
inline
const
Node
*
Node
::
FindValue
(
char
*
key
)
const
{
return
FindValue
(
std
::
string
(
key
));
}
inline
const
Node
&
Node
::
operator
[]
(
const
char
*
key
)
const
{
return
GetValue
(
std
::
string
(
key
));
}
inline
const
Node
&
Node
::
operator
[]
(
char
*
key
)
const
{
return
GetValue
(
std
::
string
(
key
));
}
}
#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
test/parsertests.cpp
View file @
fadca5a8
...
...
@@ -864,6 +864,22 @@ namespace Test
}
return
true
;
}
bool
NonConstKey
()
{
std
::
string
input
=
"{a: 1}"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
std
::
vector
<
char
>
key
(
2
);
key
[
0
]
=
'a'
;
key
[
1
]
=
'\0'
;
if
(
doc
[
&
key
[
0
]].
to
<
int
>
()
!=
1
)
return
false
;
return
true
;
}
}
namespace
{
...
...
@@ -1142,6 +1158,7 @@ namespace Test
RunParserTest
(
&
Parser
::
ExplicitNonSpecificSequenceTag
,
"explicit, non-specific sequence tag"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
Infinity
,
"infinity"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
NaN
,
"NaN"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
NonConstKey
,
"non const key"
,
passed
,
total
);
RunEncodingTest
(
&
EncodeToUtf8
,
false
,
"UTF-8, no BOM"
,
passed
,
total
);
RunEncodingTest
(
&
EncodeToUtf8
,
true
,
"UTF-8 with BOM"
,
passed
,
total
);
...
...
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