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
b5b03bb9
Commit
b5b03bb9
authored
Oct 12, 2016
by
Jesse Beder
Browse files
Run clang-format.
parent
086fec5c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
43 deletions
+35
-43
include/yaml-cpp/exceptions.h
include/yaml-cpp/exceptions.h
+2
-2
include/yaml-cpp/node/convert.h
include/yaml-cpp/node/convert.h
+5
-6
include/yaml-cpp/node/detail/node_iterator.h
include/yaml-cpp/node/detail/node_iterator.h
+1
-1
include/yaml-cpp/node/emit.h
include/yaml-cpp/node/emit.h
+1
-1
src/emit.cpp
src/emit.cpp
+1
-1
src/nodebuilder.cpp
src/nodebuilder.cpp
+2
-3
src/null.cpp
src/null.cpp
+2
-1
src/ptr_vector.h
src/ptr_vector.h
+5
-13
src/scanner.cpp
src/scanner.cpp
+2
-2
test/node/node_test.cpp
test/node/node_test.cpp
+14
-13
No files found.
include/yaml-cpp/exceptions.h
View file @
b5b03bb9
...
...
@@ -89,7 +89,7 @@ const char* const BAD_FILE = "bad file";
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
,
typename
disable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
const
T
&
,
typename
disable_if
<
is_numeric
<
T
>>::
type
*
=
0
)
{
return
KEY_NOT_FOUND
;
}
...
...
@@ -101,7 +101,7 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
template
<
typename
T
>
inline
const
std
::
string
KEY_NOT_FOUND_WITH_KEY
(
const
T
&
key
,
typename
enable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
const
T
&
key
,
typename
enable_if
<
is_numeric
<
T
>>::
type
*
=
0
)
{
std
::
stringstream
stream
;
stream
<<
KEY_NOT_FOUND
<<
": "
<<
key
;
return
stream
.
str
();
...
...
include/yaml-cpp/node/convert.h
View file @
b5b03bb9
...
...
@@ -163,7 +163,7 @@ struct convert<bool> {
// std::map
template
<
typename
K
,
typename
V
>
struct
convert
<
std
::
map
<
K
,
V
>
>
{
struct
convert
<
std
::
map
<
K
,
V
>>
{
static
Node
encode
(
const
std
::
map
<
K
,
V
>&
rhs
)
{
Node
node
(
NodeType
::
Map
);
for
(
typename
std
::
map
<
K
,
V
>::
const_iterator
it
=
rhs
.
begin
();
...
...
@@ -190,7 +190,7 @@ struct convert<std::map<K, V> > {
// std::vector
template
<
typename
T
>
struct
convert
<
std
::
vector
<
T
>
>
{
struct
convert
<
std
::
vector
<
T
>>
{
static
Node
encode
(
const
std
::
vector
<
T
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
for
(
typename
std
::
vector
<
T
>::
const_iterator
it
=
rhs
.
begin
();
...
...
@@ -217,7 +217,7 @@ struct convert<std::vector<T> > {
// std::list
template
<
typename
T
>
struct
convert
<
std
::
list
<
T
>
>
{
struct
convert
<
std
::
list
<
T
>>
{
static
Node
encode
(
const
std
::
list
<
T
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
for
(
typename
std
::
list
<
T
>::
const_iterator
it
=
rhs
.
begin
();
...
...
@@ -269,8 +269,7 @@ struct convert<std::array<T, N>> {
return
true
;
}
private:
private:
static
bool
isNodeValid
(
const
Node
&
node
)
{
return
node
.
IsSequence
()
&&
node
.
size
()
==
N
;
}
...
...
@@ -278,7 +277,7 @@ private:
// std::pair
template
<
typename
T
,
typename
U
>
struct
convert
<
std
::
pair
<
T
,
U
>
>
{
struct
convert
<
std
::
pair
<
T
,
U
>>
{
static
Node
encode
(
const
std
::
pair
<
T
,
U
>&
rhs
)
{
Node
node
(
NodeType
::
Sequence
);
node
.
push_back
(
rhs
.
first
);
...
...
include/yaml-cpp/node/detail/node_iterator.h
View file @
b5b03bb9
...
...
@@ -55,7 +55,7 @@ template <typename V>
class
node_iterator_base
:
public
std
::
iterator
<
std
::
forward_iterator_tag
,
node_iterator_value
<
V
>
,
std
::
ptrdiff_t
,
node_iterator_value
<
V
>*
,
node_iterator_value
<
V
>
>
{
node_iterator_value
<
V
>>
{
private:
struct
enabler
{};
...
...
include/yaml-cpp/node/emit.h
View file @
b5b03bb9
...
...
@@ -27,6 +27,6 @@ YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node);
/** Converts the node to a YAML string. */
YAML_CPP_API
std
::
string
Dump
(
const
Node
&
node
);
}
// namespace YAML
}
// namespace YAML
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/emit.cpp
View file @
b5b03bb9
...
...
@@ -22,4 +22,4 @@ std::string Dump(const Node& node) {
emitter
<<
node
;
return
emitter
.
c_str
();
}
}
// namespace YAML
}
// namespace YAML
src/nodebuilder.cpp
View file @
b5b03bb9
...
...
@@ -48,9 +48,8 @@ void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag,
Pop
();
}
void
NodeBuilder
::
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
EmitterStyle
::
value
style
)
{
void
NodeBuilder
::
OnSequenceStart
(
const
Mark
&
mark
,
const
std
::
string
&
tag
,
anchor_t
anchor
,
EmitterStyle
::
value
style
)
{
detail
::
node
&
node
=
Push
(
mark
,
anchor
);
node
.
set_tag
(
tag
);
node
.
set_type
(
NodeType
::
Sequence
);
...
...
src/null.cpp
View file @
b5b03bb9
...
...
@@ -4,6 +4,7 @@ namespace YAML {
_Null
Null
;
bool
IsNullString
(
const
std
::
string
&
str
)
{
return
str
.
empty
()
||
str
==
"~"
||
str
==
"null"
||
str
==
"Null"
||
str
==
"NULL"
;
return
str
.
empty
()
||
str
==
"~"
||
str
==
"null"
||
str
==
"Null"
||
str
==
"NULL"
;
}
}
src/ptr_vector.h
View file @
b5b03bb9
...
...
@@ -22,29 +22,21 @@ class ptr_vector : private YAML::noncopyable {
public:
ptr_vector
()
{}
void
clear
()
{
m_data
.
clear
();
}
void
clear
()
{
m_data
.
clear
();
}
std
::
size_t
size
()
const
{
return
m_data
.
size
();
}
bool
empty
()
const
{
return
m_data
.
empty
();
}
void
push_back
(
std
::
unique_ptr
<
T
>&&
t
)
{
m_data
.
push_back
(
std
::
move
(
t
));
}
void
push_back
(
std
::
unique_ptr
<
T
>&&
t
)
{
m_data
.
push_back
(
std
::
move
(
t
));
}
T
&
operator
[](
std
::
size_t
i
)
{
return
*
m_data
[
i
];
}
const
T
&
operator
[](
std
::
size_t
i
)
const
{
return
*
m_data
[
i
];
}
T
&
back
()
{
return
*
(
m_data
.
back
().
get
());
}
T
&
back
()
{
return
*
(
m_data
.
back
().
get
());
}
const
T
&
back
()
const
{
return
*
(
m_data
.
back
().
get
());
}
const
T
&
back
()
const
{
return
*
(
m_data
.
back
().
get
());
}
private:
std
::
vector
<
std
::
unique_ptr
<
T
>>
m_data
;
std
::
vector
<
std
::
unique_ptr
<
T
>>
m_data
;
};
}
...
...
src/scanner.cpp
View file @
b5b03bb9
...
...
@@ -65,9 +65,9 @@ void Scanner::EnsureTokensInQueue() {
}
// no token? maybe we've actually finished
if
(
m_endedStream
)
{
if
(
m_endedStream
)
{
return
;
}
}
// no? then scan...
ScanNextToken
();
...
...
test/node/node_test.cpp
View file @
b5b03bb9
...
...
@@ -14,10 +14,10 @@ using ::testing::Eq;
#define EXPECT_THROW_REPRESENTATION_EXCEPTION(statement, message) \
ASSERT_THROW(statement, RepresentationException); \
try { \
statement; \
try {
\
statement;
\
} catch (const RepresentationException& e) { \
EXPECT_EQ(e.msg, message); \
EXPECT_EQ(e.msg, message);
\
}
namespace
YAML
{
...
...
@@ -132,7 +132,7 @@ TEST(NodeTest, ConstIteratorOnConstUndefinedNode) {
std
::
size_t
count
=
0
;
for
(
const_iterator
it
=
undefinedCn
.
begin
();
it
!=
undefinedCn
.
end
();
++
it
)
{
count
++
;
}
}
EXPECT_EQ
(
0
,
count
);
}
...
...
@@ -144,7 +144,8 @@ TEST(NodeTest, IteratorOnConstUndefinedNode) {
Node
&
nonConstUndefinedNode
=
const_cast
<
Node
&>
(
undefinedCn
);
std
::
size_t
count
=
0
;
for
(
iterator
it
=
nonConstUndefinedNode
.
begin
();
it
!=
nonConstUndefinedNode
.
end
();
++
it
)
{
for
(
iterator
it
=
nonConstUndefinedNode
.
begin
();
it
!=
nonConstUndefinedNode
.
end
();
++
it
)
{
count
++
;
}
EXPECT_EQ
(
0
,
count
);
...
...
@@ -163,7 +164,7 @@ TEST(NodeTest, SimpleSubkeys) {
}
TEST
(
NodeTest
,
StdArray
)
{
std
::
array
<
int
,
5
>
evens
{{
2
,
4
,
6
,
8
,
10
}};
std
::
array
<
int
,
5
>
evens
{{
2
,
4
,
6
,
8
,
10
}};
Node
node
;
node
[
"evens"
]
=
evens
;
std
::
array
<
int
,
5
>
actualEvens
=
node
[
"evens"
].
as
<
std
::
array
<
int
,
5
>>
();
...
...
@@ -171,11 +172,11 @@ TEST(NodeTest, StdArray) {
}
TEST
(
NodeTest
,
StdArrayWrongSize
)
{
std
::
array
<
int
,
3
>
evens
{{
2
,
4
,
6
}};
std
::
array
<
int
,
3
>
evens
{{
2
,
4
,
6
}};
Node
node
;
node
[
"evens"
]
=
evens
;
EXPECT_THROW_REPRESENTATION_EXCEPTION
(
(
node
[
"evens"
].
as
<
std
::
array
<
int
,
5
>>
()),
ErrorMsg
::
BAD_CONVERSION
);
EXPECT_THROW_REPRESENTATION_EXCEPTION
(
(
node
[
"evens"
].
as
<
std
::
array
<
int
,
5
>>
()),
ErrorMsg
::
BAD_CONVERSION
);
}
TEST
(
NodeTest
,
StdVector
)
{
...
...
@@ -189,7 +190,7 @@ TEST(NodeTest, StdVector) {
Node
node
;
node
[
"primes"
]
=
primes
;
EXPECT_EQ
(
primes
,
node
[
"primes"
].
as
<
std
::
vector
<
int
>
>
());
EXPECT_EQ
(
primes
,
node
[
"primes"
].
as
<
std
::
vector
<
int
>>
());
}
TEST
(
NodeTest
,
StdList
)
{
...
...
@@ -203,7 +204,7 @@ TEST(NodeTest, StdList) {
Node
node
;
node
[
"primes"
]
=
primes
;
EXPECT_EQ
(
primes
,
node
[
"primes"
].
as
<
std
::
list
<
int
>
>
());
EXPECT_EQ
(
primes
,
node
[
"primes"
].
as
<
std
::
list
<
int
>>
());
}
TEST
(
NodeTest
,
StdMap
)
{
...
...
@@ -216,7 +217,7 @@ TEST(NodeTest, StdMap) {
Node
node
;
node
[
"squares"
]
=
squares
;
std
::
map
<
int
,
int
>
actualSquares
=
node
[
"squares"
].
as
<
std
::
map
<
int
,
int
>
>
();
std
::
map
<
int
,
int
>
actualSquares
=
node
[
"squares"
].
as
<
std
::
map
<
int
,
int
>>
();
EXPECT_EQ
(
squares
,
actualSquares
);
}
...
...
@@ -228,7 +229,7 @@ TEST(NodeTest, StdPair) {
Node
node
;
node
[
"pair"
]
=
p
;
std
::
pair
<
int
,
std
::
string
>
actualP
=
node
[
"pair"
].
as
<
std
::
pair
<
int
,
std
::
string
>
>
();
node
[
"pair"
].
as
<
std
::
pair
<
int
,
std
::
string
>>
();
EXPECT_EQ
(
p
,
actualP
);
}
...
...
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