mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Run clang-format.
This commit is contained in:
@@ -89,7 +89,7 @@ const char* const BAD_FILE = "bad file";
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(
|
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;
|
return KEY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(
|
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;
|
std::stringstream stream;
|
||||||
stream << KEY_NOT_FOUND << ": " << key;
|
stream << KEY_NOT_FOUND << ": " << key;
|
||||||
return stream.str();
|
return stream.str();
|
||||||
|
@@ -163,7 +163,7 @@ struct convert<bool> {
|
|||||||
|
|
||||||
// std::map
|
// std::map
|
||||||
template <typename K, typename V>
|
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) {
|
static Node encode(const std::map<K, V>& rhs) {
|
||||||
Node node(NodeType::Map);
|
Node node(NodeType::Map);
|
||||||
for (typename std::map<K, V>::const_iterator it = rhs.begin();
|
for (typename std::map<K, V>::const_iterator it = rhs.begin();
|
||||||
@@ -190,7 +190,7 @@ struct convert<std::map<K, V> > {
|
|||||||
|
|
||||||
// std::vector
|
// std::vector
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct convert<std::vector<T> > {
|
struct convert<std::vector<T>> {
|
||||||
static Node encode(const std::vector<T>& rhs) {
|
static Node encode(const std::vector<T>& rhs) {
|
||||||
Node node(NodeType::Sequence);
|
Node node(NodeType::Sequence);
|
||||||
for (typename std::vector<T>::const_iterator it = rhs.begin();
|
for (typename std::vector<T>::const_iterator it = rhs.begin();
|
||||||
@@ -217,7 +217,7 @@ struct convert<std::vector<T> > {
|
|||||||
|
|
||||||
// std::list
|
// std::list
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct convert<std::list<T> > {
|
struct convert<std::list<T>> {
|
||||||
static Node encode(const std::list<T>& rhs) {
|
static Node encode(const std::list<T>& rhs) {
|
||||||
Node node(NodeType::Sequence);
|
Node node(NodeType::Sequence);
|
||||||
for (typename std::list<T>::const_iterator it = rhs.begin();
|
for (typename std::list<T>::const_iterator it = rhs.begin();
|
||||||
@@ -269,8 +269,7 @@ struct convert<std::array<T, N>> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static bool isNodeValid(const Node& node) {
|
static bool isNodeValid(const Node& node) {
|
||||||
return node.IsSequence() && node.size() == N;
|
return node.IsSequence() && node.size() == N;
|
||||||
}
|
}
|
||||||
@@ -278,7 +277,7 @@ private:
|
|||||||
|
|
||||||
// std::pair
|
// std::pair
|
||||||
template <typename T, typename U>
|
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) {
|
static Node encode(const std::pair<T, U>& rhs) {
|
||||||
Node node(NodeType::Sequence);
|
Node node(NodeType::Sequence);
|
||||||
node.push_back(rhs.first);
|
node.push_back(rhs.first);
|
||||||
|
@@ -55,7 +55,7 @@ template <typename V>
|
|||||||
class node_iterator_base
|
class node_iterator_base
|
||||||
: public std::iterator<std::forward_iterator_tag, node_iterator_value<V>,
|
: public std::iterator<std::forward_iterator_tag, node_iterator_value<V>,
|
||||||
std::ptrdiff_t, node_iterator_value<V>*,
|
std::ptrdiff_t, node_iterator_value<V>*,
|
||||||
node_iterator_value<V> > {
|
node_iterator_value<V>> {
|
||||||
private:
|
private:
|
||||||
struct enabler {};
|
struct enabler {};
|
||||||
|
|
||||||
|
@@ -27,6 +27,6 @@ YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node);
|
|||||||
|
|
||||||
/** Converts the node to a YAML string. */
|
/** Converts the node to a YAML string. */
|
||||||
YAML_CPP_API std::string Dump(const Node& node);
|
YAML_CPP_API std::string Dump(const Node& node);
|
||||||
} // namespace YAML
|
} // namespace YAML
|
||||||
|
|
||||||
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||||
|
@@ -22,4 +22,4 @@ std::string Dump(const Node& node) {
|
|||||||
emitter << node;
|
emitter << node;
|
||||||
return emitter.c_str();
|
return emitter.c_str();
|
||||||
}
|
}
|
||||||
} // namespace YAML
|
} // namespace YAML
|
||||||
|
@@ -48,9 +48,8 @@ void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag,
|
|||||||
Pop();
|
Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeBuilder::OnSequenceStart(const Mark& mark,
|
void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag,
|
||||||
const std::string& tag, anchor_t anchor,
|
anchor_t anchor, EmitterStyle::value style) {
|
||||||
EmitterStyle::value style) {
|
|
||||||
detail::node& node = Push(mark, anchor);
|
detail::node& node = Push(mark, anchor);
|
||||||
node.set_tag(tag);
|
node.set_tag(tag);
|
||||||
node.set_type(NodeType::Sequence);
|
node.set_type(NodeType::Sequence);
|
||||||
|
@@ -4,6 +4,7 @@ namespace YAML {
|
|||||||
_Null Null;
|
_Null Null;
|
||||||
|
|
||||||
bool IsNullString(const std::string& str) {
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,29 +22,21 @@ class ptr_vector : private YAML::noncopyable {
|
|||||||
public:
|
public:
|
||||||
ptr_vector() {}
|
ptr_vector() {}
|
||||||
|
|
||||||
void clear() {
|
void clear() { m_data.clear(); }
|
||||||
m_data.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t size() const { return m_data.size(); }
|
std::size_t size() const { return m_data.size(); }
|
||||||
bool empty() const { return m_data.empty(); }
|
bool empty() const { return m_data.empty(); }
|
||||||
|
|
||||||
void push_back(std::unique_ptr<T>&& t) {
|
void push_back(std::unique_ptr<T>&& t) { m_data.push_back(std::move(t)); }
|
||||||
m_data.push_back(std::move(t));
|
|
||||||
}
|
|
||||||
T& operator[](std::size_t i) { return *m_data[i]; }
|
T& operator[](std::size_t i) { return *m_data[i]; }
|
||||||
const T& operator[](std::size_t i) const { return *m_data[i]; }
|
const T& operator[](std::size_t i) const { return *m_data[i]; }
|
||||||
|
|
||||||
T& back() {
|
T& back() { return *(m_data.back().get()); }
|
||||||
return *(m_data.back().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& back() const {
|
const T& back() const { return *(m_data.back().get()); }
|
||||||
return *(m_data.back().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<T>> m_data;
|
std::vector<std::unique_ptr<T>> m_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,9 +65,9 @@ void Scanner::EnsureTokensInQueue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no token? maybe we've actually finished
|
// no token? maybe we've actually finished
|
||||||
if (m_endedStream) {
|
if (m_endedStream) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no? then scan...
|
// no? then scan...
|
||||||
ScanNextToken();
|
ScanNextToken();
|
||||||
|
@@ -14,10 +14,10 @@ using ::testing::Eq;
|
|||||||
|
|
||||||
#define EXPECT_THROW_REPRESENTATION_EXCEPTION(statement, message) \
|
#define EXPECT_THROW_REPRESENTATION_EXCEPTION(statement, message) \
|
||||||
ASSERT_THROW(statement, RepresentationException); \
|
ASSERT_THROW(statement, RepresentationException); \
|
||||||
try { \
|
try { \
|
||||||
statement; \
|
statement; \
|
||||||
} catch (const RepresentationException& e) { \
|
} catch (const RepresentationException& e) { \
|
||||||
EXPECT_EQ(e.msg, message); \
|
EXPECT_EQ(e.msg, message); \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
@@ -132,7 +132,7 @@ TEST(NodeTest, ConstIteratorOnConstUndefinedNode) {
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
for (const_iterator it = undefinedCn.begin(); it != undefinedCn.end(); ++it) {
|
for (const_iterator it = undefinedCn.begin(); it != undefinedCn.end(); ++it) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, count);
|
EXPECT_EQ(0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,8 @@ TEST(NodeTest, IteratorOnConstUndefinedNode) {
|
|||||||
Node& nonConstUndefinedNode = const_cast<Node&>(undefinedCn);
|
Node& nonConstUndefinedNode = const_cast<Node&>(undefinedCn);
|
||||||
|
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
for (iterator it = nonConstUndefinedNode.begin(); it != nonConstUndefinedNode.end(); ++it) {
|
for (iterator it = nonConstUndefinedNode.begin();
|
||||||
|
it != nonConstUndefinedNode.end(); ++it) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, count);
|
EXPECT_EQ(0, count);
|
||||||
@@ -163,7 +164,7 @@ TEST(NodeTest, SimpleSubkeys) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, StdArray) {
|
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 node;
|
||||||
node["evens"] = evens;
|
node["evens"] = evens;
|
||||||
std::array<int, 5> actualEvens = node["evens"].as<std::array<int, 5>>();
|
std::array<int, 5> actualEvens = node["evens"].as<std::array<int, 5>>();
|
||||||
@@ -171,11 +172,11 @@ TEST(NodeTest, StdArray) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, StdArrayWrongSize) {
|
TEST(NodeTest, StdArrayWrongSize) {
|
||||||
std::array<int, 3> evens {{ 2, 4, 6 }};
|
std::array<int, 3> evens{{2, 4, 6}};
|
||||||
Node node;
|
Node node;
|
||||||
node["evens"] = evens;
|
node["evens"] = evens;
|
||||||
EXPECT_THROW_REPRESENTATION_EXCEPTION((node["evens"].as<std::array<int, 5>>()),
|
EXPECT_THROW_REPRESENTATION_EXCEPTION(
|
||||||
ErrorMsg::BAD_CONVERSION);
|
(node["evens"].as<std::array<int, 5>>()), ErrorMsg::BAD_CONVERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, StdVector) {
|
TEST(NodeTest, StdVector) {
|
||||||
@@ -189,7 +190,7 @@ TEST(NodeTest, StdVector) {
|
|||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
node["primes"] = primes;
|
node["primes"] = primes;
|
||||||
EXPECT_EQ(primes, node["primes"].as<std::vector<int> >());
|
EXPECT_EQ(primes, node["primes"].as<std::vector<int>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, StdList) {
|
TEST(NodeTest, StdList) {
|
||||||
@@ -203,7 +204,7 @@ TEST(NodeTest, StdList) {
|
|||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
node["primes"] = primes;
|
node["primes"] = primes;
|
||||||
EXPECT_EQ(primes, node["primes"].as<std::list<int> >());
|
EXPECT_EQ(primes, node["primes"].as<std::list<int>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, StdMap) {
|
TEST(NodeTest, StdMap) {
|
||||||
@@ -216,7 +217,7 @@ TEST(NodeTest, StdMap) {
|
|||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
node["squares"] = squares;
|
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);
|
EXPECT_EQ(squares, actualSquares);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ TEST(NodeTest, StdPair) {
|
|||||||
Node node;
|
Node node;
|
||||||
node["pair"] = p;
|
node["pair"] = p;
|
||||||
std::pair<int, std::string> actualP =
|
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);
|
EXPECT_EQ(p, actualP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user