From e98c82d380820e285b56e19433bc2557c5e99cba Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Apr 2016 21:53:26 +0200 Subject: [PATCH] [DOC] documentation finished --- doc/build.md | 66 +++++++++++++++++ doc/index.bb | 28 ------- doc/mainpage.md | 71 ++++++++++++++++++ doc/read.md | 80 ++++++++++++++++++++ doc/tutorial/000_Read.bb | 0 doc/tutorial/001_write.bb | 0 doc/write.md | 61 ++++++++++++++++ doxy_exml.py | 3 + exml/Attribute.cpp | 2 - exml/Attribute.h | 3 +- exml/AttributeList.cpp | 2 - exml/AttributeList.h | 34 +++++++-- exml/Comment.cpp | 2 - exml/Comment.h | 3 +- exml/Declaration.cpp | 2 - exml/Declaration.h | 4 +- exml/Document.cpp | 2 - exml/Document.h | 3 +- exml/Element.cpp | 2 - exml/Element.h | 31 ++++++-- exml/FilePos.cpp | 2 - exml/FilePos.h | 2 - exml/Node.cpp | 2 - exml/Node.h | 4 +- exml/Text.cpp | 2 - exml/Text.h | 3 +- exml/debug.cpp | 2 - exml/debug.h | 2 - exml/exml.h | 8 +- exml/internal/Attribute.cpp | 2 - exml/internal/Attribute.h | 2 - exml/internal/AttributeList.cpp | 2 - exml/internal/AttributeList.h | 2 - exml/internal/Comment.cpp | 2 - exml/internal/Comment.h | 2 - exml/internal/Declaration.cpp | 2 - exml/internal/Declaration.h | 2 - exml/internal/Document.cpp | 2 - exml/internal/Document.h | 10 ++- exml/internal/Element.cpp | 2 - exml/internal/Element.h | 2 - exml/internal/Node.cpp | 2 - exml/internal/Node.h | 4 +- exml/internal/Text.cpp | 2 - exml/internal/Text.h | 2 - exml/iterator.h | 22 ++++-- exml/nodeType.cpp | 2 - exml/nodeType.h | 2 - lutin_exml-sample.py | 1 + monk_exml.py | 17 ----- sample/main.cpp | 2 - sample/read.cpp | 117 ++++++++++++++++++++++++++++-- sample/read.h | 2 - sample/read.xml | 8 ++ sample/write.cpp | 76 ++++++++++++++++++- sample/write.h | 2 - test/exmlTestAll.cpp | 2 - test/exmlTestAttribute.cpp | 2 - test/exmlTestComment.cpp | 2 - test/exmlTestCommon.cpp | 2 - test/exmlTestCommon.h | 2 - test/exmlTestDeclaration.cpp | 2 - test/exmlTestDeclarationXML.cpp | 2 - test/exmlTestElement.cpp | 2 - test/exmlTestParseAttribute.cpp | 2 - test/exmlTestParseComment.cpp | 2 - test/exmlTestParseDeclaration.cpp | 2 - test/exmlTestParseElement.cpp | 2 - test/main.cpp | 2 - 69 files changed, 566 insertions(+), 179 deletions(-) create mode 100644 doc/build.md delete mode 100644 doc/index.bb create mode 100644 doc/mainpage.md create mode 100644 doc/read.md delete mode 100644 doc/tutorial/000_Read.bb delete mode 100644 doc/tutorial/001_write.bb create mode 100644 doc/write.md delete mode 100644 monk_exml.py create mode 100644 sample/read.xml diff --git a/doc/build.md b/doc/build.md new file mode 100644 index 0000000..fda02c0 --- /dev/null +++ b/doc/build.md @@ -0,0 +1,66 @@ +Build lib & build sample {#exml_build} +======================== + +@tableofcontents + +Download: {#exml_build_download} +========= + +exml use some tools to manage source and build it: + +lutin (build-system): {#exml_build_download_lutin} +--------------------- + +```{.sh} + pip install lutin --user + # optionnal dependency of lutin (manage image changing size for application release) + pip install pillow --user +``` + + +dependency: {#exml_build_download_dependency} +----------- + +```{.sh} + mkdir framework + cd framework + git clone https://github.com/atria-soft/elog.git + git clone https://github.com/atria-soft/etk.git + git clone https://github.com/atria-soft/ememory.git + cd .. +``` + +sources: {#exml_build_download_sources} +-------- + +```{.sh} + cd framework + git clone https://github.com/atria-soft/exml.git + cd .. +``` + +Build: {#exml_build_build} +====== + + +library: {#exml_build_build_library} +-------- + +```{.sh} + lutin -mdebug exml +``` + +Sample: {#exml_build_build_sample} +------- + +```{.sh} + lutin -mdebug exml-sample +``` + + +Run sample: {#exml_build_run_sample} +=========== + +```{.sh} + lutin -mdebug exml-sample?run +``` diff --git a/doc/index.bb b/doc/index.bb deleted file mode 100644 index ba1ca1a..0000000 --- a/doc/index.bb +++ /dev/null @@ -1,28 +0,0 @@ -== [center]EXML library[/center] == -__________________________________________________ - -===What is EXML, and how can I use it?=== -EXML, or Ewol XML file interface, is a simple xml reader and writer. - -===What languages are supported?=== -EXML is written in C++. - - -===Are there any licensing restrictions?=== -EXML is [b]FREE software[/b] - - -==== License (APACHE-2.0) ==== -Copyright exml Edouard DUPIN - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/doc/mainpage.md b/doc/mainpage.md new file mode 100644 index 0000000..7f11df8 --- /dev/null +++ b/doc/mainpage.md @@ -0,0 +1,71 @@ +EXML library {#mainpage} +============ + +@tableofcontents + +What is EXML: {#exml_mainpage_what} +================== + +EXML, or Ewol XML interface is a simple, small, efficient, C++ XML parser/generator that can be easily integrating into other programs. + +What it does: {#exml_mainpage_what_it_does} +------------- + +EXML parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved. + +XML stands for "eXtensible Markup Language." It is a general purpose human and machine readable markup language to describe arbitrary data. +All those random file formats created to store application data can all be replaced with XML. One parser for everything. + +http://wikipedia.org/wiki/XML + +There are different ways to access and interact with XML data. +EXML uses a Document Object Model (DOM), meaning the XML data is parsed into a C++ objects that can be browsed and manipulated, and then written to disk. +You can also construct an XML document from scratch with C++ objects and write this to disk. + +EXML is designed to be easy and fast to learn. + +EXML is dependent of the STL (compatible with MacOs stl (CXX)) + +What it doesn't do: {#exml_mainpage_what_it_not_does} +------------------- + +EXML doesn't parse or use DTDs (Document Type Definitions) or XSLs (eXtensible Stylesheet Language). + +What languages are supported? {#exml_mainpage_language} +============================= + +EXML is written in C++. + + +Are there any licensing restrictions? {#exml_mainpage_license_restriction} +===================================== + +EXML is **FREE software** and _all sub-library are FREE and staticly linkable !!!_ + + +License (APACHE-2.0) {#exml_mainpage_license} +==================== + +Copyright EXML Edouard DUPIN + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +Other pages {#exml_mainpage_sub_page} +=========== + + - @ref exml_build + - @ref exml_tutorial_read + - @ref exml_tutorial_write + - [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html) + diff --git a/doc/read.md b/doc/read.md new file mode 100644 index 0000000..adf9283 --- /dev/null +++ b/doc/read.md @@ -0,0 +1,80 @@ +Read an XML content {#exml_tutorial_read} +=================== + +@tableofcontents + +The first thing to do when reading or writing a XML file/stream, is to declare the Document interface + +Include exml +@snippet read.cpp exml_sample_include + +Declare document interface +@snippet read.cpp exml_sample_declare_doc + + +Read an XML file {#exml_tutorial_read_file} +================ + +File to read: "read.xml" +@include read.xml + +Reading a file is done like this: +@snippet read.cpp exml_sample_read_file + +The file naming is manage by @ref etk::FSNode that provide "DATA:" start string for internal application asset. You can use external path like "./plop/file.xml" too. + + +Read an XML Stream {#exml_tutorial_read_stream} +================== + +Reading a file is done like this: +@snippet read.cpp exml_sample_read_stream1 + +In C and C++ it is very hard to read string with the \\" then to simplify parsing of xml the parser engine support the use of simple ' interface: +@snippet read.cpp exml_sample_read_stream2 + + +Access at all Element datas {#exml_tutorial_read_folow} +=========================== + +In an exml::Element (or exml::Document) the sub-nodes are accessible threw an abstraction class stores in an element name **nodes** + +Get a node with its name: +@snippet read.cpp exml_sample_read_get_node + +Reading all file nodes: +@snippet read.cpp exml_sample_read_folow_nodes + +**note:** the itElem is a simple exml::Node that can be all the xml type. you can change the type by calling: toDocument(), toElement(), toString() ... + +In a C style mode: +@snippet read.cpp exml_sample_read_folow_nodes_c + + + +In an exml::Element (or exml::Document or exml::Declaration) the sub-nodes are accessible threw an abstraction class stores in an element name **attributes** + +Reading all Attributes of one node: +@snippet read.cpp exml_sample_read_folow_attributes + +In a C style mode: +@snippet read.cpp exml_sample_read_folow_attributes_c + +Get an attribute data: +@snippet read.cpp exml_sample_read_get_direct_attribute + + + + +In an exml::Element (or exml::Document) the internal data text can be accessible threw the interface: + +Get all the data in an element in text mode: +@snippet read.cpp exml_sample_read_get_all_under_string + + + +All example file {#exml_tutorial_read_all} +================ + +@snippet read.cpp exml_sample_read_all + diff --git a/doc/tutorial/000_Read.bb b/doc/tutorial/000_Read.bb deleted file mode 100644 index e69de29..0000000 diff --git a/doc/tutorial/001_write.bb b/doc/tutorial/001_write.bb deleted file mode 100644 index e69de29..0000000 diff --git a/doc/write.md b/doc/write.md new file mode 100644 index 0000000..4c82b14 --- /dev/null +++ b/doc/write.md @@ -0,0 +1,61 @@ +Write an XML content {#exml_tutorial_write} +==================== + +@tableofcontents + +The first thing to do when reading or writing a XML file/stream, is to declare the Document interface + +Include exml +@snippet read.cpp exml_sample_include + +Declare document interface +@snippet read.cpp exml_sample_declare_doc + + +Write an XML file {#exml_tutorial_write_file} +================= + +Write an xml tree is done like: +@snippet write.cpp exml_sample_write_file + + +Write an XML Stream {#exml_tutorial_write_stream} +=================== + +Writing a stream is done like this: +@snippet write.cpp exml_sample_write_stream + +Operation on Tree {#exml_tutorial_write_operation} +================= + +Add Node/Declaration: +@snippet write.cpp exml_sample_write_add_declaration + +Add an Node/Element: +@snippet write.cpp exml_sample_write_add_element + +Remove a Node/Element: +@snippet write.cpp exml_sample_write_rm_node + + +Add an attribute (simple version): +@snippet write.cpp exml_sample_write_add_attribute_simple + +Add an attribute (complex version): +@snippet write.cpp exml_sample_write_add_attribute_complex + +Remove an attribute: +@snippet write.cpp exml_sample_write_rm_attribute + +Object concept {#exml_tutorial_concept} +============== + +the exml concept is to abstract the implementation of the internal system. All the element are maped on shared memory. +Then if you asign an element to an other, it is the same. You need to clone it if you want to have new standalone element. + + +All example file {#exml_tutorial_write_all} +================ + +@snippet write.cpp exml_sample_write_all + diff --git a/doxy_exml.py b/doxy_exml.py index e09941d..4b41eb4 100644 --- a/doxy_exml.py +++ b/doxy_exml.py @@ -14,6 +14,9 @@ def create(target, module_name): module_name, "doc" ]) + my_module.add_sample_path([ + "sample", + ]) my_module.add_module_depend([ 'elog', 'etk', diff --git a/exml/Attribute.cpp b/exml/Attribute.cpp index e113e4e..cd031c1 100644 --- a/exml/Attribute.cpp +++ b/exml/Attribute.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Attribute.h b/exml/Attribute.h index 3d90f0e..116baa6 100644 --- a/exml/Attribute.h +++ b/exml/Attribute.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -44,6 +42,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return Local reference on this object */ exml::Attribute& operator= (const exml::Attribute& _obj); public: diff --git a/exml/AttributeList.cpp b/exml/AttributeList.cpp index f32002a..ac05b84 100644 --- a/exml/AttributeList.cpp +++ b/exml/AttributeList.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/AttributeList.h b/exml/AttributeList.h index 90e8b63..976c120 100644 --- a/exml/AttributeList.h +++ b/exml/AttributeList.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -13,11 +11,17 @@ namespace exml { class AttributeList; - + /** + * @brief Abstract interface on all attributes elements + */ class AttributeListData { private: - exml::AttributeList* m_data; + exml::AttributeList* m_data; //!< Pointer on the Attribute list class (must not be nullptr) public: + /** + * @brief Constructor on the AttributeListData class + * @param[in] _list Point on the parrent class (must not be nullptr) + */ AttributeListData(exml::AttributeList* _list); public: /** @@ -74,10 +78,26 @@ namespace exml { */ void set(const std::string& _name, const std::string& _value); public: - using iterator = exml::iterator; + using iterator = exml::iterator; //!< Specify iterator of the element methode + /** + * @brief Get iterator of the first sub nodes + * @return iterator on the begin position of the nodes + */ iterator begin(); + /** + * @brief Get iterator of the next of the last sub nodes + * @return iterator on the next of the last position of the nodes + */ iterator end(); + /** + * @brief Get const iterator of the first sub nodes + * @return const iterator on the begin position of the nodes + */ const iterator begin() const; + /** + * @brief Get const iterator of the next of the last sub nodes + * @return const iterator on the next of the last position of the nodes + */ const iterator end() const; }; @@ -86,11 +106,11 @@ namespace exml { */ class AttributeList : public exml::Node { public: - AttributeListData attributes; + AttributeListData attributes; //!< interface on all attributes protected: /** * @brief basic element of a xml structure - * @param[in] _value value of the node + * @param[in] _internalNode Value of the node */ AttributeList(ememory::SharedPtr _internalNode); /** diff --git a/exml/Comment.cpp b/exml/Comment.cpp index 2bf6ac4..ed0a40b 100644 --- a/exml/Comment.cpp +++ b/exml/Comment.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Comment.h b/exml/Comment.h index 15e6fee..5655a03 100644 --- a/exml/Comment.h +++ b/exml/Comment.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -34,6 +32,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return A reference on the local Object */ exml::Comment& operator= (const exml::Comment& _obj); }; diff --git a/exml/Declaration.cpp b/exml/Declaration.cpp index daa815e..2991d7b 100644 --- a/exml/Declaration.cpp +++ b/exml/Declaration.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Declaration.h b/exml/Declaration.h index 58ff1ef..61b52a0 100644 --- a/exml/Declaration.h +++ b/exml/Declaration.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -34,6 +32,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return A reference on the local Object */ exml::Declaration& operator= (const exml::Declaration& _obj); }; @@ -62,6 +61,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return A reference on the local Object */ exml::DeclarationXML& operator= (const exml::DeclarationXML& _obj); }; diff --git a/exml/Document.cpp b/exml/Document.cpp index e1e09f8..3125e94 100644 --- a/exml/Document.cpp +++ b/exml/Document.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Document.h b/exml/Document.h index 799e22a..fd9e822 100644 --- a/exml/Document.h +++ b/exml/Document.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -33,6 +31,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return Reference on the local Object */ exml::Document& operator= (const exml::Document& _obj); /** diff --git a/exml/Element.cpp b/exml/Element.cpp index fe2a16a..f4dfb9f 100644 --- a/exml/Element.cpp +++ b/exml/Element.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Element.h b/exml/Element.h index c644621..7d2f42c 100644 --- a/exml/Element.h +++ b/exml/Element.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -16,11 +14,17 @@ namespace exml { /** * @brief Basic element Node of an XML document <YYYYY> + * @todo Remove node with a specisic ID/Iterator (erase) + * @todo Remove an Node with his exml::Element link */ class ElementData { private: - exml::Element* m_data; + exml::Element* m_data; //!< Pointer on the exml::Element class (must not be nullptr) public: + /** + * @brief constructor on the ElementData class + * @param[in] _list Get pointer on the exml::Element class (must not be nullptr) + */ ElementData(exml::Element* _list); public: /** @@ -69,10 +73,26 @@ namespace exml { */ const exml::Element operator[] (const std::string& _name) const; public: - using iterator = exml::iterator; + using iterator = exml::iterator; //!< Specify iterator of the element methode + /** + * @brief Get iterator of the first sub nodes + * @return iterator on the begin position of the nodes + */ iterator begin(); + /** + * @brief Get iterator of the next of the last sub nodes + * @return iterator on the next of the last position of the nodes + */ iterator end(); + /** + * @brief Get const iterator of the first sub nodes + * @return const iterator on the begin position of the nodes + */ const iterator begin() const; + /** + * @brief Get const iterator of the next of the last sub nodes + * @return const iterator on the next of the last position of the nodes + */ const iterator end() const; }; /** @@ -80,7 +100,7 @@ namespace exml { */ class Element : public exml::AttributeList { public: - ElementData nodes; + ElementData nodes; //!< All Sub-nodes interface public: /** * @brief Constructor @@ -100,6 +120,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return Local reference on this class */ exml::Element& operator= (const exml::Element& _obj); /** diff --git a/exml/FilePos.cpp b/exml/FilePos.cpp index 21f3de7..7b93a52 100644 --- a/exml/FilePos.cpp +++ b/exml/FilePos.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #include diff --git a/exml/FilePos.h b/exml/FilePos.h index b6d3c2f..44e86a5 100644 --- a/exml/FilePos.h +++ b/exml/FilePos.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/Node.cpp b/exml/Node.cpp index 9a47957..bc46493 100644 --- a/exml/Node.cpp +++ b/exml/Node.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Node.h b/exml/Node.h index c15b048..b8a51f0 100644 --- a/exml/Node.h +++ b/exml/Node.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -53,6 +51,8 @@ namespace exml { public: /** * @brief Check if the element exit + * @return true The element exist + * @return false The element does NOT exist */ bool exist() const; /** diff --git a/exml/Text.cpp b/exml/Text.cpp index 554ce28..d6ca016 100644 --- a/exml/Text.cpp +++ b/exml/Text.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/Text.h b/exml/Text.h index 869fcfd..a38d221 100644 --- a/exml/Text.h +++ b/exml/Text.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -34,6 +32,7 @@ namespace exml { /** * @brief Copy constructor * @param[in] _obj Object to copy + * @return A reference on this object */ exml::Text& operator= (const exml::Text& _obj); }; diff --git a/exml/debug.cpp b/exml/debug.cpp index b4f4533..4ffe837 100644 --- a/exml/debug.cpp +++ b/exml/debug.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/debug.h b/exml/debug.h index 8ec6a5e..8279ee0 100644 --- a/exml/debug.h +++ b/exml/debug.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/exml.h b/exml/exml.h index da0ec84..827e40a 100644 --- a/exml/exml.h +++ b/exml/exml.h @@ -1,11 +1,15 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once #include +#include +#include +#include +#include +#include +#include diff --git a/exml/internal/Attribute.cpp b/exml/internal/Attribute.cpp index 910e731..0dc6ccf 100644 --- a/exml/internal/Attribute.cpp +++ b/exml/internal/Attribute.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Attribute.h b/exml/internal/Attribute.h index 03e28fa..9392089 100644 --- a/exml/internal/Attribute.h +++ b/exml/internal/Attribute.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/internal/AttributeList.cpp b/exml/internal/AttributeList.cpp index a2dc72e..44caf7e 100644 --- a/exml/internal/AttributeList.cpp +++ b/exml/internal/AttributeList.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/AttributeList.h b/exml/internal/AttributeList.h index 51c4761..93e0698 100644 --- a/exml/internal/AttributeList.h +++ b/exml/internal/AttributeList.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/internal/Comment.cpp b/exml/internal/Comment.cpp index 6821463..722c834 100644 --- a/exml/internal/Comment.cpp +++ b/exml/internal/Comment.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Comment.h b/exml/internal/Comment.h index 1421a3f..97c9499 100644 --- a/exml/internal/Comment.h +++ b/exml/internal/Comment.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/internal/Declaration.cpp b/exml/internal/Declaration.cpp index 48a91d1..ed17013 100644 --- a/exml/internal/Declaration.cpp +++ b/exml/internal/Declaration.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Declaration.h b/exml/internal/Declaration.h index 36950f9..dd885b1 100644 --- a/exml/internal/Declaration.h +++ b/exml/internal/Declaration.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/internal/Document.cpp b/exml/internal/Document.cpp index 64d18b3..0879cce 100644 --- a/exml/internal/Document.cpp +++ b/exml/internal/Document.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Document.h b/exml/internal/Document.h index bd3635f..a2fbdd6 100644 --- a/exml/internal/Document.h +++ b/exml/internal/Document.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -122,6 +120,14 @@ namespace exml { } } +/** + * @brief Automatic create error on the basic Document object + * @param[in] doc Document reference + * @param[in] data main string parsed + * @param[in] pos Position in the file + * @param[in] filePos position in linre row in the file + * @param[in] comment Comment of the error find + */ #define CREATE_ERROR(doc,data,pos,filePos,comment) \ do { \ EXML_ERROR(comment); \ diff --git a/exml/internal/Element.cpp b/exml/internal/Element.cpp index 7f32cd6..390d046 100644 --- a/exml/internal/Element.cpp +++ b/exml/internal/Element.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Element.h b/exml/internal/Element.h index b52926e..dbe96f5 100644 --- a/exml/internal/Element.h +++ b/exml/internal/Element.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/internal/Node.cpp b/exml/internal/Node.cpp index b126ee2..69aa864 100644 --- a/exml/internal/Node.cpp +++ b/exml/internal/Node.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Node.h b/exml/internal/Node.h index 38f3359..31f2d7e 100644 --- a/exml/internal/Node.h +++ b/exml/internal/Node.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -21,11 +19,13 @@ namespace exml { //#define ENABLE_DISPLAY_PARSED_ELEMENT //#define ENABLE_CRITICAL_WHEN_ERROR #if 1 + //! manual debug element (when developpe exml) #define EXML_PARSE_ELEMENT EXML_VERBOSE #else #define EXML_PARSE_ELEMENT EXML_DEBUG #endif #if 1 + //! manual debug element (when developpe exml) #define EXML_PARSE_ATTRIBUTE EXML_VERBOSE #else #define EXML_PARSE_ATTRIBUTE EXML_DEBUG diff --git a/exml/internal/Text.cpp b/exml/internal/Text.cpp index e3194d7..7ec4f76 100644 --- a/exml/internal/Text.cpp +++ b/exml/internal/Text.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/internal/Text.h b/exml/internal/Text.h index 0a4c320..c9050c5 100644 --- a/exml/internal/Text.h +++ b/exml/internal/Text.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/exml/iterator.h b/exml/iterator.h index cef69fc..94f0e5f 100644 --- a/exml/iterator.h +++ b/exml/iterator.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once @@ -20,13 +18,27 @@ namespace exml { EXML_BASE_T& m_data; //!< Reference on the exml::Element size_t m_id; //!< Id of the element that we are parsing public: + /** + * @brief Constructor of the generic object class + * @param[in] _obj Reference on the object to go threw + * @param[in] _pos Position in the object + */ iterator(EXML_BASE_T& _obj, size_t _pos); + /** + * @brief Const constructor of the generic const object class + * @param[in] _obj Reference on the object to go threw + * @param[in] _pos Position in the object + */ iterator(const EXML_BASE_T& _obj, size_t _pos); + /** + * @brief Copy iterator + * @param[in] _obj Iterator to copy + */ iterator(const iterator& _obj); /** - * @brief Operator+= Addition value - * @param[in] _val Value to addition - * @return Local reference of the iterator additionned + * @brief Operator= Asignement iterator + * @param[in] _obj Iterator to copy + * @return Local reference of the iterator assigned */ iterator& operator= (const iterator& _obj); /** diff --git a/exml/nodeType.cpp b/exml/nodeType.cpp index 845ac71..02a2d63 100644 --- a/exml/nodeType.cpp +++ b/exml/nodeType.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/exml/nodeType.h b/exml/nodeType.h index 24befa2..74a30de 100644 --- a/exml/nodeType.h +++ b/exml/nodeType.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2011, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/lutin_exml-sample.py b/lutin_exml-sample.py index 83afab1..612cd3d 100644 --- a/lutin_exml-sample.py +++ b/lutin_exml-sample.py @@ -32,5 +32,6 @@ def create(target, module_name): 'sample/write.cpp' ]) my_module.add_module_depend(['exml', 'test-debug']) + my_module.copy_path('sample/read.xml') return my_module diff --git a/monk_exml.py b/monk_exml.py deleted file mode 100644 index 146c03d..0000000 --- a/monk_exml.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -import monkModule as module -import monkTools as tools - -def get_desc(): - return "e-xml XML parser and generator" - -def create(): - # module name is 'edn' and type binary. - myModule = module.Module(__file__, 'exml', 'LIBRARY') - # enable doculentation : - myModule.set_website("http://heeroyui.github.io/exml/") - myModule.set_website_sources("http://github.com/heeroyui/exml/") - myModule.set_path(tools.get_current_path(__file__) + "/exml/") - # add the currrent module at the - return myModule - diff --git a/sample/main.cpp b/sample/main.cpp index bbae787..e535cd9 100644 --- a/sample/main.cpp +++ b/sample/main.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2016, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/sample/read.cpp b/sample/read.cpp index 0c25e17..9980cb8 100644 --- a/sample/read.cpp +++ b/sample/read.cpp @@ -1,21 +1,62 @@ /** @file * @author Edouard DUPIN - * * @copyright 2016, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ +//! [exml_sample_read_all] #include +//! [exml_sample_include] #include +//! [exml_sample_include] #include "read.h" -void appl::read() { + +static void readFromFile() { + //! [exml_sample_declare_doc] + exml::Document doc; + //! [exml_sample_declare_doc] + //! [exml_sample_read_file] + bool retParse = doc.load("DATA:read.xml"); + //! [exml_sample_read_file] + TEST_INFO("parse ret = " << retParse); + TEST_INFO("Debug display of the tree:"); + doc.display(); +} + +static void readFromString1() { exml::Document doc; TEST_INFO("parse"); - bool retParse = doc.parse("" - "" - "coucou"); + //! [exml_sample_read_stream1] + std::string stream = "" + "" + "coucou"; + bool retParse = doc.parse(stream); + //! [exml_sample_read_stream1] + TEST_INFO("parse ret = " << retParse); + TEST_INFO("Debug display of the tree:"); + doc.display(); +} + +static void readFromString2() { + exml::Document doc; + TEST_INFO("parse"); + //! [exml_sample_read_stream2] + std::string stream = "" + "" + "coucou"; + bool retParse = doc.parse(stream); + //! [exml_sample_read_stream2] + TEST_INFO("parse ret = " << retParse); + TEST_INFO("Debug display of the tree:"); + doc.display(); +} + + +static void readFull() { + exml::Document doc; + TEST_INFO("parse"); + bool retParse = doc.load("DATA:read.xml"); TEST_INFO("parse ret = " << retParse); TEST_INFO("Debug display of the tree:"); doc.display(); @@ -34,7 +75,7 @@ void appl::read() { continue; } TEST_INFO(" list of attribute:"); - for (auto itElem: elem.attributes) { + for (const auto itElem: elem.attributes) { TEST_INFO(" " << itElem); } TEST_INFO(" list of sub-node:"); @@ -42,4 +83,66 @@ void appl::read() { TEST_INFO(" " << itElem); } } + TEST_INFO(" Direct get node exml:"); + //! [exml_sample_read_get_node] + exml::Element element = doc.nodes["exml"]; + //! [exml_sample_read_get_node] + TEST_INFO(" list of attribute:"); + //! [exml_sample_read_folow_attributes] + for (const auto itElem: element.attributes) { + std::string value = itElem.getValue(); + TEST_INFO(" '" << value << "'"); + } + TEST_INFO(" list of attribute in C:"); + //! [exml_sample_read_folow_attributes] + //! [exml_sample_read_folow_attributes_c] + for (size_t iii=0; iii + + + coucou + + + + \ No newline at end of file diff --git a/sample/write.cpp b/sample/write.cpp index 8fa30a7..0b1bd35 100644 --- a/sample/write.cpp +++ b/sample/write.cpp @@ -1,15 +1,83 @@ /** @file * @author Edouard DUPIN - * * @copyright 2016, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ +//! [exml_sample_write_all] #include #include #include "write.h" -void appl::write() { - + +static void writeToFile() { + exml::Document doc; + doc.nodes.add(exml::Declaration("2.5")); + doc.nodes.add(exml::Element("node1")); + doc.nodes.add(exml::Element("node2")); + doc.nodes.add(exml::Comment("basic comment")); + TEST_INFO("store"); + //! [exml_sample_write_file] + bool retGenerate = doc.store("generate.xml"); + //! [exml_sample_write_file] + TEST_INFO("parse ret = " << retGenerate); + TEST_INFO("Debug display of the tree:"); + doc.display(); } + +static void writeToString() { + exml::Document doc; + doc.nodes.add(exml::Declaration("2.5")); + doc.nodes.add(exml::Element("node1")); + doc.nodes.add(exml::Element("node2")); + doc.nodes.add(exml::Comment("basic comment")); + TEST_INFO("generate"); + //! [exml_sample_write_stream] + std::string streamOut; + bool retGenerate = doc.generate(streamOut); + //! [exml_sample_write_stream] + TEST_INFO("parse ret = " << retGenerate); + TEST_INFO("Debug display of the tree:"); + doc.display(); +} + +static void writeAll() { + exml::Document doc; + //! [exml_sample_write_add_declaration] + doc.nodes.add(exml::Declaration("2.5")); + //! [exml_sample_write_add_declaration] + //! [exml_sample_write_add_element] + exml::Element elem = exml::Element("exml"); + doc.nodes.add(elem); + //! [exml_sample_write_add_element] + + //! [exml_sample_write_add_attribute_simple] + elem.attributes.set("attr1", "value attr 1"); + //! [exml_sample_write_add_attribute_simple] + //! [exml_sample_write_add_attribute_complex] + elem.attributes.add(exml::Attribute("attr2", "value attr 2")); + //! [exml_sample_write_add_attribute_complex] + doc.display(); + + //! [exml_sample_write_rm_attribute] + elem.attributes.remove("attr1"); + //! [exml_sample_write_rm_attribute] + + elem.nodes.add(exml::Element("node1")); + elem.nodes.add(exml::Element("node2")); + elem.nodes.add(exml::Element("node1")); + + //! [exml_sample_write_rm_node] + // remove all node with this name + elem.nodes.remove("attr1"); + //! [exml_sample_write_rm_node] +} + + +void appl::write() { + writeToFile(); + writeToString(); + writeAll(); +} +//! [exml_sample_write_all] + diff --git a/sample/write.h b/sample/write.h index c93600d..daba8bd 100644 --- a/sample/write.h +++ b/sample/write.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2016, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestAll.cpp b/test/exmlTestAll.cpp index 729be43..aa117b9 100644 --- a/test/exmlTestAll.cpp +++ b/test/exmlTestAll.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestAttribute.cpp b/test/exmlTestAttribute.cpp index 3cc4bd9..9281f24 100644 --- a/test/exmlTestAttribute.cpp +++ b/test/exmlTestAttribute.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestComment.cpp b/test/exmlTestComment.cpp index dab3b49..8f7fe40 100644 --- a/test/exmlTestComment.cpp +++ b/test/exmlTestComment.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestCommon.cpp b/test/exmlTestCommon.cpp index c25a0de..57a3c77 100644 --- a/test/exmlTestCommon.cpp +++ b/test/exmlTestCommon.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestCommon.h b/test/exmlTestCommon.h index 929f8e3..5a9a63b 100644 --- a/test/exmlTestCommon.h +++ b/test/exmlTestCommon.h @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ #pragma once diff --git a/test/exmlTestDeclaration.cpp b/test/exmlTestDeclaration.cpp index 934f716..b283265 100644 --- a/test/exmlTestDeclaration.cpp +++ b/test/exmlTestDeclaration.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestDeclarationXML.cpp b/test/exmlTestDeclarationXML.cpp index e1c312d..b5811f6 100644 --- a/test/exmlTestDeclarationXML.cpp +++ b/test/exmlTestDeclarationXML.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestElement.cpp b/test/exmlTestElement.cpp index f2a65ea..50ffc66 100644 --- a/test/exmlTestElement.cpp +++ b/test/exmlTestElement.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestParseAttribute.cpp b/test/exmlTestParseAttribute.cpp index 94fe881..a949616 100644 --- a/test/exmlTestParseAttribute.cpp +++ b/test/exmlTestParseAttribute.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestParseComment.cpp b/test/exmlTestParseComment.cpp index ddd7209..76c0901 100644 --- a/test/exmlTestParseComment.cpp +++ b/test/exmlTestParseComment.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestParseDeclaration.cpp b/test/exmlTestParseDeclaration.cpp index 3a01f8a..eddf778 100644 --- a/test/exmlTestParseDeclaration.cpp +++ b/test/exmlTestParseDeclaration.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/exmlTestParseElement.cpp b/test/exmlTestParseElement.cpp index 344f6d5..b6e11f6 100644 --- a/test/exmlTestParseElement.cpp +++ b/test/exmlTestParseElement.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */ diff --git a/test/main.cpp b/test/main.cpp index 11bf062..9002a73 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,8 +1,6 @@ /** @file * @author Edouard DUPIN - * * @copyright 2014, Edouard DUPIN, all right reserved - * * @license APACHE v2.0 (see license file) */