Fix comments on previous commit

This commit is contained in:
Ted Lyngmo 2019-03-12 17:45:33 +01:00
parent 5ab904311f
commit d1a722aba9
15 changed files with 42 additions and 59 deletions

View File

@ -22,6 +22,7 @@ namespace YAML {
template <class T> template <class T>
class AnchorDict { class AnchorDict {
public: public:
AnchorDict() : m_data{} {}
void Register(anchor_t anchor, T value) { void Register(anchor_t anchor, T value) {
if (anchor > m_data.size()) { if (anchor > m_data.size()) {
m_data.resize(anchor); m_data.resize(anchor);
@ -32,7 +33,7 @@ class AnchorDict {
T Get(anchor_t anchor) const { return m_data[anchor - 1]; } T Get(anchor_t anchor) const { return m_data[anchor - 1]; }
private: private:
std::vector<T> m_data{}; std::vector<T> m_data;
}; };
} }

View File

@ -16,7 +16,6 @@
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/emitterdef.h" #include "yaml-cpp/emitterdef.h"
#include "yaml-cpp/emittermanip.h" #include "yaml-cpp/emittermanip.h"
#include "yaml-cpp/noncopyable.h"
#include "yaml-cpp/null.h" #include "yaml-cpp/null.h"
#include "yaml-cpp/ostream_wrapper.h" #include "yaml-cpp/ostream_wrapper.h"
@ -28,10 +27,12 @@ struct _Null;
namespace YAML { namespace YAML {
class EmitterState; class EmitterState;
class YAML_CPP_API Emitter : private noncopyable { class YAML_CPP_API Emitter {
public: public:
Emitter(); Emitter();
explicit Emitter(std::ostream& stream); explicit Emitter(std::ostream& stream);
Emitter(const Emitter&) = delete;
Emitter& operator=(const Emitter&) = delete;
~Emitter(); ~Emitter();
// output // output

View File

@ -22,12 +22,13 @@ namespace YAML {
namespace detail { namespace detail {
class YAML_CPP_API memory { class YAML_CPP_API memory {
public: public:
memory() : m_nodes{} {}
node& create_node(); node& create_node();
void merge(const memory& rhs); void merge(const memory& rhs);
private: private:
typedef std::set<shared_node> Nodes; typedef std::set<shared_node> Nodes;
Nodes m_nodes{}; Nodes m_nodes;
}; };
class YAML_CPP_API memory_holder { class YAML_CPP_API memory_holder {

View File

@ -15,7 +15,7 @@
#include <string> #include <string>
namespace YAML { namespace YAML {
inline Node::Node() : m_isValid(true), m_pMemory(nullptr), m_pNode(NULL) {} inline Node::Node() : m_isValid(true), m_pMemory(nullptr), m_pNode(nullptr) {}
inline Node::Node(NodeType::value type) inline Node::Node(NodeType::value type)
: m_isValid(true), : m_isValid(true),
@ -42,7 +42,7 @@ inline Node::Node(const Node& rhs)
m_pMemory(rhs.m_pMemory), m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {} m_pNode(rhs.m_pNode) {}
inline Node::Node(Zombie) : m_isValid(false), m_pMemory{}, m_pNode(NULL) {} inline Node::Node(Zombie) : m_isValid(false), m_pMemory{}, m_pNode(nullptr) {}
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory) inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
: m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {}

View File

@ -1,23 +0,0 @@
#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include "yaml-cpp/dll.h"
namespace YAML {
// this is basically boost::noncopyable
class YAML_CPP_API noncopyable {
protected:
noncopyable() = default;
~noncopyable() = default;
noncopyable(const noncopyable&) = delete;
noncopyable& operator=(const noncopyable&) = delete;
};
}
#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -11,7 +11,6 @@
#include <memory> #include <memory>
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/noncopyable.h"
namespace YAML { namespace YAML {
class EventHandler; class EventHandler;
@ -24,11 +23,17 @@ struct Token;
* A parser turns a stream of bytes into one stream of "events" per YAML * A parser turns a stream of bytes into one stream of "events" per YAML
* document in the input stream. * document in the input stream.
*/ */
class YAML_CPP_API Parser : private noncopyable { class YAML_CPP_API Parser {
public: public:
/** Constructs an empty parser (with no input. */ /** Constructs an empty parser (with no input. */
Parser(); Parser();
/** non copyable but movable */
Parser(const Parser&) = delete;
Parser(Parser&&) = default;
Parser& operator=(const Parser&) = delete;
Parser& operator=(Parser&&) = default;
/** /**
* Constructs a parser from the given input stream. The input stream must * Constructs a parser from the given input stream. The input stream must
* live as long as the parser. * live as long as the parser.

View File

@ -17,6 +17,7 @@ struct CollectionType {
class CollectionStack { class CollectionStack {
public: public:
CollectionStack() : collectionStack{} {}
CollectionType::value GetCurCollectionType() const { CollectionType::value GetCurCollectionType() const {
if (collectionStack.empty()) if (collectionStack.empty())
return CollectionType::NoCollection; return CollectionType::NoCollection;
@ -33,7 +34,7 @@ class CollectionStack {
} }
private: private:
std::stack<CollectionType::value> collectionStack{}; std::stack<CollectionType::value> collectionStack;
}; };
} }

View File

@ -1,12 +1,7 @@
#include "directives.h" #include "directives.h"
namespace YAML { namespace YAML {
Directives::Directives() : version{true, 1, 2}, tags{} { Directives::Directives() : version{true, 1, 2}, tags{} {}
/* Version:
** bool isDefault;
** int major, minor;
*/
}
const std::string Directives::TranslateTagHandle( const std::string Directives::TranslateTagHandle(
const std::string& handle) const { const std::string& handle) const {

View File

@ -12,15 +12,17 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "yaml-cpp/noncopyable.h"
namespace YAML { namespace YAML {
// TODO: This class is no longer needed // TODO: This class is no longer needed
template <typename T> template <typename T>
class ptr_vector : private YAML::noncopyable { class ptr_vector {
public: public:
ptr_vector() : m_data{} {} ptr_vector() : m_data{} {}
ptr_vector(const ptr_vector&) = delete;
ptr_vector(ptr_vector&&) = default;
ptr_vector& operator=(const ptr_vector&) = delete;
ptr_vector& operator=(ptr_vector&&) = default;
void clear() { m_data.clear(); } void clear() { m_data.clear(); }

View File

@ -10,12 +10,7 @@ RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch), m_z(0), m_params{} {}
RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {} RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {}
RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) { RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
/*
for (std::size_t i = 0; i < str.size(); i++)
m_params.push_back(RegEx(str[i]));
*/
}
// combination constructors // combination constructors
RegEx operator!(const RegEx& ex) { RegEx operator!(const RegEx& ex) {

View File

@ -31,7 +31,7 @@ enum REGEX_OP {
class YAML_CPP_API RegEx { class YAML_CPP_API RegEx {
public: public:
RegEx(); RegEx();
RegEx(char ch); explicit RegEx(char ch);
RegEx(char a, char z); RegEx(char a, char z);
RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
~RegEx() {} ~RegEx() {}
@ -53,7 +53,7 @@ class YAML_CPP_API RegEx {
int Match(const Source& source) const; int Match(const Source& source) const;
private: private:
RegEx(REGEX_OP op); explicit RegEx(REGEX_OP op);
template <typename Source> template <typename Source>
bool IsValidSource(const Source& source) const; bool IsValidSource(const Source& source) const;

View File

@ -9,7 +9,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "yaml-cpp/noncopyable.h" #include <utility>
namespace YAML { namespace YAML {
class SettingChangeBase; class SettingChangeBase;
@ -37,7 +37,7 @@ class SettingChangeBase {
}; };
template <typename T> template <typename T>
class SettingChange : public SettingChangeBase, private noncopyable { class SettingChange : public SettingChangeBase {
public: public:
SettingChange(Setting<T>* pSetting) : SettingChange(Setting<T>* pSetting) :
m_pCurSetting(pSetting), m_pCurSetting(pSetting),
@ -62,9 +62,12 @@ inline std::unique_ptr<SettingChangeBase> Setting<T>::set(const T& value) {
return pChange; return pChange;
} }
class SettingChanges : private noncopyable { class SettingChanges {
public: public:
SettingChanges() : m_settingChanges{} {} SettingChanges() : m_settingChanges{} {}
SettingChanges(const SettingChanges&) = delete;
SettingChanges(SettingChanges&& rhs) : m_settingChanges(std::move(rhs.m_settingChanges)) {}
SettingChanges& operator=(const SettingChanges&) = delete;
~SettingChanges() { clear(); } ~SettingChanges() { clear(); }
void clear() { void clear() {

View File

@ -12,7 +12,6 @@
#include <string> #include <string>
#include "yaml-cpp/anchor.h" #include "yaml-cpp/anchor.h"
#include "yaml-cpp/noncopyable.h"
namespace YAML { namespace YAML {
class CollectionStack; class CollectionStack;
@ -23,9 +22,13 @@ struct Directives;
struct Mark; struct Mark;
struct Token; struct Token;
class SingleDocParser : private noncopyable { class SingleDocParser {
public: public:
SingleDocParser(Scanner& scanner, const Directives& directives); SingleDocParser(Scanner& scanner, const Directives& directives);
SingleDocParser(const SingleDocParser&) = delete;
SingleDocParser(SingleDocParser&&) = delete;
SingleDocParser& operator=(const SingleDocParser&) = delete;
SingleDocParser& operator=(SingleDocParser&&) = delete;
~SingleDocParser(); ~SingleDocParser();
void HandleDocument(EventHandler& eventHandler); void HandleDocument(EventHandler& eventHandler);

View File

@ -7,7 +7,6 @@
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/noncopyable.h"
#include "yaml-cpp/mark.h" #include "yaml-cpp/mark.h"
#include <cstddef> #include <cstddef>
#include <deque> #include <deque>
@ -17,7 +16,7 @@
#include <string> #include <string>
namespace YAML { namespace YAML {
class Stream : private noncopyable { class Stream {
public: public:
friend class StreamCharSource; friend class StreamCharSource;

View File

@ -7,7 +7,6 @@
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/noncopyable.h"
#include <cstddef> #include <cstddef>
namespace YAML { namespace YAML {
@ -16,6 +15,9 @@ class StreamCharSource {
StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {} StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {}
StreamCharSource(const StreamCharSource& source) StreamCharSource(const StreamCharSource& source)
: m_offset(source.m_offset), m_stream(source.m_stream) {} : m_offset(source.m_offset), m_stream(source.m_stream) {}
StreamCharSource(StreamCharSource&&) = delete;
StreamCharSource& operator=(const StreamCharSource&) = delete;
StreamCharSource& operator=(StreamCharSource&&) = delete;
~StreamCharSource() {} ~StreamCharSource() {}
operator bool() const; operator bool() const;
@ -27,8 +29,6 @@ class StreamCharSource {
private: private:
std::size_t m_offset; std::size_t m_offset;
const Stream& m_stream; const Stream& m_stream;
StreamCharSource& operator=(const StreamCharSource&); // non-assignable
}; };
inline StreamCharSource::operator bool() const { inline StreamCharSource::operator bool() const {