[DEBUG] fix the use of ememory

This commit is contained in:
Edouard DUPIN 2016-07-15 22:15:33 +02:00
parent 233c303d93
commit d2a9a09acb
11 changed files with 41 additions and 35 deletions

View File

@ -25,8 +25,8 @@ std::ostream& exml::operator <<(std::ostream& _os, const exml::Node& _obj) {
} }
exml::Node::Node(ememory::SharedPtr<exml::internal::Node> _internalNode) : exml::Node::Node(const ememory::SharedPtr<exml::internal::Node>& _internalNode) :
m_data(_internalNode) { m_data(ememory::constPointerCast<exml::internal::Node>(_internalNode)) {
// nothing to DO ... // nothing to DO ...
} }

View File

@ -38,7 +38,7 @@ namespace exml {
* @brief basic element of a xml structure * @brief basic element of a xml structure
* @param[in] _internalNode Internal reference of the Node * @param[in] _internalNode Internal reference of the Node
*/ */
Node(ememory::SharedPtr<exml::internal::Node> _internalNode); Node(const ememory::SharedPtr<exml::internal::Node>& _internalNode);
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure
*/ */

View File

@ -55,8 +55,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Attribute> toAttribute() override { ememory::SharedPtr<exml::internal::Attribute> toAttribute() override {
return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis());
}; };
ememory::SharedPtr<const exml::internal::Attribute> toAttribute() const override { const ememory::SharedPtr<exml::internal::Attribute> toAttribute() const override {
return ememory::staticPointerCast<const exml::internal::Attribute>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis());
}; };
void clear() override; void clear() override;
}; };

View File

@ -38,8 +38,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Comment> toComment() override { ememory::SharedPtr<exml::internal::Comment> toComment() override {
return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis());
} }
ememory::SharedPtr<const exml::internal::Comment> toComment() const override { const ememory::SharedPtr<exml::internal::Comment> toComment() const override {
return ememory::staticPointerCast<const exml::internal::Comment>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis());
} }
}; };
} }

View File

