Skip to content

Commit

Permalink
Run clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeder committed Oct 12, 2016
1 parent 086fec5 commit b5b03bb
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 43 deletions.
4 changes: 2 additions & 2 deletions include/yaml-cpp/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
Expand Down
11 changes: 5 additions & 6 deletions include/yaml-cpp/node/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -269,16 +269,15 @@ struct convert<std::array<T, N>> {
return true;
}

private:

private:
static bool isNodeValid(const Node& node) {
return node.IsSequence() && node.size() == N;
}
};

// 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);
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/detail/node_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};

Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ std::string Dump(const Node& node) {
emitter << node;
return emitter.c_str();
}
} // namespace YAML
} // namespace YAML
5 changes: 2 additions & 3 deletions src/nodebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
18 changes: 5 additions & 13 deletions src/ptr_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
27 changes: 14 additions & 13 deletions test/node/node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -163,19 +164,19 @@ 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>>();
EXPECT_EQ(evens, actualEvens);
}

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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit b5b03bb

Please sign in to comment.