[DOC] documentation finished

This commit is contained in:
Edouard DUPIN 2016-04-25 21:53:26 +02:00
parent a4f3eb7c9f
commit e98c82d380
69 changed files with 566 additions and 179 deletions

66
doc/build.md Normal file
View File

@ -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
```

View File

@ -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.

71
doc/mainpage.md Normal file
View File

@ -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
<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.
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)

80
doc/read.md Normal file
View File

@ -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

61
doc/write.md Normal file
View File

@ -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

View File

@ -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',

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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:

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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<exml::AttributeListData, exml::Attribute>;
using iterator = exml::iterator<exml::AttributeListData, exml::Attribute>; //!< 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<exml::internal::Node> _internalNode);
/**

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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);
};

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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);
};

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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);
/**

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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 &lt;YYYYY&gt;
* @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<exml::ElementData, exml::Node>;
using iterator = exml::iterator<exml::ElementData, exml::Node>; //!< 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);
/**

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <exml/FilePos.h>

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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;
/**

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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);
};

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -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 <exml/Document.h>
#include <exml/Node.h>
#include <exml/Element.h>
#include <exml/Attribute.h>
#include <exml/Declaration.h>
#include <exml/Comment.h>
#include <exml/Text.h>

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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); \

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -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);
/**

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -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

View File

@ -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

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2016, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -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 <test-debug/debug.h>
//! [exml_sample_include]
#include <exml/exml.h>
//! [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("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"
"<!-- my comment -->"
"<exml attributeExample=\"my data attribute\">coucou</exml>");
//! [exml_sample_read_stream1]
std::string stream = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"
"<!-- my comment -->"
"<exml attributeExample=\"my data attribute\">coucou</exml>";
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 = "<?xml version='1.0' encoding='UTF-8' standalone='true'?>"
"<!-- my comment -->"
"<exml attributeExample='my data attribute'>coucou</exml>";
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<element.attributes.size(); ++iii) {
const exml::Attribute attr = element.attributes[iii];
std::string value = attr.getValue();
TEST_INFO(" '" << value << "'");
}
//! [exml_sample_read_folow_attributes_c]
//! [exml_sample_read_get_direct_attribute]
std::string attributeValue = element.attributes["attributeExample"];
TEST_INFO(" direct get: '" << attributeValue << "'");
//! [exml_sample_read_get_direct_attribute]
TEST_INFO(" list of sub-node:");
//! [exml_sample_read_folow_nodes]
for (const auto itElem: element.nodes) {
if (itElem.isElement() == true) {
// get the <XXXX ... name
std::string value = itElem.toElement().getValue();
TEST_INFO(" '" << value << "'");
} else {
// simple debug for other type:
TEST_INFO(" ** " << itElem);
}
}
//! [exml_sample_read_folow_nodes]
TEST_INFO(" list of sub-node in C:");
//! [exml_sample_read_folow_nodes_c]
for (size_t iii=0; iii<element.nodes.size(); ++iii) {
const exml::Node node = element.nodes[iii];
if (node.isElement() == true) {
// get the <XXXX ... name
std::string value = node.toElement().getValue();
TEST_INFO(" '" << value << "'");
} else {
// simple debug for other type:
TEST_INFO(" ** " << node);
}
}
//! [exml_sample_read_folow_nodes_c]
//! [exml_sample_read_get_all_under_string]
std::string internalData = element.getText();
//! [exml_sample_read_get_all_under_string]
}
void appl::read() {
readFromFile();
readFromString1();
readFromString1();
readFull();
}
//! [exml_sample_read_all]

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2016, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

8
sample/read.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<!-- my comment -->
<exml attributeExample="my data attribute">
coucou
<!-- comment -->
<subNodeA/>
<subNodeB/>
</exml>

View File

@ -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 <test-debug/debug.h>
#include <exml/exml.h>
#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]

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2016, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/

View File

@ -1,8 +1,6 @@
/** @file
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/