From d1a722aba936a19166d5c25c741785e68e718970 Mon Sep 17 00:00:00 2001 From: Ted Lyngmo Date: Tue, 12 Mar 2019 17:45:33 +0100 Subject: [PATCH] Fix comments on previous commit --- include/yaml-cpp/contrib/anchordict.h | 3 ++- include/yaml-cpp/emitter.h | 5 +++-- include/yaml-cpp/node/detail/memory.h | 3 ++- include/yaml-cpp/node/impl.h | 4 ++-- include/yaml-cpp/noncopyable.h | 23 ----------------------- include/yaml-cpp/parser.h | 9 +++++++-- src/collectionstack.h | 3 ++- src/directives.cpp | 7 +------ src/ptr_vector.h | 8 +++++--- src/regex_yaml.cpp | 7 +------ src/regex_yaml.h | 4 ++-- src/setting.h | 9 ++++++--- src/singledocparser.h | 7 +++++-- src/stream.h | 3 +-- src/streamcharsource.h | 6 +++--- 15 files changed, 42 insertions(+), 59 deletions(-) delete mode 100644 include/yaml-cpp/noncopyable.h diff --git a/include/yaml-cpp/contrib/anchordict.h b/include/yaml-cpp/contrib/anchordict.h index 4b12281..1d7dbc4 100644 --- a/include/yaml-cpp/contrib/anchordict.h +++ b/include/yaml-cpp/contrib/anchordict.h @@ -22,6 +22,7 @@ namespace YAML { template class AnchorDict { public: + AnchorDict() : m_data{} {} void Register(anchor_t anchor, T value) { if (anchor > m_data.size()) { m_data.resize(anchor); @@ -32,7 +33,7 @@ class AnchorDict { T Get(anchor_t anchor) const { return m_data[anchor - 1]; } private: - std::vector m_data{}; + std::vector m_data; }; } diff --git a/include/yaml-cpp/emitter.h b/include/yaml-cpp/emitter.h index ef92cc4..90ce2a6 100644 --- a/include/yaml-cpp/emitter.h +++ b/include/yaml-cpp/emitter.h @@ -16,7 +16,6 @@ #include "yaml-cpp/dll.h" #include "yaml-cpp/emitterdef.h" #include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/noncopyable.h" #include "yaml-cpp/null.h" #include "yaml-cpp/ostream_wrapper.h" @@ -28,10 +27,12 @@ struct _Null; namespace YAML { class EmitterState; -class YAML_CPP_API Emitter : private noncopyable { +class YAML_CPP_API Emitter { public: Emitter(); explicit Emitter(std::ostream& stream); + Emitter(const Emitter&) = delete; + Emitter& operator=(const Emitter&) = delete; ~Emitter(); // output diff --git a/include/yaml-cpp/node/detail/memory.h b/include/yaml-cpp/node/detail/memory.h index 13822ea..1f5676d 100644 --- a/include/yaml-cpp/node/detail/memory.h +++ b/include/yaml-cpp/node/detail/memory.h @@ -22,12 +22,13 @@ namespace YAML { namespace detail { class YAML_CPP_API memory { public: + memory() : m_nodes{} {} node& create_node(); void merge(const memory& rhs); private: typedef std::set Nodes; - Nodes m_nodes{}; + Nodes m_nodes; }; class YAML_CPP_API memory_holder { diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 444011e..27dba0d 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -15,7 +15,7 @@ #include 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) : m_isValid(true), @@ -42,7 +42,7 @@ inline Node::Node(const Node& rhs) m_pMemory(rhs.m_pMemory), 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) : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} diff --git a/include/yaml-cpp/noncopyable.h b/include/yaml-cpp/noncopyable.h deleted file mode 100644 index 35f3543..0000000 --- a/include/yaml-cpp/noncopyable.h +++ /dev/null @@ -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 diff --git a/include/yaml-cpp/parser.h b/include/yaml-cpp/parser.h index ceac22d..faaabb6 100644 --- a/include/yaml-cpp/parser.h +++ b/include/yaml-cpp/parser.h @@ -11,7 +11,6 @@ #include #include "yaml-cpp/dll.h" -#include "yaml-cpp/noncopyable.h" namespace YAML { class EventHandler; @@ -24,11 +23,17 @@ struct Token; * A parser turns a stream of bytes into one stream of "events" per YAML * document in the input stream. */ -class YAML_CPP_API Parser : private noncopyable { +class YAML_CPP_API Parser { public: /** Constructs an empty parser (with no input. */ 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 * live as long as the parser. diff --git a/src/collectionstack.h b/src/collectionstack.h index bfbe181..fcaf078 100644 --- a/src/collectionstack.h +++ b/src/collectionstack.h @@ -17,6 +17,7 @@ struct CollectionType { class CollectionStack { public: + CollectionStack() : collectionStack{} {} CollectionType::value GetCurCollectionType() const { if (collectionStack.empty()) return CollectionType::NoCollection; @@ -33,7 +34,7 @@ class CollectionStack { } private: - std::stack collectionStack{}; + std::stack collectionStack; }; } diff --git a/src/directives.cpp b/src/directives.cpp index c936f73..75f0803 100644 --- a/src/directives.cpp +++ b/src/directives.cpp @@ -1,12 +1,7 @@ #include "directives.h" namespace YAML { -Directives::Directives() : version{true, 1, 2}, tags{} { - /* Version: - ** bool isDefault; - ** int major, minor; - */ -} +Directives::Directives() : version{true, 1, 2}, tags{} {} const std::string Directives::TranslateTagHandle( const std::string& handle) const { diff --git a/src/ptr_vector.h b/src/ptr_vector.h index 8a354ba..1c7e40c 100644 --- a/src/ptr_vector.h +++ b/src/ptr_vector.h @@ -12,15 +12,17 @@ #include #include -#include "yaml-cpp/noncopyable.h" - namespace YAML { // TODO: This class is no longer needed template -class ptr_vector : private YAML::noncopyable { +class ptr_vector { public: 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(); } diff --git a/src/regex_yaml.cpp b/src/regex_yaml.cpp index e40f9c0..f8b5130 100644 --- a/src/regex_yaml.cpp +++ b/src/regex_yaml.cpp @@ -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(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])); -*/ -} +RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {} // combination constructors RegEx operator!(const RegEx& ex) { diff --git a/src/regex_yaml.h b/src/regex_yaml.h index 9428836..3a347bb 100644 --- a/src/regex_yaml.h +++ b/src/regex_yaml.h @@ -31,7 +31,7 @@ enum REGEX_OP { class YAML_CPP_API RegEx { public: RegEx(); - RegEx(char ch); + explicit RegEx(char ch); RegEx(char a, char z); RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); ~RegEx() {} @@ -53,7 +53,7 @@ class YAML_CPP_API RegEx { int Match(const Source& source) const; private: - RegEx(REGEX_OP op); + explicit RegEx(REGEX_OP op); template bool IsValidSource(const Source& source) const; diff --git a/src/setting.h b/src/setting.h index 535088e..62a24ee 100644 --- a/src/setting.h +++ b/src/setting.h @@ -9,7 +9,7 @@ #include #include -#include "yaml-cpp/noncopyable.h" +#include namespace YAML { class SettingChangeBase; @@ -37,7 +37,7 @@ class SettingChangeBase { }; template -class SettingChange : public SettingChangeBase, private noncopyable { +class SettingChange : public SettingChangeBase { public: SettingChange(Setting* pSetting) : m_pCurSetting(pSetting), @@ -62,9 +62,12 @@ inline std::unique_ptr Setting::set(const T& value) { return pChange; } -class SettingChanges : private noncopyable { +class SettingChanges { public: SettingChanges() : m_settingChanges{} {} + SettingChanges(const SettingChanges&) = delete; + SettingChanges(SettingChanges&& rhs) : m_settingChanges(std::move(rhs.m_settingChanges)) {} + SettingChanges& operator=(const SettingChanges&) = delete; ~SettingChanges() { clear(); } void clear() { diff --git a/src/singledocparser.h b/src/singledocparser.h index 2b92067..fc7f835 100644 --- a/src/singledocparser.h +++ b/src/singledocparser.h @@ -12,7 +12,6 @@ #include #include "yaml-cpp/anchor.h" -#include "yaml-cpp/noncopyable.h" namespace YAML { class CollectionStack; @@ -23,9 +22,13 @@ struct Directives; struct Mark; struct Token; -class SingleDocParser : private noncopyable { +class SingleDocParser { public: SingleDocParser(Scanner& scanner, const Directives& directives); + SingleDocParser(const SingleDocParser&) = delete; + SingleDocParser(SingleDocParser&&) = delete; + SingleDocParser& operator=(const SingleDocParser&) = delete; + SingleDocParser& operator=(SingleDocParser&&) = delete; ~SingleDocParser(); void HandleDocument(EventHandler& eventHandler); diff --git a/src/stream.h b/src/stream.h index c0198af..69f8372 100644 --- a/src/stream.h +++ b/src/stream.h @@ -7,7 +7,6 @@ #pragma once #endif -#include "yaml-cpp/noncopyable.h" #include "yaml-cpp/mark.h" #include #include @@ -17,7 +16,7 @@ #include namespace YAML { -class Stream : private noncopyable { +class Stream { public: friend class StreamCharSource; diff --git a/src/streamcharsource.h b/src/streamcharsource.h index 624599e..e4d0bfe 100644 --- a/src/streamcharsource.h +++ b/src/streamcharsource.h @@ -7,7 +7,6 @@ #pragma once #endif -#include "yaml-cpp/noncopyable.h" #include namespace YAML { @@ -16,6 +15,9 @@ class StreamCharSource { StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {} StreamCharSource(const StreamCharSource& source) : m_offset(source.m_offset), m_stream(source.m_stream) {} + StreamCharSource(StreamCharSource&&) = delete; + StreamCharSource& operator=(const StreamCharSource&) = delete; + StreamCharSource& operator=(StreamCharSource&&) = delete; ~StreamCharSource() {} operator bool() const; @@ -27,8 +29,6 @@ class StreamCharSource { private: std::size_t m_offset; const Stream& m_stream; - - StreamCharSource& operator=(const StreamCharSource&); // non-assignable }; inline StreamCharSource::operator bool() const {