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>
|
||||
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();
|
||||
|
@@ -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);
|
||||
|
@@ -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 {};
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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";
|
||||
}
|
||||
}
|
||||
|
@@ -22,26 +22,18 @@ 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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user