@ -38,8 +38,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Declaration> toDeclaration() override { ememory::SharedPtr<exml::internal::Declaration> toDeclaration() override {
return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis());
}; };
ememory::SharedPtr<const exml::internal::Declaration> toDeclaration() const override { const ememory::SharedPtr<exml::internal::Declaration> toDeclaration() const override {
return ememory::staticPointerCast<const exml::internal::Declaration>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis());
}; };
}; };
/** /**

View File

@ -112,8 +112,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Document> toDocument() override { ememory::SharedPtr<exml::internal::Document> toDocument() override {
return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis());
} }
ememory::SharedPtr<const exml::internal::Document> toDocument() const override { const ememory::SharedPtr<exml::internal::Document> toDocument() const override {
return ememory::staticPointerCast<const exml::internal::Document>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis());
} }
}; };
} }

View File

@ -42,7 +42,7 @@ ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(int32_
return m_listSub[_id]; return m_listSub[_id];
} }
ememory::SharedPtr<const exml::internal::Node> exml::internal::Element::getNode(int32_t _id) const { const ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(int32_t _id) const {
if ( _id <0 if ( _id <0
|| (size_t)_id>=m_listSub.size()) { || (size_t)_id>=m_listSub.size()) {
return nullptr; return nullptr;
@ -59,8 +59,8 @@ ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getElement(
return tmpp->toElement(); return tmpp->toElement();
} }
ememory::SharedPtr<const exml::internal::Element> exml::internal::Element::getElement(int32_t _id) const { const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getElement(int32_t _id) const {
ememory::SharedPtr<const exml::internal::Node> tmpp = getNode(_id); const ememory::SharedPtr<exml::internal::Node> tmpp = getNode(_id);
if (tmpp == nullptr) { if (tmpp == nullptr) {
return nullptr; return nullptr;
} }
@ -84,7 +84,7 @@ ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(co
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) const { const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
return nullptr; return nullptr;
} }
@ -163,7 +163,7 @@ bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) con
if( m_listSub.size() == 1 if( m_listSub.size() == 1
&& m_listSub[0] != nullptr && m_listSub[0] != nullptr
&& m_listSub[0]->getType() == exml::nodeType::text && m_listSub[0]->getType() == exml::nodeType::text
&& std::dynamic_pointer_cast<exml::internal::Text>(m_listSub[0])->countLines() == 1) { && ememory::dynamicPointerCast<exml::internal::Text>(m_listSub[0])->countLines() == 1) {
_data += ">"; _data += ">";
m_listSub[0]->iGenerate(_data,0); m_listSub[0]->iGenerate(_data,0);
EXML_VERBOSE(" generate : '" << _data << "'"); EXML_VERBOSE(" generate : '" << _data << "'");

View File

@ -72,7 +72,7 @@ namespace exml {
* @param[in] _id Id of the element. * @param[in] _id Id of the element.
* @return Pointer on node. * @return Pointer on node.
*/ */
ememory::SharedPtr<const Node> getNode(int32_t _id) const; const ememory::SharedPtr<Node> getNode(int32_t _id) const;
/** /**
* @brief get the element casted in Element (if the node is not an element return NULL). * @brief get the element casted in Element (if the node is not an element return NULL).
* @param[in] _id Id of the element. * @param[in] _id Id of the element.
@ -84,7 +84,7 @@ namespace exml {
* @param[in] _id Id of the element. * @param[in] _id Id of the element.
* @return Pointer on the element or NULL. * @return Pointer on the element or NULL.
*/ */
ememory::SharedPtr<const Element> getElement(int32_t _id) const;// TODO : DEPRECATED ... not use anymore ... const ememory::SharedPtr<Element> getElement(int32_t _id) const;// TODO : DEPRECATED ... not use anymore ...
/** /**
* @brief get an element with his name (work only with exml::internal::Element) * @brief get an element with his name (work only with exml::internal::Element)
* @param[in] _name Name of the element that is requested * @param[in] _name Name of the element that is requested
@ -96,7 +96,7 @@ namespace exml {
* @param[in] _name Name of the element that is requested * @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL. * @return Pointer on the element or NULL.
*/ */
ememory::SharedPtr<const Element> getNamed(const std::string& _name) const; const ememory::SharedPtr<Element> getNamed(const std::string& _name) const;
/** /**
* @brief get the internal data of the element (if the element has some sub node thay are converted in xml string == > like this it is not needed to use <![CDATA[...]]> * @brief get the internal data of the element (if the element has some sub node thay are converted in xml string == > like this it is not needed to use <![CDATA[...]]>
* @return the curent data string. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text... * @return the curent data string. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text...
@ -129,8 +129,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Element> toElement() override { ememory::SharedPtr<exml::internal::Element> toElement() override {
return ememory::staticPointerCast<exml::internal::Element>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Element>(sharedFromThis());
} }
ememory::SharedPtr<const exml::internal::Element> toElement() const override { const ememory::SharedPtr<exml::internal::Element> toElement() const override {
return ememory::staticPointerCast<const exml::internal::Element>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Element>(sharedFromThis());
} }
void clear() override; void clear() override;
}; };

View File

@ -5,6 +5,12 @@
*/ */
#include <exml/internal/Node.h> #include <exml/internal/Node.h>
#include <exml/internal/Document.h>
#include <exml/internal/Attribute.h>
#include <exml/internal/Comment.h>
#include <exml/internal/Declaration.h>
#include <exml/internal/Element.h>
#include <exml/internal/Text.h>
#include <exml/debug.h> #include <exml/debug.h>
static bool isWhiteChar(char32_t _val) { static bool isWhiteChar(char32_t _val) {
@ -131,7 +137,7 @@ ememory::SharedPtr<exml::internal::Document> exml::internal::Node::toDocument()
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Document> exml::internal::Node::toDocument() const { const ememory::SharedPtr<exml::internal::Document> exml::internal::Node::toDocument() const {
return nullptr; return nullptr;
} }
@ -139,7 +145,7 @@ ememory::SharedPtr<exml::internal::Attribute> exml::internal::Node::toAttribute(
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Attribute> exml::internal::Node::toAttribute() const { const ememory::SharedPtr<exml::internal::Attribute> exml::internal::Node::toAttribute() const {
return nullptr; return nullptr;
} }
@ -147,7 +153,7 @@ ememory::SharedPtr<exml::internal::Comment> exml::internal::Node::toComment() {
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Comment> exml::internal::Node::toComment() const { const ememory::SharedPtr<exml::internal::Comment> exml::internal::Node::toComment() const {
return nullptr; return nullptr;
} }
@ -155,7 +161,7 @@ ememory::SharedPtr<exml::internal::Declaration> exml::internal::Node::toDeclarat
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Declaration> exml::internal::Node::toDeclaration() const { const ememory::SharedPtr<exml::internal::Declaration> exml::internal::Node::toDeclaration() const {
return nullptr; return nullptr;
} }
@ -163,7 +169,7 @@ ememory::SharedPtr<exml::internal::Element> exml::internal::Node::toElement() {
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Element> exml::internal::Node::toElement() const { const ememory::SharedPtr<exml::internal::Element> exml::internal::Node::toElement() const {
return nullptr; return nullptr;
} }
@ -171,7 +177,7 @@ ememory::SharedPtr<exml::internal::Text> exml::internal::Node::toText() {
return nullptr; return nullptr;
} }
ememory::SharedPtr<const exml::internal::Text> exml::internal::Node::toText() const{ const ememory::SharedPtr<exml::internal::Text> exml::internal::Node::toText() const{
return nullptr; return nullptr;
} }

View File

@ -143,7 +143,7 @@ namespace exml {
* @brief Cast the element in a Document if it is possible. * @brief Cast the element in a Document if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Document> toDocument() const; virtual const ememory::SharedPtr<exml::internal::Document> toDocument() const;
/** /**
* @brief Cast the element in a Attribute if it is possible. * @brief Cast the element in a Attribute if it is possible.
* @return pointer on the class or nullptr. * @return pointer on the class or nullptr.
@ -153,7 +153,7 @@ namespace exml {
* @brief Cast the element in a Attribute if it is possible. * @brief Cast the element in a Attribute if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Attribute> toAttribute() const; virtual const ememory::SharedPtr<exml::internal::Attribute> toAttribute() const;
/** /**
* @brief Cast the element in a Comment if it is possible. * @brief Cast the element in a Comment if it is possible.
* @return pointer on the class or nullptr. * @return pointer on the class or nullptr.
@ -163,7 +163,7 @@ namespace exml {
* @brief Cast the element in a Comment if it is possible. * @brief Cast the element in a Comment if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Comment> toComment() const; virtual const ememory::SharedPtr<exml::internal::Comment> toComment() const;
/** /**
* @brief Cast the element in a Declaration if it is possible. * @brief Cast the element in a Declaration if it is possible.
* @return pointer on the class or nullptr. * @return pointer on the class or nullptr.
@ -173,7 +173,7 @@ namespace exml {
* @brief Cast the element in a Declaration if it is possible. * @brief Cast the element in a Declaration if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Declaration> toDeclaration() const; virtual const ememory::SharedPtr<exml::internal::Declaration> toDeclaration() const;
/** /**
* @brief Cast the element in a Element if it is possible. * @brief Cast the element in a Element if it is possible.
* @return pointer on the class or nullptr. * @return pointer on the class or nullptr.
@ -183,7 +183,7 @@ namespace exml {
* @brief Cast the element in a Element if it is possible. * @brief Cast the element in a Element if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Element> toElement() const; virtual const ememory::SharedPtr<exml::internal::Element> toElement() const;
/** /**
* @brief Cast the element in a Text if it is possible. * @brief Cast the element in a Text if it is possible.
* @return pointer on the class or nullptr. * @return pointer on the class or nullptr.
@ -193,7 +193,7 @@ namespace exml {
* @brief Cast the element in a Text if it is possible. * @brief Cast the element in a Text if it is possible.
* @return CONST pointer on the class or nullptr. * @return CONST pointer on the class or nullptr.
*/ */
virtual ememory::SharedPtr<const exml::internal::Text> toText() const; virtual const ememory::SharedPtr<exml::internal::Text> toText() const;
/** /**
* @brief check if the node is a exml::internal::Document * @brief check if the node is a exml::internal::Document

View File

@ -49,8 +49,8 @@ namespace exml {
ememory::SharedPtr<exml::internal::Text> toText() override { ememory::SharedPtr<exml::internal::Text> toText() override {
return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis());
}; };
ememory::SharedPtr<const exml::internal::Text> toText() const override { const ememory::SharedPtr<exml::internal::Text> toText() const override {
return ememory::staticPointerCast<const exml::internal::Text>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis());
}; };
}; };
/** /**