From b626465ccadaff0760b8b23847c775ae6af766e3 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 18 Apr 2016 21:46:42 +0200 Subject: [PATCH] [DEV] change 'enum' in 'enum class' --- exml/Element.cpp | 2 +- exml/Node.cpp | 2 +- exml/internal/Attribute.h | 2 +- exml/internal/Comment.h | 2 +- exml/internal/Declaration.h | 2 +- exml/internal/Document.h | 2 +- exml/internal/Element.cpp | 12 ++++++------ exml/internal/Element.h | 2 +- exml/internal/Node.cpp | 14 +++++++------- exml/internal/Text.h | 2 +- exml/nodeType.cpp | 32 ++++++++++++++++---------------- exml/nodeType.h | 18 +++++++++--------- test/exmlTestAttribute.cpp | 2 +- test/exmlTestComment.cpp | 2 +- test/exmlTestDeclaration.cpp | 2 +- test/exmlTestDeclarationXML.cpp | 2 +- test/exmlTestElement.cpp | 4 ++-- 17 files changed, 52 insertions(+), 52 deletions(-) diff --git a/exml/Element.cpp b/exml/Element.cpp index 7e72e9d..96fc212 100644 --- a/exml/Element.cpp +++ b/exml/Element.cpp @@ -73,7 +73,7 @@ size_t exml::ElementData::size() const { enum exml::nodeType exml::ElementData::getType(int32_t _id) const { if (m_data->m_data == nullptr) { EXML_ERROR(" can not get type ..."); - return exml::nodeType_unknow; + return exml::nodeType::unknow; } return static_cast(m_data->m_data.get())->getType(_id); } diff --git a/exml/Node.cpp b/exml/Node.cpp index ef803ec..aad03e6 100644 --- a/exml/Node.cpp +++ b/exml/Node.cpp @@ -71,7 +71,7 @@ const std::string& exml::Node::getValue() const { enum exml::nodeType exml::Node::getType() const { if (m_data == nullptr) { EXML_ERROR(" can not get type ..."); - return exml::nodeType_unknow; + return exml::nodeType::unknow; } return m_data->getType(); } diff --git a/exml/internal/Attribute.h b/exml/internal/Attribute.h index 614d267..03e28fa 100644 --- a/exml/internal/Attribute.h +++ b/exml/internal/Attribute.h @@ -50,7 +50,7 @@ namespace exml { }; public: enum nodeType getType() const override { - return exml::nodeType_attribute; + return exml::nodeType::attribute; }; bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iGenerate(std::string& _data, int32_t _indent) const override; diff --git a/exml/internal/Comment.h b/exml/internal/Comment.h index 177937c..1421a3f 100644 --- a/exml/internal/Comment.h +++ b/exml/internal/Comment.h @@ -33,7 +33,7 @@ namespace exml { } public: enum nodeType getType() const override { - return nodeType_comment; + return nodeType::comment; } bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iGenerate(std::string& _data, int32_t _indent) const override; diff --git a/exml/internal/Declaration.h b/exml/internal/Declaration.h index 037628e..36950f9 100644 --- a/exml/internal/Declaration.h +++ b/exml/internal/Declaration.h @@ -33,7 +33,7 @@ namespace exml { static ememory::SharedPtr create(const std::string& _name=""); public: enum nodeType getType() const override{ - return nodeType_declaration; + return nodeType::declaration; }; bool iGenerate(std::string& _data, int32_t _indent) const override; bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; diff --git a/exml/internal/Document.h b/exml/internal/Document.h index 7a73003..bd3635f 100644 --- a/exml/internal/Document.h +++ b/exml/internal/Document.h @@ -109,7 +109,7 @@ namespace exml { void displayError(); public: enum nodeType getType() const override { - return nodeType_document; + return nodeType::document; } bool iGenerate(std::string& _data, int32_t _indent) const override; ememory::SharedPtr toDocument() override { diff --git a/exml/internal/Element.cpp b/exml/internal/Element.cpp index 6e76dbc..7f32cd6 100644 --- a/exml/internal/Element.cpp +++ b/exml/internal/Element.cpp @@ -31,7 +31,7 @@ ememory::SharedPtr exml::internal::Element::create(cons enum exml::nodeType exml::internal::Element::getType(int32_t _id) const { ememory::SharedPtr tmpp = getNode(_id); if (tmpp == nullptr) { - return exml::nodeType_unknow; + return exml::nodeType::unknow; } return tmpp->getType(); } @@ -75,7 +75,7 @@ ememory::SharedPtr exml::internal::Element::getNamed(co } for (size_t iii=0; iiigetType() == exml::nodeType_element + && m_listSub[iii]->getType() == exml::nodeType::element && m_listSub[iii]->getValue() == _name) { if (m_listSub[iii] == nullptr) { return nullptr; @@ -92,7 +92,7 @@ ememory::SharedPtr exml::internal::Element::getNa } for (size_t iii=0; iiigetType() == exml::nodeType_element + && m_listSub[iii]->getType() == exml::nodeType::element && m_listSub[iii]->getValue() == _name) { if (m_listSub[iii] == nullptr) { return nullptr; @@ -108,7 +108,7 @@ void exml::internal::Element::append(const ememory::SharedPtrgetType() == exml::nodeType_attribute) { + if (_node->getType() == exml::nodeType::attribute) { appendAttribute(_node->toAttribute()); return; } @@ -140,7 +140,7 @@ void exml::internal::Element::remove(const std::string& _nodeName) { std::string exml::internal::Element::getText() const { std::string res; if (m_listSub.size() == 1) { - if (m_listSub[0]->getType() == nodeType_text) { + if (m_listSub[0]->getType() == nodeType::text) { res = m_listSub[0]->getValue(); } else { m_listSub[0]->iGenerate(res, 0); @@ -164,7 +164,7 @@ bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) con if (m_listSub.size()>0) { if( m_listSub.size() == 1 && m_listSub[0] != nullptr - && m_listSub[0]->getType() == exml::nodeType_text + && m_listSub[0]->getType() == exml::nodeType::text && std::dynamic_pointer_cast(m_listSub[0])->countLines() == 1) { _data += ">"; m_listSub[0]->iGenerate(_data,0); diff --git a/exml/internal/Element.h b/exml/internal/Element.h index 55b5c4b..b52926e 100644 --- a/exml/internal/Element.h +++ b/exml/internal/Element.h @@ -124,7 +124,7 @@ namespace exml { bool _mainNode=false); public: enum nodeType getType() const override { - return nodeType_element; + return nodeType::element; } bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iGenerate(std::string& _data, int32_t _indent) const override; diff --git a/exml/internal/Node.cpp b/exml/internal/Node.cpp index c970082..b126ee2 100644 --- a/exml/internal/Node.cpp +++ b/exml/internal/Node.cpp @@ -126,7 +126,7 @@ const std::string& exml::internal::Node::getValue() const { } enum exml::nodeType exml::internal::Node::getType() const { - return nodeType_node; + return nodeType::node; } ememory::SharedPtr exml::internal::Node::toDocument() { @@ -178,26 +178,26 @@ ememory::SharedPtr exml::internal::Node::toText() co } bool exml::internal::Node::isDocument() const { - return getType() == exml::nodeType_document; + return getType() == exml::nodeType::document; } bool exml::internal::Node::isAttribute() const { - return getType() == exml::nodeType_attribute; + return getType() == exml::nodeType::attribute; } bool exml::internal::Node::isComment() const { - return getType() == exml::nodeType_comment; + return getType() == exml::nodeType::comment; } bool exml::internal::Node::isDeclaration() const { - return getType() == exml::nodeType_declaration; + return getType() == exml::nodeType::declaration; } bool exml::internal::Node::isElement() const { - return getType() == exml::nodeType_element; + return getType() == exml::nodeType::element; } bool exml::internal::Node::isText() const { - return getType() == exml::nodeType_text; + return getType() == exml::nodeType::text; } diff --git a/exml/internal/Text.h b/exml/internal/Text.h index e55ab50..0a4c320 100644 --- a/exml/internal/Text.h +++ b/exml/internal/Text.h @@ -40,7 +40,7 @@ namespace exml { int32_t countLines() const; public: enum nodeType getType() const override{ - return nodeType_text; + return nodeType::text; }; bool iParse(const std::string& _data, int32_t& _pos, diff --git a/exml/nodeType.cpp b/exml/nodeType.cpp index 3fc1a88..845ac71 100644 --- a/exml/nodeType.cpp +++ b/exml/nodeType.cpp @@ -13,29 +13,29 @@ std::ostream& exml::operator <<(std::ostream& _os, enum exml::nodeType _obj) { switch (_obj) { - case nodeType_unknow: - _os << "exml::nodeType_unknow"; + case nodeType::unknow: + _os << "exml::nodeType::unknow"; break; - case nodeType_node: - _os << "exml::nodeType_node"; + case nodeType::node: + _os << "exml::nodeType::node"; break; - case nodeType_document: - _os << "exml::nodeType_document"; + case nodeType::document: + _os << "exml::nodeType::document"; break; - case nodeType_declaration: - _os << "exml::nodeType_declaration"; + case nodeType::declaration: + _os << "exml::nodeType::declaration"; break; - case nodeType_attribute: - _os << "exml::nodeType_attribute"; + case nodeType::attribute: + _os << "exml::nodeType::attribute"; break; - case nodeType_element: - _os << "exml::nodeType_element"; + case nodeType::element: + _os << "exml::nodeType::element"; break; - case nodeType_comment: - _os << "exml::nodeType_comment"; + case nodeType::comment: + _os << "exml::nodeType::comment"; break; - case nodeType_text: - _os << "exml::nodeType_text"; + case nodeType::text: + _os << "exml::nodeType::text"; break; } return _os; diff --git a/exml/nodeType.h b/exml/nodeType.h index 1a51f21..24befa2 100644 --- a/exml/nodeType.h +++ b/exml/nodeType.h @@ -16,15 +16,15 @@ namespace exml { /** * @brief Type of the XML elements. */ - enum nodeType { - nodeType_unknow, //!< might be an error ... - nodeType_node, //!< might be an error ... - nodeType_document, //!< all the file main access - nodeType_declaration, //!< <?xml ... ?> - nodeType_attribute, //!< the <Element ATTRIBUTE="ATTRIBUTE_VALUE" /> - nodeType_element, //!< the <XXX> ... </XXX> - nodeType_comment, //!< comment node : <!-- --> - nodeType_text, //!< <XXX> InsideText </XXX> + enum class nodeType { + unknow, //!< might be an error ... + node, //!< might be an error ... + document, //!< all the file main access + declaration, //!< <?xml ... ?> + attribute, //!< the <Element ATTRIBUTE="ATTRIBUTE_VALUE" /> + element, //!< the <XXX> ... </XXX> + comment, //!< comment node : <!-- --> + text, //!< <XXX> InsideText </XXX> }; //! @not_in_doc std::ostream& operator <<(std::ostream& _os, enum nodeType _obj); diff --git a/test/exmlTestAttribute.cpp b/test/exmlTestAttribute.cpp index d502b38..3cc4bd9 100644 --- a/test/exmlTestAttribute.cpp +++ b/test/exmlTestAttribute.cpp @@ -13,7 +13,7 @@ TEST(TestAttribute, create) { exml::Attribute myAttribute("nameAttribute", "valueAttribute"); - EXPECT_EQ(myAttribute.getType(), exml::nodeType_attribute); + EXPECT_EQ(myAttribute.getType(), exml::nodeType::attribute); } TEST(TestAttribute, createCopy) { diff --git a/test/exmlTestComment.cpp b/test/exmlTestComment.cpp index 711430b..dab3b49 100644 --- a/test/exmlTestComment.cpp +++ b/test/exmlTestComment.cpp @@ -12,7 +12,7 @@ TEST(TestComment, create) { exml::Comment myComment("my Comment"); - EXPECT_EQ(myComment.getType(), exml::nodeType_comment); + EXPECT_EQ(myComment.getType(), exml::nodeType::comment); } TEST(TestComment, createCopy) { diff --git a/test/exmlTestDeclaration.cpp b/test/exmlTestDeclaration.cpp index 872b47a..934f716 100644 --- a/test/exmlTestDeclaration.cpp +++ b/test/exmlTestDeclaration.cpp @@ -12,7 +12,7 @@ TEST(TestDeclaration, create) { exml::Declaration myDeclaration("type"); - EXPECT_EQ(myDeclaration.getType(), exml::nodeType_declaration); + EXPECT_EQ(myDeclaration.getType(), exml::nodeType::declaration); } TEST(TestDeclaration, createCopy) { diff --git a/test/exmlTestDeclarationXML.cpp b/test/exmlTestDeclarationXML.cpp index 3a027e6..e1c312d 100644 --- a/test/exmlTestDeclarationXML.cpp +++ b/test/exmlTestDeclarationXML.cpp @@ -12,7 +12,7 @@ TEST(TestDeclarationXML, create) { exml::DeclarationXML myDeclarationXML("1.0", "UTF-8", true); - EXPECT_EQ(myDeclarationXML.getType(), exml::nodeType_declaration); + EXPECT_EQ(myDeclarationXML.getType(), exml::nodeType::declaration); } TEST(TestDeclarationXML, createCopy) { diff --git a/test/exmlTestElement.cpp b/test/exmlTestElement.cpp index c35f389..f2a65ea 100644 --- a/test/exmlTestElement.cpp +++ b/test/exmlTestElement.cpp @@ -14,7 +14,7 @@ TEST(TestElement, create) { exml::Element myElement("NodeName"); - EXPECT_EQ(myElement.getType(), exml::nodeType_element); + EXPECT_EQ(myElement.getType(), exml::nodeType::element); } TEST(TestElement, createCopy) { @@ -55,7 +55,7 @@ TEST(TestElement, getText2 ) { TEST(TestElement, getTypeId ) { exml::Element myElement("NodeName"); - EXPECT_EQ(myElement.nodes.getType(1), exml::nodeType_unknow); + EXPECT_EQ(myElement.nodes.getType(1), exml::nodeType::unknow); } TEST(TestElement, getNamed ) {