Compare commits

...

17 Commits

68 changed files with 983 additions and 588 deletions

373
LICENSE Normal file
View File

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@ -61,15 +61,15 @@ Compile software:
lutin -C -P exml-test
License (APACHE v2.0)
License (MPL v2.0)
=====================
Copyright exml Edouard DUPIN
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Mozilla Public 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
https://www.mozilla.org/MPL/2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -26,7 +26,7 @@ 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}
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).
@ -43,16 +43,16 @@ Are there any licensing restrictions? {#exml_mainpage_license_restric
EXML is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
License (APACHE-2.0) {#exml_mainpage_license}
====================
License (MPL v2.0) {#exml_mainpage_license}
==================
Copyright EXML Edouard DUPIN
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Mozilla Public 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>
<https://www.mozilla.org/MPL/2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -21,7 +21,7 @@ File to read: "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.
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}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Attribute.hpp>
@ -10,12 +10,12 @@
exml::Attribute::Attribute(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::Node(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if (m_data->isAttribute() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -24,12 +24,12 @@ exml::Attribute::Attribute(const exml::Attribute& _obj) :
}
/*
exml::Attribute::Attribute(nullptr) :
exml::Node(nullptr) {
exml::Attribute::Attribute(null) :
exml::Node(null) {
}
*/
exml::Attribute::Attribute(const std::string& _name, const std::string& _value) :
exml::Attribute::Attribute(const etk::String& _name, const etk::String& _value) :
exml::Node() {
m_data = exml::internal::Attribute::create(_name, _value);
}
@ -39,37 +39,37 @@ exml::Attribute& exml::Attribute::operator= (const exml::Attribute& _obj) {
return *this;
}
void exml::Attribute::setName(const std::string& _name){
if (m_data == nullptr) {
EXML_DEBUG(" can not setName (nullptr) ...");
void exml::Attribute::setName(const etk::String& _name){
if (m_data == null) {
EXML_DEBUG(" can not setName (null) ...");
return;
}
static_cast<exml::internal::Attribute*>(m_data.get())->setName(_name);
}
const std::string& exml::Attribute::getName() const {
if (m_data == nullptr) {
static std::string errorValue = "";
EXML_DEBUG(" can not setName (nullptr) ...");
const etk::String& exml::Attribute::getName() const {
if (m_data == null) {
static etk::String errorValue = "";
EXML_DEBUG(" can not setName (null) ...");
return errorValue;
}
return static_cast<const exml::internal::Attribute*>(m_data.get())->getName();
}
void exml::Attribute::clear() {
if (m_data == nullptr) {
EXML_DEBUG(" can not setName (nullptr) ...");
if (m_data == null) {
EXML_DEBUG(" can not setName (null) ...");
return;
}
static_cast<exml::internal::Attribute*>(m_data.get())->clear();
}
std::pair<std::string, std::string> exml::Attribute::getPair() const {
if (m_data == nullptr) {
EXML_DEBUG(" can not setName (nullptr) ...");
return std::pair<std::string, std::string>("","");
etk::Pair<etk::String, etk::String> exml::Attribute::getPair() const {
if (m_data == null) {
EXML_DEBUG(" can not setName (null) ...");
return etk::Pair<etk::String, etk::String>("","");
}
return std::pair<std::string, std::string>(static_cast<const exml::internal::Attribute*>(m_data.get())->getName(),
return etk::Pair<etk::String, etk::String>(static_cast<const exml::internal::Attribute*>(m_data.get())->getName(),
static_cast<const exml::internal::Attribute*>(m_data.get())->getValue());
}

View File

@ -1,12 +1,13 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <etk/Pair.hpp>
namespace exml {
namespace internal {
@ -27,7 +28,7 @@ namespace exml {
* @brief Copy constructor
* @param[in] _obj Object to copy
*/
// TODO : Attribute(nullptr);
// TODO : Attribute(null);
/**
* @brief Copy constructor
* @param[in] _obj Object to copy
@ -38,7 +39,7 @@ namespace exml {
* @param[in] _name Name of the attribute.
* @param[in] _value Value of the attribute.
*/
Attribute(const std::string& _name="", const std::string& _value="");
Attribute(const etk::String& _name="", const etk::String& _value="");
/**
* @brief Copy constructor
* @param[in] _obj Object to copy
@ -50,17 +51,17 @@ namespace exml {
* @brief set the name of the attribute
* @param[in] _name New name of the attribute
*/
virtual void setName(const std::string& _name);
virtual void setName(const etk::String& _name);
/**
* @brief get the current name of the Attribute
* @return String of the attribute
*/
virtual const std::string& getName() const;
virtual const etk::String& getName() const;
/**
* @brief get attribute name and value
* @return Name and value of the attribute
*/
std::pair<std::string, std::string> getPair() const;
etk::Pair<etk::String, etk::String> getPair() const;
public:
void clear() override;
friend class exml::AttributeListData;

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/debug.hpp>
@ -27,7 +27,7 @@ exml::AttributeListData::AttributeListData(exml::AttributeList* _list) :
}
size_t exml::AttributeListData::size() const {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not sizeAttribute ...");
return 0;
}
@ -36,65 +36,65 @@ size_t exml::AttributeListData::size() const {
}
exml::Attribute exml::AttributeListData::operator[] (int32_t _id) {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttr (nullptr) ...");
return exml::Attribute(ememory::SharedPtr<exml::internal::Attribute>(nullptr));
if (m_data->m_data == null) {
EXML_DEBUG(" can not getAttr (null) ...");
return exml::Attribute(ememory::SharedPtr<exml::internal::Attribute>(null));
}
return exml::Attribute(static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttr(_id));
}
const exml::Attribute exml::AttributeListData::operator[] (int32_t _id) const {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttr (nullptr) ...");
return exml::Attribute(ememory::SharedPtr<exml::internal::Attribute>(nullptr));
if (m_data->m_data == null) {
EXML_DEBUG(" can not getAttr (null) ...");
return exml::Attribute(ememory::SharedPtr<exml::internal::Attribute>(null));
}
return exml::Attribute(static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttr(_id));
}
std::pair<std::string, std::string> exml::AttributeListData::getPair(int32_t _id) const {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttrPair (nullptr) ...");
return std::pair<std::string, std::string>("","");
etk::Pair<etk::String, etk::String> exml::AttributeListData::getPair(int32_t _id) const {
if (m_data->m_data == null) {
EXML_DEBUG(" can not getAttrPair (null) ...");
return etk::Pair<etk::String, etk::String>("","");
}
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttrPair(_id);
}
void exml::AttributeListData::add(exml::Attribute _attr) {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not appendAttribute (nullptr) ...");
if (m_data->m_data == null) {
EXML_DEBUG(" can not appendAttribute (null) ...");
return;
}
static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->appendAttribute(_attr.getInternalAttribute());
}
const std::string& exml::AttributeListData::operator[](const std::string& _name) const {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttribute (nullptr) ...");
static std::string errorValue("");
const etk::String& exml::AttributeListData::operator[](const etk::String& _name) const {
if (m_data->m_data == null) {
EXML_DEBUG(" can not getAttribute (null) ...");
static etk::String errorValue("");
return errorValue;
}
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttribute(_name);
}
bool exml::AttributeListData::exist(const std::string& _name) const {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttribute (nullptr) ...");
bool exml::AttributeListData::exist(const etk::String& _name) const {
if (m_data->m_data == null) {
EXML_DEBUG(" can not getAttribute (null) ...");
return false;
}
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->existAttribute(_name);
}
bool exml::AttributeListData::remove(const std::string& _name) {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not removeAttribute (nullptr) ...");
bool exml::AttributeListData::remove(const etk::String& _name) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not removeAttribute (null) ...");
return false;
}
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->removeAttribute(_name);
}
void exml::AttributeListData::set(const std::string& _name, const std::string& _value) {
if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not setAttribute (nullptr) ...");
void exml::AttributeListData::set(const etk::String& _name, const etk::String& _value) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not setAttribute (null) ...");
return;
}
static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->setAttribute(_name, _value);

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
@ -16,11 +16,11 @@ namespace exml {
*/
class AttributeListData {
private:
exml::AttributeList* m_data; //!< Pointer on the Attribute list class (must not be nullptr)
exml::AttributeList* m_data; //!< Pointer on the Attribute list class (must not be null)
public:
/**
* @brief Constructor on the AttributeListData class
* @param[in] _list Point on the parrent class (must not be nullptr)
* @param[in] _list Point on the parrent class (must not be null)
*/
AttributeListData(exml::AttributeList* _list);
public:
@ -40,7 +40,7 @@ namespace exml {
* @return true The attribute has been removed
* @return false An error occured.
*/
bool remove(const std::string& _name);
bool remove(const etk::String& _name);
/**
* @brief get attribute whith his ID
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
@ -58,25 +58,25 @@ namespace exml {
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
* @return Name and value of the attribute
*/
std::pair<std::string, std::string> getPair(int32_t _id) const;
etk::Pair<etk::String, etk::String> getPair(int32_t _id) const;
/**
* @brief get the attribute value with searching in the List with his name
* @param[in] _name Attribute Name.
* @return Value of the attribute or no data in the string
*/
const std::string& operator[](const std::string& _name) const;
const etk::String& operator[](const etk::String& _name) const;
/**
* @brief check if an attribute exist or not with his name.
* @param[in] _name Attribute Name.
* @return true if the attribute exist or False
*/
bool exist(const std::string& _name) const;
bool exist(const etk::String& _name) const;
/**
* @brief Set A new attribute or replace data of the previous one
* @param[in] _name Name of the attribute
* @param[in] _value Value of the attribute
*/
void set(const std::string& _name, const std::string& _value);
void set(const etk::String& _name, const etk::String& _value);
public:
using iterator = exml::iterator<exml::AttributeListData, exml::Attribute>; //!< Specify iterator of the element methode
/**

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Comment.hpp>
@ -10,12 +10,12 @@
exml::Comment::Comment(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::Node(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if (m_data->isComment() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -24,7 +24,7 @@ exml::Comment::Comment(const exml::Comment& _obj) :
}
exml::Comment::Comment(const std::string& _value) :
exml::Comment::Comment(const etk::String& _value) :
exml::Node() {
m_data = exml::internal::Comment::create(_value);
}

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
namespace exml {
/**
@ -28,7 +28,7 @@ namespace exml {
* @brief Constructor
* @param[in] _value comment value
*/
Comment(const std::string& _value="");
Comment(const etk::String& _value="");
/**
* @brief Copy constructor
* @param[in] _obj Object to copy

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Declaration.hpp>
@ -10,12 +10,12 @@
exml::Declaration::Declaration(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::AttributeList(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if (m_data->isDeclaration() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -24,7 +24,7 @@ exml::Declaration::Declaration(const exml::Declaration& _obj) :
}
exml::Declaration::Declaration(const std::string& _name) :
exml::Declaration::Declaration(const etk::String& _name) :
exml::AttributeList() {
m_data = exml::internal::Declaration::create();
}
@ -39,13 +39,13 @@ exml::Declaration& exml::Declaration::operator= (const exml::Declaration& _obj)
exml::DeclarationXML::DeclarationXML(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::Declaration(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
// TODO: Do it better
if (m_data->isDeclaration() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -54,7 +54,7 @@ exml::DeclarationXML::DeclarationXML(const exml::DeclarationXML& _obj) :
}
exml::DeclarationXML::DeclarationXML(const std::string& _version, const std::string& _format, bool _standalone) :
exml::DeclarationXML::DeclarationXML(const etk::String& _version, const etk::String& _format, bool _standalone) :
exml::Declaration() {
m_data = exml::internal::DeclarationXML::create(_version, _format, _standalone);
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
@ -28,7 +28,7 @@ namespace exml {
* @brief Constructor
* @param[in] _name name of the declaration (xml, xml:xxxx ...)
*/
Declaration(const std::string& _name="");
Declaration(const etk::String& _name="");
/**
* @brief Copy constructor
* @param[in] _obj Object to copy
@ -57,7 +57,7 @@ namespace exml {
* @param[in] _format charset of the XML
* @param[in] _standalone this document is standalone
*/
DeclarationXML(const std::string& _version="0.0", const std::string& _format = "UTF-8", bool _standalone = true);
DeclarationXML(const etk::String& _version="0.0", const etk::String& _format = "UTF-8", bool _standalone = true);
/**
* @brief Copy constructor
* @param[in] _obj Object to copy

View File

@ -1,21 +1,23 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Document.hpp>
#include <exml/debug.hpp>
#include <exml/internal/Document.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/uri/uri.hpp>
exml::Document::Document(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::Element(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if (m_data->isDocument() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -34,81 +36,126 @@ exml::Document& exml::Document::operator= (const exml::Document& _obj) {
return *this;
}
bool exml::Document::parse(const std::string& _data) {
if (m_data == nullptr) {
EXML_DEBUG("Can not parse (nullptr) ...");
bool exml::Document::parse(const etk::String& _data) {
if (m_data == null) {
EXML_DEBUG("Can not parse (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->parse(_data);
}
bool exml::Document::generate(std::string& _data) {
if (m_data == nullptr) {
EXML_DEBUG("Can not generate (nullptr) ...");
bool exml::Document::generate(etk::String& _data) {
if (m_data == null) {
EXML_DEBUG("Can not generate (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->generate(_data);
}
bool exml::Document::load(const std::string& _file) {
if (m_data == nullptr) {
EXML_DEBUG("Can not load (nullptr) ...");
bool exml::Document::load(const etk::Path& _path) {
if (m_data == null) {
EXML_DEBUG("Can not load (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->load(_file);
return static_cast<exml::internal::Document*>(m_data.get())->load(_path);
}
bool exml::Document::store(const std::string& _file) {
if (m_data == nullptr) {
EXML_DEBUG("Can not store (nullptr) ...");
bool exml::Document::load(const etk::Uri& _uri) {
if (m_data == null) {
EXML_DEBUG("Can not load (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->store(_file);
return static_cast<exml::internal::Document*>(m_data.get())->load(_uri);
}
bool exml::Document::store(const etk::Path& _path) {
if (m_data == null) {
EXML_DEBUG("Can not store (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->store(_path);
}
bool exml::Document::store(const etk::Uri& _uri) {
if (m_data == null) {
EXML_DEBUG("Can not store (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->store(_uri);
}
bool exml::Document::storeSafe(const etk::Path& _path) {
if (m_data == null) {
EXML_DEBUG("Can not store (null) ...");
return false;
}
bool done = static_cast<exml::internal::Document*>(m_data.get())->store(_path+".tmp");
if (done == false) {
return false;
}
return etk::path::move(_path+".tmp", _path);
}
bool exml::Document::storeSafe(const etk::Uri& _uri) {
if (m_data == null) {
EXML_DEBUG("Can not store (null) ...");
return false;
}
if (etk::uri::canMove(_uri) == false) {
return static_cast<exml::internal::Document*>(m_data.get())->store(_uri);
}
etk::Uri uriTmp = _uri;
uriTmp.setPath(uriTmp.getPath() + ".tmp");
bool done = static_cast<exml::internal::Document*>(m_data.get())->store(uriTmp);
if (done == false) {
return false;
}
return etk::uri::move(uriTmp, _uri);
}
void exml::Document::display() {
if (m_data == nullptr) {
EXML_DEBUG("Can not display (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not display (null) ...");
return;
}
static_cast<exml::internal::Document*>(m_data.get())->display();
}
void exml::Document::setCaseSensitive(bool _val) {
if (m_data == nullptr) {
EXML_DEBUG("Can not setCaseSensitive (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not setCaseSensitive (null) ...");
return;
}
static_cast<exml::internal::Document*>(m_data.get())->setCaseSensitive(_val);
}
bool exml::Document::getCaseSensitive() const {
if (m_data == nullptr) {
EXML_DEBUG("Can not getCaseSensitive (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not getCaseSensitive (null) ...");
return false;
}
return static_cast<const exml::internal::Document*>(m_data.get())->getCaseSensitive();
}
void exml::Document::setDisplayError(bool _value){
if (m_data == nullptr) {
EXML_DEBUG("Can not setDisplayError (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not setDisplayError (null) ...");
return;
}
static_cast<exml::internal::Document*>(m_data.get())->setDisplayError(_value);
}
bool exml::Document::getDisplayError() {
if (m_data == nullptr) {
EXML_DEBUG("Can not getDisplayError (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not getDisplayError (null) ...");
return false;
}
return static_cast<exml::internal::Document*>(m_data.get())->getDisplayError();
}
void exml::Document::displayError() {
if (m_data == nullptr) {
EXML_DEBUG("Can not displayError (nullptr) ...");
if (m_data == null) {
EXML_DEBUG("Can not displayError (null) ...");
return;
}
static_cast<exml::internal::Document*>(m_data.get())->displayError();

View File

@ -1,12 +1,13 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/Element.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <etk/uri/uri.hpp>
namespace exml {
/**
@ -51,28 +52,41 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool parse(const std::string& _data);
bool parse(const etk::String& _data);
/**
* @brief generate a string that contain the created XML
* @param[out] _data Data where the xml is stored
* @return false : An error occured
* @return true : Parsing is OK
*/
bool generate(std::string& _data);
bool generate(etk::String& _data);
/**
* @brief Load the file that might contain the xml
* @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @param[in] _path/_uri Path/URI of the xml
* @return false : An error occured
* @return true : Parsing is OK
*/
bool load(const std::string& _file);
bool load(const etk::Path& _path);
/// @previous
bool load(const etk::Uri& _uri);
/**
* @brief Store the Xml in the file
* @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @param[in] _path/_uri Path/URI of the xml
* @return false : An error occured
* @return true : Parsing is OK
*/
bool store(const std::string& _file);
bool store(const etk::Path& _path);
/// @previous
bool store(const etk::Uri& _uri);
/**
* @brief Store the Json in the file (safe mode mean that the file is store in a second file xxx.tmp and moved in the file xxx (only one mode to be really safe with filesystem ...)
* @param[in] _path/_uri Path/URI of the json
* @return false : An error occured
* @return true : Parsing is OK
*/
bool storeSafe(const etk::Path& _path);
/// @previous
bool storeSafe(const etk::Uri& _uri);
/**
* @brief Display the Document on console
*/

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Element.hpp>
@ -12,13 +12,13 @@
exml::Element::Element(const ememory::SharedPtr<exml::internal::Node>& _internalNode) :
exml::AttributeList(_internalNode),
nodes(this) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if ( m_data->isElement() == false
&& m_data->isDocument() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -28,7 +28,7 @@ exml::Element::Element(const exml::Element& _obj) :
}
exml::Element::Element(const std::string& _data) :
exml::Element::Element(const etk::String& _data) :
exml::AttributeList(),
nodes(this) {
m_data = exml::internal::Element::create(_data);
@ -61,7 +61,7 @@ exml::ElementData::ElementData(exml::Element* _elem) :
}
size_t exml::ElementData::size() const {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return 0;
}
@ -69,7 +69,7 @@ size_t exml::ElementData::size() const {
}
enum exml::nodeType exml::ElementData::getType(int32_t _id) const {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return exml::nodeType::unknow;
}
@ -77,7 +77,7 @@ enum exml::nodeType exml::ElementData::getType(int32_t _id) const {
}
exml::Node exml::ElementData::operator[](int32_t _id) {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return exml::Node();
}
@ -85,23 +85,23 @@ exml::Node exml::ElementData::operator[](int32_t _id) {
}
const exml::Node exml::ElementData::operator[](int32_t _id) const {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return exml::Node();
}
return exml::Node(static_cast<const exml::internal::Element*>(m_data->m_data.get())->getNode(_id));
}
exml::Element exml::ElementData::operator[](const std::string& _name) {
if (m_data->m_data == nullptr) {
exml::Element exml::ElementData::operator[](const etk::String& _name) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return exml::Element();
}
return exml::Element(static_cast<exml::internal::Element*>(m_data->m_data.get())->getNamed(_name));
}
const exml::Element exml::ElementData::operator[] (const std::string& _name) const {
if (m_data->m_data == nullptr) {
const exml::Element exml::ElementData::operator[] (const etk::String& _name) const {
if (m_data->m_data == null) {
EXML_DEBUG(" can not get type ...");
return exml::Element();
}
@ -109,23 +109,23 @@ const exml::Element exml::ElementData::operator[] (const std::string& _name) con
}
void exml::ElementData::add(const exml::Node& _node) {
if (m_data->m_data == nullptr) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not APPEND on null element ...");
return;
}
static_cast<exml::internal::Element*>(m_data->m_data.get())->append(_node.m_data);
}
void exml::ElementData::remove(const std::string& _nodeName) {
if (m_data->m_data == nullptr) {
void exml::ElementData::remove(const etk::String& _nodeName) {
if (m_data->m_data == null) {
EXML_DEBUG(" can not APPEND on null element ...");
return;
}
static_cast<exml::internal::Element*>(m_data->m_data.get())->remove(_nodeName);
}
std::string exml::Element::getText() const {
if (m_data == nullptr) {
etk::String exml::Element::getText() const {
if (m_data == null) {
EXML_DEBUG(" can not APPEND on null element ...");
return "";
}
@ -133,7 +133,7 @@ std::string exml::Element::getText() const {
}
void exml::Element::clear() {
if (m_data == nullptr) {
if (m_data == null) {
EXML_DEBUG(" can not CLEAR on null element ...");
return;
}

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <exml/AttributeList.hpp>
#include <exml/iterator.hpp>
@ -19,11 +19,11 @@ namespace exml {
*/
class ElementData {
private:
exml::Element* m_data; //!< Pointer on the exml::Element class (must not be nullptr)
exml::Element* m_data; //!< Pointer on the exml::Element class (must not be null)
public:
/**
* @brief constructor on the ElementData class
* @param[in] _list Get pointer on the exml::Element class (must not be nullptr)
* @param[in] _list Get pointer on the exml::Element class (must not be null)
*/
ElementData(exml::Element* _list);
public:
@ -41,7 +41,7 @@ namespace exml {
* @brief Remove a node with his name.
* @param[in] _nodeName Name of the node.
*/
void remove(const std::string& _nodeName);
void remove(const etk::String& _nodeName);
/**
* @brief get the type of the element id.
* @param[in] _id Id of the element.
@ -65,13 +65,13 @@ namespace exml {
* @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL.
*/
exml::Element operator[] (const std::string& _name);
exml::Element operator[] (const etk::String& _name);
/**
* @brief get an element with his name (work only with exml::Element)
* @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL.
*/
const exml::Element operator[] (const std::string& _name) const;
const exml::Element operator[] (const etk::String& _name) const;
public:
using iterator = exml::iterator<exml::ElementData, exml::Node>; //!< Specify iterator of the element methode
/**
@ -116,7 +116,7 @@ namespace exml {
* @brief Constructor
* @param[in] _value Element name;
*/
Element(const std::string& _value="");
Element(const etk::String& _value="");
/**
* @brief Copy constructor
* @param[in] _obj Object to copy
@ -127,7 +127,7 @@ namespace exml {
* @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...
*/
std::string getText() const;
etk::String getText() const;
public:
void clear() override;
};

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/FilePos.hpp>
@ -82,7 +82,7 @@ size_t exml::FilePos::getLine() const {
return m_line;
}
std::ostream& exml::operator <<(std::ostream& _os, const exml::FilePos& _obj) {
etk::Stream& exml::operator <<(etk::Stream& _os, const exml::FilePos& _obj) {
_os << "(l=";
_os << _obj.getLine();
_os << ",c=";

View File

@ -1,11 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/Stream.hpp>
namespace exml {
/**
@ -87,7 +88,7 @@ namespace exml {
size_t getLine() const;
};
//! @not-in-doc
std::ostream& operator <<(std::ostream& _os, const FilePos& _obj);
etk::Stream& operator <<(etk::Stream& _os, const FilePos& _obj);
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Node.hpp>
@ -14,7 +14,7 @@
#include <exml/Element.hpp>
#include <exml/Text.hpp>
std::ostream& exml::operator <<(std::ostream& _os, const exml::Node& _obj) {
etk::Stream& exml::operator <<(etk::Stream& _os, const exml::Node& _obj) {
_os << "{";
_os << "Node XML: " << _obj.getType();
if (_obj.isElement() == true) {
@ -31,35 +31,35 @@ exml::Node::Node(const ememory::SharedPtr<exml::internal::Node>& _internalNode)
}
exml::Node::Node() :
m_data(nullptr) {
m_data(null) {
}
bool exml::Node::exist() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return true;
}
exml::FilePos exml::Node::getPos() const {
if (m_data == nullptr) {
if (m_data == null) {
return exml::FilePos(0,0);
}
return m_data->getPos();
}
void exml::Node::setValue(std::string _value) {
if (m_data == nullptr) {
void exml::Node::setValue(etk::String _value) {
if (m_data == null) {
EXML_ERROR(" can not set value: '" << _value << "'");
return;
}
m_data->setValue(_value);
}
const std::string& exml::Node::getValue() const {
if (m_data == nullptr) {
static std::string errorString = "";
const etk::String& exml::Node::getValue() const {
if (m_data == null) {
static etk::String errorString = "";
EXML_DEBUG(" can not get value ...");
return errorString;
}
@ -67,7 +67,7 @@ const std::string& exml::Node::getValue() const {
}
enum exml::nodeType exml::Node::getType() const {
if (m_data == nullptr) {
if (m_data == null) {
EXML_DEBUG("Can not get type ...");
return exml::nodeType::unknow;
}
@ -123,49 +123,49 @@ const exml::Text exml::Node::toText() const {
}
bool exml::Node::isDocument() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isDocument();
}
bool exml::Node::isAttribute() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isAttribute();
}
bool exml::Node::isComment() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isComment();
}
bool exml::Node::isDeclaration() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isDeclaration();
}
bool exml::Node::isElement() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isElement() || m_data->isDocument();
}
bool exml::Node::isText() const {
if (m_data == nullptr) {
if (m_data == null) {
return false;
}
return m_data->isText();
}
void exml::Node::clear() {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
return m_data->clear();

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
@ -64,12 +64,12 @@ namespace exml {
* @brief set the value of the node.
* @param[in] _value New value of the node.
*/
virtual void setValue(std::string _value);
virtual void setValue(etk::String _value);
/**
* @brief get the current element Value.
* @return the reference of the string value.
*/
const std::string& getValue() const;
const etk::String& getValue() const;
/**
* @brief get the node type.
* @return the type of the Node.
@ -77,62 +77,62 @@ namespace exml {
enum nodeType getType() const;
/**
* @brief Cast the element in a Document if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Document toDocument();
/**
* @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 null.
*/
const exml::Document toDocument() const;
/**
* @brief Cast the element in a Attribute if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Attribute toAttribute();
/**
* @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 null.
*/
const exml::Attribute toAttribute() const;
/**
* @brief Cast the element in a Comment if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Comment toComment();
/**
* @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 null.
*/
const exml::Comment toComment() const;
/**
* @brief Cast the element in a Declaration if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Declaration toDeclaration();
/**
* @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 null.
*/
const exml::Declaration toDeclaration() const;
/**
* @brief Cast the element in a Element if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Element toElement();
/**
* @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 null.
*/
const exml::Element toElement() const;
/**
* @brief Cast the element in a Text if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
exml::Text toText();
/**
* @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 null.
*/
const exml::Text toText() const;
/**
@ -171,5 +171,5 @@ namespace exml {
virtual void clear();
};
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const exml::Node& _obj);
etk::Stream& operator <<(etk::Stream& _os, const exml::Node& _obj);
}

View File

@ -1,22 +1,21 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/Text.hpp>
#include <exml/internal/Text.hpp>
#include <exml/debug.hpp>
#include <regex>
exml::Text::Text(ememory::SharedPtr<exml::internal::Node> _internalNode) :
exml::Node(_internalNode) {
if (m_data == nullptr) {
if (m_data == null) {
return;
}
if (m_data->isText() == false) {
// try to set wrong type inside ... ==> remove it ...
m_data = nullptr;
m_data = null;
}
}
@ -25,7 +24,7 @@ exml::Text::Text(const exml::Text& _obj) :
}
exml::Text::Text(const std::string& _data) :
exml::Text::Text(const etk::String& _data) :
exml::Node() {
m_data = exml::internal::Text::create(_data);
}

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
namespace exml {
/**
@ -28,7 +28,7 @@ namespace exml {
* @brief Constructor
* @param[in] _data String data of the current Text
*/
Text(const std::string& _data="");
Text(const etk::String& _data="");
/**
* @brief Copy constructor
* @param[in] _obj Object to copy

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/debug.hpp>

View File

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

View File

@ -3,7 +3,7 @@
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/iterator.hpp>
@ -11,28 +11,28 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(EXML_BASE_T& _obj, size_t _pos) :
m_data(_obj),
m_id(_pos) {
m_id = std::avg(size_t(0), m_id, m_data.size());
m_id = etk::avg(size_t(0), m_id, m_data.size());
}
template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const EXML_BASE_T& _obj, size_t _pos) :
m_data(const_cast<EXML_BASE_T&>(_obj)),
m_id(_pos) {
m_id = std::avg(size_t(0), m_id, m_data.size());
m_id = etk::avg(size_t(0), m_id, m_data.size());
}
template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) :
m_data(_obj.m_data),
m_id(_obj.m_id) {
m_id = std::avg(size_t(0), m_id, m_data.size());
m_id = etk::avg(size_t(0), m_id, m_data.size());
}
template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator= (const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) {
m_data = _obj.m_data;
m_id = _obj.m_id;
m_id = std::avg(size_t(0), m_id, m_data.size());
m_id = etk::avg(size_t(0), m_id, m_data.size());
return *this;
}
@ -40,7 +40,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator+= (int32_t _val) {
int64_t val = m_id;
val += _val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size()));
m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this;
}
@ -55,7 +55,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator-= (int32_t _val) {
int64_t val = m_id;
val -= _val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size()));
m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this;
}
@ -70,7 +70,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator++() {
int64_t val = m_id;
++val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size()));
m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this;
}
@ -85,7 +85,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator--() {
int64_t val = m_id;
--val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size()));
m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this;
}

View File

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

View File

@ -1,24 +1,24 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Attribute.hpp>
#include <exml/debug.hpp>
#include <exml/internal/Document.hpp>
ememory::SharedPtr<exml::internal::Attribute> exml::internal::Attribute::create(const std::string& _name, const std::string& _value) {
return ememory::SharedPtr<exml::internal::Attribute>(new exml::internal::Attribute(_name, _value));
ememory::SharedPtr<exml::internal::Attribute> exml::internal::Attribute::create(const etk::String& _name, const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Attribute>(ETK_NEW(exml::internal::Attribute, _name, _value));
}
exml::internal::Attribute::Attribute(const std::string& _name, const std::string& _value) :
exml::internal::Attribute::Attribute(const etk::String& _name, const etk::String& _value) :
exml::internal::Node(_value),
m_name(_name) {
}
bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
bool exml::internal::Attribute::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
EXML_VERBOSE("start parse : 'attribute'");
m_pos = _filePos;
// search end of the comment :
@ -34,9 +34,9 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break;
}
}
m_name = std::string(_data, _pos, lastElementName+1-(_pos));
m_name = etk::String(_data, _pos, lastElementName+1-(_pos));
if (_caseSensitive == true) {
m_name = etk::tolower(m_name);
m_name = etk::toLower(m_name);
}
// count white space :
exml::FilePos tmpPos;
@ -83,7 +83,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break;
}
}
m_value = std::string(_data, lastElementName+white+2, lastAttributePos-(lastElementName+white+2));
m_value = etk::String(_data, lastElementName+white+2, lastAttributePos-(lastElementName+white+2));
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -103,7 +103,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break;
}
}
m_value = std::string(_data, lastElementName+white+3, lastAttributePos-(lastElementName+white+3));
m_value = etk::String(_data, lastElementName+white+3, lastAttributePos-(lastElementName+white+3));
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -111,7 +111,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
return true;
}
bool exml::internal::Attribute::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Attribute::iGenerate(etk::String& _data, int32_t _indent) const {
_data += " ";
_data += m_name;
_data += "=\"";

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
namespace exml {
namespace internal {
@ -20,7 +20,7 @@ namespace exml {
* @param[in] _name Name of the attribute.
* @param[in] _value Value of the attribute.
*/
Attribute(const std::string& _name="", const std::string& _value="");
Attribute(const etk::String& _name="", const etk::String& _value="");
public:
/**
* @brief defined factory
@ -28,30 +28,30 @@ namespace exml {
* @param[in] _value Value of the attribute
* @return Shared pointer on the Attribute element
*/
static ememory::SharedPtr<Attribute> create(const std::string& _name="", const std::string& _value="");
static ememory::SharedPtr<Attribute> create(const etk::String& _name="", const etk::String& _value="");
protected:
std::string m_name; //!< Name of the attribute
etk::String m_name; //!< Name of the attribute
public:
/**
* @brief set the name of the attribute
* @param[in] _name New name of the attribute
*/
virtual void setName(const std::string& _name) {
virtual void setName(const etk::String& _name) {
m_name = _name;
};
/**
* @brief get the current name of the Attribute
* @return String of the attribute
*/
virtual const std::string& getName() const {
virtual const etk::String& getName() const {
return m_name;
};
public:
enum nodeType getType() const override {
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;
bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Attribute> toAttribute() override {
return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis());
};

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/AttributeList.hpp>
@ -10,7 +10,7 @@
ememory::SharedPtr<exml::internal::Attribute> exml::internal::AttributeList::getAttr(int32_t _id) {
if ( _id < 0
|| size_t(_id) >= m_listAttribute.size()) {
return nullptr;
return null;
}
return m_listAttribute[_id];
}
@ -18,22 +18,22 @@ ememory::SharedPtr<exml::internal::Attribute> exml::internal::AttributeList::get
ememory::SharedPtr<const exml::internal::Attribute> exml::internal::AttributeList::getAttr(int32_t _id) const {
if ( _id < 0
|| size_t(_id) >= m_listAttribute.size()) {
return nullptr;
return null;
}
return m_listAttribute[_id];
}
std::pair<std::string, std::string> exml::internal::AttributeList::getAttrPair(int32_t _id) const {
etk::Pair<etk::String, etk::String> exml::internal::AttributeList::getAttrPair(int32_t _id) const {
ememory::SharedPtr<const exml::internal::Attribute> att = getAttr(_id);
if (att == nullptr) {
return std::make_pair<std::string, std::string>("","");
if (att == null) {
return etk::makePair<etk::String, etk::String>("","");
}
return std::make_pair(att->getName(),att->getValue());
return etk::makePair(att->getName(),att->getValue());
}
void exml::internal::AttributeList::appendAttribute(const ememory::SharedPtr<exml::internal::Attribute>& _attr) {
if (_attr == nullptr) {
if (_attr == null) {
EXML_ERROR("Try to set an empty node");
return;
}
@ -43,16 +43,16 @@ void exml::internal::AttributeList::appendAttribute(const ememory::SharedPtr<exm
return;
}
}
m_listAttribute.push_back(_attr);
m_listAttribute.pushBack(_attr);
}
const std::string& exml::internal::AttributeList::getAttribute(const std::string& _name) const {
static const std::string errorReturn("");
const etk::String& exml::internal::AttributeList::getAttribute(const etk::String& _name) const {
static const etk::String errorReturn("");
if (_name.size() == 0) {
return errorReturn;
}
for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if( m_listAttribute[iii] != nullptr
if( m_listAttribute[iii] != null
&& m_listAttribute[iii]->getName() == _name) {
return m_listAttribute[iii]->getValue();
}
@ -61,12 +61,12 @@ const std::string& exml::internal::AttributeList::getAttribute(const std::string
}
bool exml::internal::AttributeList::existAttribute(const std::string& _name) const {
bool exml::internal::AttributeList::existAttribute(const etk::String& _name) const {
if (_name.size() == 0) {
return false;
}
for (size_t iii=0; iii<m_listAttribute.size(); ++iii) {
if( m_listAttribute[iii] != nullptr
if( m_listAttribute[iii] != null
&& m_listAttribute[iii]->getName() == _name) {
return true;
}
@ -74,13 +74,13 @@ bool exml::internal::AttributeList::existAttribute(const std::string& _name) con
return false;
}
bool exml::internal::AttributeList::removeAttribute(const std::string& _name) {
bool exml::internal::AttributeList::removeAttribute(const etk::String& _name) {
if (_name.size() == 0) {
return false;
}
auto it = m_listAttribute.begin();
while (it != m_listAttribute.end()) {
if (*it == nullptr) {
if (*it == null) {
it = m_listAttribute.erase(it);
continue;
}
@ -93,10 +93,10 @@ bool exml::internal::AttributeList::removeAttribute(const std::string& _name) {
return false;
}
void exml::internal::AttributeList::setAttribute(const std::string& _name, const std::string& _value) {
void exml::internal::AttributeList::setAttribute(const etk::String& _name, const etk::String& _value) {
// check if attribute already det :
for (size_t iii=0; iii<m_listAttribute.size(); ++iii) {
if( m_listAttribute[iii] != nullptr
if( m_listAttribute[iii] != null
&& m_listAttribute[iii]->getName() == _name) {
// update the value :
m_listAttribute[iii]->setValue(_value);
@ -104,15 +104,15 @@ void exml::internal::AttributeList::setAttribute(const std::string& _name, const
}
}
ememory::SharedPtr<exml::internal::Attribute> attr = exml::internal::Attribute::create(_name, _value);
if (attr == nullptr) {
if (attr == null) {
EXML_ERROR("memory allocation error...");
}
m_listAttribute.push_back(attr);
m_listAttribute.pushBack(attr);
}
bool exml::internal::AttributeList::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::AttributeList::iGenerate(etk::String& _data, int32_t _indent) const {
for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if (m_listAttribute[iii] != nullptr) {
if (m_listAttribute[iii] != null) {
m_listAttribute[iii]->iGenerate(_data, _indent);
}
}

View File

@ -1,14 +1,14 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <exml/internal/Attribute.hpp>
#include <utility>
#include <etk/Pair.hpp>
namespace exml {
namespace internal {
@ -21,12 +21,12 @@ namespace exml {
* @brief Constructor
* @param[in] _value Node value;
*/
AttributeList(const std::string& _value="") :
AttributeList(const etk::String& _value="") :
exml::internal::Node(_value) {
};
protected:
std::vector<ememory::SharedPtr<exml::internal::Attribute>> m_listAttribute; //!< list of all attribute
etk::Vector<ememory::SharedPtr<exml::internal::Attribute>> m_listAttribute; //!< list of all attribute
public:
/**
* @brief get the number of attribute in the Node
@ -57,34 +57,34 @@ namespace exml {
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
* @return Name and value of the attribute
*/
std::pair<std::string, std::string> getAttrPair(int32_t _id) const;
etk::Pair<etk::String, etk::String> getAttrPair(int32_t _id) const;
/**
* @brief get the attribute value with searching in the List with his name
* @param[in] _name Attribute Name.
* @return Value of the attribute or no data in the string
*/
const std::string& getAttribute(const std::string& _name) const;
const etk::String& getAttribute(const etk::String& _name) const;
/**
* @brief check if an attribute exist or not with his name.
* @param[in] _name Attribute Name.
* @return true if the attribute exist or False
*/
bool existAttribute(const std::string& _name) const;
bool existAttribute(const etk::String& _name) const;
/**
* @brief Set A new attribute or replace data of the previous one
* @param[in] _name Name of the attribute
* @param[in] _value Value of the attribute
*/
void setAttribute(const std::string& _name, const std::string& _value);
void setAttribute(const etk::String& _name, const etk::String& _value);
/**
* @brief Remove an attribute form the list
* @param[in] _name Name of the attribute
* @return true The attribute has been removed
* @return false An error occured.
*/
bool removeAttribute(const std::string& _name);
bool removeAttribute(const etk::String& _name);
public:
bool iGenerate(std::string& _data, int32_t _indent) const override;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
void clear() override;
};
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Comment.hpp>
@ -18,11 +18,11 @@ static bool isWhiteChar(char32_t _val) {
return false;
}
ememory::SharedPtr<exml::internal::Comment> exml::internal::Comment::create(const std::string& _value) {
return ememory::SharedPtr<exml::internal::Comment>(new exml::internal::Comment(_value));
ememory::SharedPtr<exml::internal::Comment> exml::internal::Comment::create(const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Comment>(ETK_NEW(exml::internal::Comment, _value));
}
bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
bool exml::internal::Comment::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
EXML_VERBOSE("start parse : 'comment'");
m_pos = _filePos;
exml::FilePos tmpPos;
@ -50,7 +50,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo
}
}
// find end of value:
m_value = std::string(_data, _pos+white, newEnd-(_pos+white));
m_value = etk::String(_data, _pos+white, newEnd-(_pos+white));
EXML_VERBOSE(" find comment '" << m_value << "'");
_pos = iii+2;
return true;
@ -61,7 +61,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo
return false;
}
bool exml::internal::Comment::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Comment::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent);
_data += "<!--";
_data += m_value;

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
namespace exml {
namespace internal {
@ -20,12 +20,12 @@ namespace exml {
* @return Shared pointer on the Comment element
* @param[in] _value comment value
*/
static ememory::SharedPtr<exml::internal::Comment> create(const std::string& _value="");
static ememory::SharedPtr<exml::internal::Comment> create(const etk::String& _value="");
/**
* @brief Constructor
* @param[in] _value comment value
*/
Comment(const std::string& _value) :
Comment(const etk::String& _value) :
exml::internal::Node(_value) {
}
@ -33,8 +33,8 @@ namespace exml {
enum nodeType getType() const override {
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;
bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Comment> toComment() override {
return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis());
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Declaration.hpp>
@ -15,15 +15,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
*/
ememory::SharedPtr<exml::internal::Declaration> exml::internal::Declaration::create(const std::string& _name) {
return ememory::SharedPtr<exml::internal::Declaration>(new exml::internal::Declaration(_name));
ememory::SharedPtr<exml::internal::Declaration> exml::internal::Declaration::create(const etk::String& _name) {
return ememory::SharedPtr<exml::internal::Declaration>(ETK_NEW(exml::internal::Declaration, _name));
}
ememory::SharedPtr<exml::internal::DeclarationXML> exml::internal::DeclarationXML::create(const std::string& _version, const std::string& _format, bool _standalone) {
return ememory::SharedPtr<exml::internal::DeclarationXML>(new exml::internal::DeclarationXML(_version, _format, _standalone));
ememory::SharedPtr<exml::internal::DeclarationXML> exml::internal::DeclarationXML::create(const etk::String& _version, const etk::String& _format, bool _standalone) {
return ememory::SharedPtr<exml::internal::DeclarationXML>(ETK_NEW(exml::internal::DeclarationXML, _version, _format, _standalone));
}
exml::internal::DeclarationXML::DeclarationXML(const std::string& _version, const std::string& _format, bool _standalone) :
exml::internal::DeclarationXML::DeclarationXML(const etk::String& _version, const etk::String& _format, bool _standalone) :
exml::internal::Declaration("xml") {
if (_version.size()!=0) {
setAttribute("version", _version);
@ -41,7 +41,7 @@ exml::internal::DeclarationXML::DeclarationXML(const std::string& _version, cons
}
}
bool exml::internal::Declaration::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Declaration::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent);
_data += "<?";
_data += m_value;
@ -50,7 +50,7 @@ bool exml::internal::Declaration::iGenerate(std::string& _data, int32_t _indent)
return true;
}
bool exml::internal::Declaration::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
bool exml::internal::Declaration::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
EXML_VERBOSE("start parse : 'declaration' : '" << m_value << "'");
m_pos = _filePos;
// search end of the comment :
@ -75,9 +75,9 @@ bool exml::internal::Declaration::iParse(const std::string& _data, int32_t& _pos
return true;
}
if (checkAvaillable(_data[iii], true) == true) {
// we find an attibute == > create a new and parse it :
// we find an attibute == > create an element and parse it:
ememory::SharedPtr<exml::internal::Attribute> attribute = exml::internal::Attribute::create();
if (attribute == nullptr) {
if (attribute == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, " Allocation error ...");
return false;
}
@ -86,7 +86,7 @@ bool exml::internal::Declaration::iParse(const std::string& _data, int32_t& _pos
return false;
}
iii = _pos;
m_listAttribute.push_back(attribute);
m_listAttribute.pushBack(attribute);
continue;
}
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
@ -18,7 +18,7 @@ namespace exml {
* @brief Constructor
* @param[in] _name name of the declaration (xml, xml:xxxx ...)
*/
Declaration(const std::string& _name="") :
Declaration(const etk::String& _name="") :
exml::internal::AttributeList(_name) {
};
@ -28,13 +28,13 @@ namespace exml {
* @param[in] _name name of the declaration (xml, xml:xxxx ...)
* @return a structure declaration
*/
static ememory::SharedPtr<Declaration> create(const std::string& _name="");
static ememory::SharedPtr<Declaration> create(const etk::String& _name="");
public:
enum nodeType getType() const override{
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;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
ememory::SharedPtr<exml::internal::Declaration> toDeclaration() override {
return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis());
};
@ -53,7 +53,7 @@ namespace exml {
* @param[in] _format charset of the XML
* @param[in] _standalone this document is standalone
*/
DeclarationXML(const std::string& _version, const std::string& _format = "UTF-8", bool _standalone = true);
DeclarationXML(const etk::String& _version, const etk::String& _format = "UTF-8", bool _standalone = true);
public:
/**
* @brief Factory to create XML declaration
@ -62,7 +62,7 @@ namespace exml {
* @param[in] _standalone this document is standalone
* @return a structure declaration
*/
static ememory::SharedPtr<DeclarationXML> create(const std::string& _version, const std::string& _format = "UTF-8", bool _standalone = true);
static ememory::SharedPtr<DeclarationXML> create(const etk::String& _version, const etk::String& _format = "UTF-8", bool _standalone = true);
};
}
}

View File

@ -1,15 +1,15 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Document.hpp>
#include <exml/debug.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/provider/provider.hpp>
ememory::SharedPtr<exml::internal::Document> exml::internal::Document::create() {
return ememory::SharedPtr<exml::internal::Document>(new exml::internal::Document());
return ememory::SharedPtr<exml::internal::Document>(ETK_NEW(exml::internal::Document));
}
exml::internal::Document::Document() :
@ -22,16 +22,16 @@ exml::internal::Document::Document() :
}
bool exml::internal::Document::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Document::iGenerate(etk::String& _data, int32_t _indent) const {
for (size_t iii=0; iii<m_listSub.size(); iii++) {
if (m_listSub[iii] != nullptr) {
if (m_listSub[iii] != null) {
m_listSub[iii]->iGenerate(_data, _indent);
}
}
return true;
}
bool exml::internal::Document::parse(const std::string& _data) {
bool exml::internal::Document::parse(const etk::String& _data) {
EXML_VERBOSE("Start parsing document (type: string) size=" << _data.size());
clear();
// came from char == > force in utf8 ...
@ -41,73 +41,62 @@ bool exml::internal::Document::parse(const std::string& _data) {
return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true);
}
bool exml::internal::Document::generate(std::string& _data) {
bool exml::internal::Document::generate(etk::String& _data) {
_data = "";
return iGenerate(_data,0);
}
bool exml::internal::Document::load(const std::string& _file) {
bool exml::internal::Document::load(const etk::Uri& _uri) {
// Start loading the XML :
EXML_VERBOSE("open file (xml) \"" << _file << "\"");
EXML_VERBOSE("open file (xml) " << _uri);
clear();
etk::FSNode tmpFile(_file);
if (tmpFile.exist() == false) {
EXML_ERROR("File Does not exist : " << _file);
auto fileIo = etk::uri::get(_uri);
if (fileIo == null) {
EXML_ERROR("File Does not exist : " << _uri);
return false;
}
int64_t fileSize = tmpFile.fileSize();
if (fileSize == 0) {
EXML_ERROR("This file is empty : " << _file);
if (fileIo->open(etk::io::OpenMode::Read) == false) {
EXML_ERROR("Can not open (r) the file : " << _uri);
return false;
}
if (tmpFile.fileOpenRead() == false) {
EXML_ERROR("Can not open (r) the file : " << _file);
return false;
}
// allocate data
std::vector<char> fileBuffer;
fileBuffer.resize(fileSize+5, 0);
// load data from the file :
tmpFile.fileRead(&fileBuffer[0], 1, fileSize);
// load data from the file:
etk::String tmpDataUnicode = fileIo->readAllString();
// close the file:
tmpFile.fileClose();
// convert in UTF8 :
std::string tmpDataUnicode(&fileBuffer[0]);
// parse the data :
fileIo->close();
// parse the data:
bool ret = parse(tmpDataUnicode);
//Display();
return ret;
}
bool exml::internal::Document::store(const std::string& _file) {
std::string createData;
bool exml::internal::Document::store(const etk::Uri& _uri) {
etk::String createData;
if (generate(createData) == false) {
EXML_ERROR("Error while creating the XML : " << _file);
EXML_ERROR("Error while creating the XML: " << _uri);
return false;
}
etk::FSNode tmpFile(_file);
if (tmpFile.fileOpenWrite() == false) {
EXML_ERROR("Can not open (w) the file : " << _file);
auto fileIo = etk::uri::get(_uri);
if (fileIo == null) {
EXML_ERROR("Can not create the uri: " << _uri);
return false;
}
if (tmpFile.fileWrite((char*)createData.c_str(), sizeof(char), createData.size()) != (int64_t)createData.size()) {
EXML_ERROR("Error while writing output XML file : " << _file);
tmpFile.fileClose();
if (fileIo->open(etk::io::OpenMode::Write) == false) {
EXML_ERROR("Can not open (r) the file : " << _uri);
return false;
}
tmpFile.fileClose();
fileIo->writeAll(createData);
fileIo->close();
return true;
}
void exml::internal::Document::display() {
std::string tmpp;
etk::String tmpp;
iGenerate(tmpp, 0);
EXML_INFO("Generated XML : \n" << tmpp);
}
std::string createPosPointer(const std::string& _line, int32_t _pos) {
std::string out;
etk::String createPosPointer(const etk::String& _line, int32_t _pos) {
etk::String out;
size_t iii;
for (iii=0; (int64_t)iii<_pos && iii<_line.size(); iii++) {
if (_line[iii] == '\t') {
@ -144,7 +133,7 @@ void exml::internal::Document::displayError() {
#endif
}
void exml::internal::Document::createError(const std::string& _data, int32_t _pos, const exml::FilePos& _filePos, const std::string& _comment) {
void exml::internal::Document::createError(const etk::String& _data, int32_t _pos, const exml::FilePos& _filePos, const etk::String& _comment) {
m_comment = _comment;
m_Line = etk::extract_line(_data, _pos);
m_filePos = _filePos;

View File

@ -1,12 +1,13 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Element.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <etk/uri/uri.hpp>
namespace exml {
namespace internal {
@ -49,36 +50,36 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool parse(const std::string& _data);
bool parse(const etk::String& _data);
/**
* @brief generate a string that contain the created XML
* @param[out] _data Data where the xml is stored
* @return false : An error occured
* @return true : Parsing is OK
*/
bool generate(std::string& _data);
bool generate(etk::String& _data);
/**
* @brief Load the file that might contain the xml
* @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @param[in] _uri URI of the xml
* @return false : An error occured
* @return true : Parsing is OK
*/
bool load(const std::string& _file);
bool load(const etk::Uri& _uri);
/**
* @brief Store the Xml in the file
* @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @param[in] _uri URI of the xml
* @return false : An error occured
* @return true : Parsing is OK
*/
bool store(const std::string& _file);
bool store(const etk::Uri& _uri);
/**
* @brief Display the Document on console
*/
void display();
private:
bool m_writeErrorWhenDetexted; //!< Request print error in parsing just when detected
std::string m_comment; //!< Comment on the error
std::string m_Line; //!< Parse line error (copy)
etk::String m_comment; //!< Comment on the error
etk::String m_Line; //!< Parse line error (copy)
exml::FilePos m_filePos; //!< position of the error
public:
/**
@ -103,12 +104,12 @@ namespace exml {
* @param[in] _filePos human position of the error
* @param[in] _comment Error string to display
*/
void createError(const std::string& _data, int32_t _pos, const exml::FilePos& _filePos, const std::string& _comment);
void createError(const etk::String& _data, int32_t _pos, const exml::FilePos& _filePos, const etk::String& _comment);
public:
enum nodeType getType() const override {
return nodeType::document;
}
bool iGenerate(std::string& _data, int32_t _indent) const override;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Document> toDocument() override {
return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis());
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Element.hpp>
@ -22,13 +22,13 @@ static bool isWhiteChar(char32_t _val) {
return false;
}
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::create(const std::string& _value) {
return ememory::SharedPtr<exml::internal::Element>(new exml::internal::Element(_value));
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::create(const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Element>(ETK_NEW(exml::internal::Element, _value));
}
enum exml::nodeType exml::internal::Element::getType(int32_t _id) const {
ememory::SharedPtr<const exml::internal::Node> tmpp = getNode(_id);
if (tmpp == nullptr) {
if (tmpp == null) {
return exml::nodeType::unknow;
}
return tmpp->getType();
@ -37,7 +37,7 @@ enum exml::nodeType exml::internal::Element::getType(int32_t _id) const {
ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(int32_t _id) {
if ( _id <0
|| (size_t)_id>=m_listSub.size()) {
return nullptr;
return null;
}
return m_listSub[_id];
}
@ -45,7 +45,7 @@ ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(int32_
const ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(int32_t _id) const {
if ( _id <0
|| (size_t)_id>=m_listSub.size()) {
return nullptr;
return null;
}
return m_listSub[_id];
}
@ -53,56 +53,56 @@ const ememory::SharedPtr<exml::internal::Node> exml::internal::Element::getNode(
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getElement(int32_t _id) {
ememory::SharedPtr<exml::internal::Node> tmpp = getNode(_id);
if (tmpp == nullptr) {
return nullptr;
if (tmpp == null) {
return null;
}
return tmpp->toElement();
}
const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getElement(int32_t _id) const {
const ememory::SharedPtr<exml::internal::Node> tmpp = getNode(_id);
if (tmpp == nullptr) {
return nullptr;
if (tmpp == null) {
return null;
}
return tmpp->toElement();
}
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) {
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const etk::String& _name) {
if (_name.size() == 0) {
return nullptr;
return null;
}
for (size_t iii=0; iii<m_listSub.size(); iii++) {
if( m_listSub[iii] != nullptr
if( m_listSub[iii] != null
&& m_listSub[iii]->getType() == exml::nodeType::element
&& m_listSub[iii]->getValue() == _name) {
if (m_listSub[iii] == nullptr) {
return nullptr;
if (m_listSub[iii] == null) {
return null;
}
return m_listSub[iii]->toElement();
}
}
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) const {
const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const etk::String& _name) const {
if (_name.size() == 0) {
return nullptr;
return null;
}
for (size_t iii=0; iii<m_listSub.size(); iii++) {
if( m_listSub[iii] != nullptr
if( m_listSub[iii] != null
&& m_listSub[iii]->getType() == exml::nodeType::element
&& m_listSub[iii]->getValue() == _name) {
if (m_listSub[iii] == nullptr) {
return nullptr;
if (m_listSub[iii] == null) {
return null;
}
return m_listSub[iii]->toElement();
}
}
return nullptr;
return null;
}
void exml::internal::Element::append(const ememory::SharedPtr<exml::internal::Node>& _node) {
if (_node == nullptr) {
if (_node == null) {
EXML_ERROR("Try to set an empty node");
return;
}
@ -116,16 +116,16 @@ void exml::internal::Element::append(const ememory::SharedPtr<exml::internal::No
return;
}
}
m_listSub.push_back(_node);
m_listSub.pushBack(_node);
}
void exml::internal::Element::remove(const std::string& _nodeName) {
void exml::internal::Element::remove(const etk::String& _nodeName) {
if (_nodeName == "") {
return;
}
auto it = m_listSub.begin();
while (it != m_listSub.end()) {
if (*it == nullptr) {
if (*it == null) {
it = m_listSub.erase(it);
} else if ((*it)->getValue() == _nodeName) {
it = m_listSub.erase(it);
@ -135,8 +135,8 @@ void exml::internal::Element::remove(const std::string& _nodeName) {
}
}
std::string exml::internal::Element::getText() const {
std::string res;
etk::String exml::internal::Element::getText() const {
etk::String res;
if (m_listSub.size() == 1) {
if (m_listSub[0]->getType() == nodeType::text) {
res = m_listSub[0]->getValue();
@ -145,7 +145,7 @@ std::string exml::internal::Element::getText() const {
}
} else {
for (size_t iii=0; iii<m_listSub.size(); iii++) {
if (m_listSub[iii] != nullptr) {
if (m_listSub[iii] != null) {
m_listSub[iii]->iGenerate(res, 0);
}
}
@ -153,7 +153,7 @@ std::string exml::internal::Element::getText() const {
return res;
}
bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Element::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent);
_data += "<";
_data += m_value;
@ -161,7 +161,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] != null
&& m_listSub[0]->getType() == exml::nodeType::text
&& ememory::dynamicPointerCast<exml::internal::Text>(m_listSub[0])->countLines() == 1) {
_data += ">";
@ -171,7 +171,7 @@ bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) con
_data += ">\n";
for (size_t iii=0; iii<m_listSub.size(); iii++) {
if (m_listSub[iii] != nullptr) {
if (m_listSub[iii] != null) {
m_listSub[iii]->iGenerate(_data, _indent+1);
}
}
@ -187,7 +187,7 @@ bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) con
}
bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc, bool _mainNode) {
bool exml::internal::Element::subParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc, bool _mainNode) {
EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos);
for (size_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
@ -230,13 +230,13 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
}
tmpPos.check(_data[jjj]);
}
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2));
etk::String tmpname = etk::String(_data, iii+white+2, endPosName+1-(iii+white+2));
if (_caseSensitive == true) {
tmpname = etk::tolower(tmpname);
tmpname = etk::toLower(tmpname);
}
// Find declaration balise
ememory::SharedPtr<exml::internal::Declaration> declaration = exml::internal::Declaration::create(tmpname);
if (declaration == nullptr) {
if (declaration == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation Error...");
return false;
}
@ -246,7 +246,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
iii = _pos;
m_listSub.push_back(declaration);
m_listSub.pushBack(declaration);
continue;
}
if(_data[iii+white+1] == '!') {
@ -263,13 +263,13 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
if(_data[iii+white+3] != '-') {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML");
return false;
}
++tmpPos;
// find comment:
ememory::SharedPtr<exml::internal::Comment> comment = exml::internal::Comment::create();
if (comment == nullptr) {
if (comment == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
@ -279,7 +279,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
iii = _pos;
m_listSub.push_back(comment);
m_listSub.pushBack(comment);
} else if (_data[iii+white+2] == '[') {
++tmpPos;
if (iii+white+8>=_data.size()) {
@ -292,13 +292,13 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
|| _data[iii+white+6] != 'T'
|| _data[iii+white+7] != 'A'
|| _data[iii+white+8] != '[') {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Element parse with '<![") + _data[iii+white+3] + _data[iii+white+4] + _data[iii+white+5] + _data[iii+white+6] + _data[iii+white+7] + _data[iii+white+8] + "' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Element parse with '<![") + _data[iii+white+3] + _data[iii+white+4] + _data[iii+white+5] + _data[iii+white+6] + _data[iii+white+7] + _data[iii+white+8] + "' chars == > invalide XML");
return false;
}
tmpPos+=6;
// find text:
ememory::SharedPtr<exml::internal::TextCDATA> text = exml::internal::TextCDATA::create();
if (text == nullptr) {
if (text == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
@ -308,9 +308,9 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
iii = _pos;
m_listSub.push_back(text);
m_listSub.pushBack(text);
} else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML");
return false;
}
continue;
@ -329,9 +329,9 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
}
tmpPos.check(_data[jjj]);
}
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2));
etk::String tmpname = etk::String(_data, iii+white+2, endPosName+1-(iii+white+2));
if (_caseSensitive == true) {
tmpname = etk::tolower(tmpname);
tmpname = etk::toLower(tmpname);
}
if( tmpname == m_value) {
// find end of node :
@ -351,12 +351,12 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
&& _data[jjj] != ' '
&& _data[jjj] != '\t') {
_filePos += tmpPos;
CREATE_ERROR(_doc, _data, jjj, _filePos, std::string("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'");
CREATE_ERROR(_doc, _data, jjj, _filePos, etk::String("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'");
return false;
}
}
} else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End node error : '") + tmpname + "' != '" + m_value + "'");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("End node error : '") + tmpname + "' != '" + m_value + "'");
return false;
}
}
@ -380,14 +380,14 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
}
tmpPos.check(_data[jjj]);
}
std::string tmpname = std::string(_data, iii+white+1, endPosName+1-(iii+white+1));
etk::String tmpname = etk::String(_data, iii+white+1, endPosName+1-(iii+white+1));
if (_caseSensitive == true) {
etk::tolower(tmpname);
etk::toLower(tmpname);
}
//EXML_INFO("find node named : '" << tmpname << "'");
// find text:
ememory::SharedPtr<exml::internal::Element> element = exml::internal::Element::create(tmpname);
if (element == nullptr) {
if (element == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
@ -397,12 +397,12 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
iii = _pos;
m_listSub.push_back(element);
m_listSub.pushBack(element);
continue;
}
_filePos+=tmpPos;
// here we have an error :
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Find an ununderstanding element : '") + _data[iii+white+1] + "'");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Find an ununderstanding element : '") + _data[iii+white+1] + "'");
return false;
} else {
if (_data[iii] == '>') {
@ -418,7 +418,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
} else {
// find data == > parse it...
ememory::SharedPtr<exml::internal::Text> text = exml::internal::Text::create();
if (text == nullptr) {
if (text == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
@ -428,18 +428,18 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false;
}
iii = _pos;
m_listSub.push_back(text);
m_listSub.pushBack(text);
}
}
}
if (_mainNode == true) {
return true;
}
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Did not find end of the exml::internal::Element : '") + m_value + "'");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Did not find end of the exml::internal::Element : '") + m_value + "'");
return false;
}
bool exml::internal::Element::iParse(const std::string& _data,
bool exml::internal::Element::iParse(const etk::String& _data,
int32_t& _pos,
bool _caseSensitive,
exml::FilePos& _filePos,
@ -474,9 +474,9 @@ bool exml::internal::Element::iParse(const std::string& _data,
return false;
}
if (checkAvaillable(_data[iii], true) == true) {
// we find an attibute == > create a new and parse it :
// we find an attibute == > create an element and parse it:
ememory::SharedPtr<exml::internal::Attribute> attribute = exml::internal::Attribute::create();
if (attribute == nullptr) {
if (attribute == null) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
@ -485,15 +485,15 @@ bool exml::internal::Element::iParse(const std::string& _data,
return false;
}
iii = _pos;
m_listAttribute.push_back(attribute);
m_listAttribute.pushBack(attribute);
continue;
}
if (isWhiteChar(_data[iii]) == false) {
CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find an unknow element : '") + _data[iii] + "'");
CREATE_ERROR(_doc, _data, iii, _filePos, etk::String("Find an unknow element : '") + _data[iii] + "'");
return false;
}
}
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Unexpecting end of parsing exml::internal::Element : '") + m_value + "' == > check if the '/>' is set or the end of element");
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Unexpecting end of parsing exml::internal::Element : '") + m_value + "' == > check if the '/>' is set or the end of element");
return false;
}

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <exml/internal/AttributeList.hpp>
namespace exml {
@ -24,7 +24,7 @@ namespace exml {
* @brief Constructor
* @param[in] _value Element name;
*/
Element(const std::string& _value) :
Element(const etk::String& _value) :
exml::internal::AttributeList(_value) {
};
@ -34,9 +34,9 @@ namespace exml {
* @param[in] _value Name of the node.
* @return Shared pointer on the Element
*/
static ememory::SharedPtr<Element> create(const std::string& _value="");
static ememory::SharedPtr<Element> create(const etk::String& _value="");
protected:
std::vector<ememory::SharedPtr<exml::internal::Node>> m_listSub; //!< List of subNodes
etk::Vector<ememory::SharedPtr<exml::internal::Node>> m_listSub; //!< List of subNodes
public:
/**
* @brief get the number of sub element in the node (can be exml::internal::Comment ; exml::internal::Element ; exml::internal::Text :exml::internal::Declaration).
@ -54,7 +54,7 @@ namespace exml {
* @brief Remove all element with this name
* @param[in] _nodeName Name of nodes to remove.
*/
void remove(const std::string& _nodeName);
void remove(const etk::String& _nodeName);
/**
* @brief get the type of the element id.
* @param[in] _id Id of the element.
@ -90,18 +90,18 @@ namespace exml {
* @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL.
*/
ememory::SharedPtr<Element> getNamed(const std::string& _name);
ememory::SharedPtr<Element> getNamed(const etk::String& _name);
/**
* @brief get an element with his name (work only with exml::internal::Element)
* @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL.
*/
const ememory::SharedPtr<Element> getNamed(const std::string& _name) const;
const ememory::SharedPtr<Element> getNamed(const etk::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[...]]>
* @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...
*/
std::string getText() const;
etk::String getText() const;
protected:
/**
* @brief Parse sub node string
@ -114,7 +114,7 @@ namespace exml {
* @return true parsing is done OK
* @return false An error appear in the parsing
*/
bool subParse(const std::string& _data,
bool subParse(const etk::String& _data,
int32_t& _pos,
bool _caseSensitive,
exml::FilePos& _filePos,
@ -124,8 +124,8 @@ namespace exml {
enum nodeType getType() const override {
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;
bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Element> toElement() override;
const ememory::SharedPtr<exml::internal::Element> toElement() const override;
void clear() override;

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Node.hpp>
@ -23,14 +23,14 @@ static bool isWhiteChar(char32_t _val) {
return false;
}
exml::internal::Node::Node(const std::string& _value) :
exml::internal::Node::Node(const etk::String& _value) :
m_pos(0,0),
m_value(_value) {
// nothing to do.
}
void exml::internal::Node::addIndent(std::string& _data, int32_t _indent) const {
void exml::internal::Node::addIndent(etk::String& _data, int32_t _indent) const {
for (int32_t iii=0; iii<_indent; iii++) {
_data += "\t";
}
@ -93,7 +93,7 @@ bool exml::internal::Node::checkAvaillable(char32_t _val, bool _firstChar) const
}
int32_t exml::internal::Node::countWhiteChar(const std::string& _data, int32_t _pos, exml::FilePos& _filePos) const {
int32_t exml::internal::Node::countWhiteChar(const etk::String& _data, int32_t _pos, exml::FilePos& _filePos) const {
_filePos.clear();
int32_t white=0;
for (size_t iii=_pos; iii<_data.size(); iii++) {
@ -108,7 +108,7 @@ int32_t exml::internal::Node::countWhiteChar(const std::string& _data, int32_t _
return white;
}
bool exml::internal::Node::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Node::iGenerate(etk::String& _data, int32_t _indent) const {
return true;
}
@ -121,11 +121,11 @@ void exml::internal::Node::clear() {
m_pos.clear();
}
void exml::internal::Node::setValue(std::string _value) {
void exml::internal::Node::setValue(etk::String _value) {
m_value = _value;
}
const std::string& exml::internal::Node::getValue() const {
const etk::String& exml::internal::Node::getValue() const {
return m_value;
}
@ -134,51 +134,51 @@ enum exml::nodeType exml::internal::Node::getType() const {
}
ememory::SharedPtr<exml::internal::Document> exml::internal::Node::toDocument() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Document> exml::internal::Node::toDocument() const {
return nullptr;
return null;
}
ememory::SharedPtr<exml::internal::Attribute> exml::internal::Node::toAttribute() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Attribute> exml::internal::Node::toAttribute() const {
return nullptr;
return null;
}
ememory::SharedPtr<exml::internal::Comment> exml::internal::Node::toComment() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Comment> exml::internal::Node::toComment() const {
return nullptr;
return null;
}
ememory::SharedPtr<exml::internal::Declaration> exml::internal::Node::toDeclaration() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Declaration> exml::internal::Node::toDeclaration() const {
return nullptr;
return null;
}
ememory::SharedPtr<exml::internal::Element> exml::internal::Node::toElement() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Element> exml::internal::Node::toElement() const {
return nullptr;
return null;
}
ememory::SharedPtr<exml::internal::Text> exml::internal::Node::toText() {
return nullptr;
return null;
}
const ememory::SharedPtr<exml::internal::Text> exml::internal::Node::toText() const{
return nullptr;
return null;
}
bool exml::internal::Node::isDocument() const {

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
@ -53,7 +53,7 @@ namespace exml {
* @brief basic element of a xml structure
* @param[in] _value value of the node
*/
Node(const std::string& _value);
Node(const etk::String& _value);
public:
/**
* @brief Virtualize destructor
@ -69,14 +69,14 @@ namespace exml {
* @param[in,out] _doc Base document reference
* @return false if an error occured.
*/
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) = 0;
virtual bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) = 0;
/**
* @brief generate a string with the tree of the xml
* @param[in,out] _data string where to add the elements
* @param[in] _indent current indentation of the file
* @return false if an error occured.
*/
virtual bool iGenerate(std::string& _data, int32_t _indent) const;
virtual bool iGenerate(etk::String& _data, int32_t _indent) const;
protected:
exml::FilePos m_pos; //!< position in the readed file == > not correct when the file is generated
public:
@ -86,18 +86,18 @@ namespace exml {
*/
const exml::FilePos& getPos() const;
protected:
std::string m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
etk::String m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
public:
/**
* @brief set the value of the node.
* @param[in] _value New value of the node.
*/
virtual void setValue(std::string _value);
virtual void setValue(etk::String _value);
/**
* @brief get the current element Value.
* @return the reference of the string value.
*/
virtual const std::string& getValue() const;
virtual const etk::String& getValue() const;
public:
/**
* @brief get the node type.
@ -110,7 +110,7 @@ namespace exml {
* @param[in,out] _data String where the indentation is done.
* @param[in] _indent Number of tab to add at the string.
*/
void addIndent(std::string& _data, int32_t _indent) const;
void addIndent(etk::String& _data, int32_t _indent) const;
/**
* @brief Display the cuurent element that is curently parse.
* @param[in] _val Char that is parsed.
@ -132,66 +132,66 @@ namespace exml {
* @param[out] _filePos new poistion of te file to add.
* @return number of white element.
*/
int32_t countWhiteChar(const std::string& _data, int32_t _pos, exml::FilePos& _filePos) const;
int32_t countWhiteChar(const etk::String& _data, int32_t _pos, exml::FilePos& _filePos) const;
public:
/**
* @brief Cast the element in a Document if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Document> toDocument();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Document> toDocument() const;
/**
* @brief Cast the element in a Attribute if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Attribute> toAttribute();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Attribute> toAttribute() const;
/**
* @brief Cast the element in a Comment if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Comment> toComment();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Comment> toComment() const;
/**
* @brief Cast the element in a Declaration if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Declaration> toDeclaration();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Declaration> toDeclaration() const;
/**
* @brief Cast the element in a Element if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Element> toElement();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Element> toElement() const;
/**
* @brief Cast the element in a Text if it is possible.
* @return pointer on the class or nullptr.
* @return pointer on the class or null.
*/
virtual ememory::SharedPtr<exml::internal::Text> toText();
/**
* @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 null.
*/
virtual const ememory::SharedPtr<exml::internal::Text> toText() const;

View File

@ -1,13 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/internal/Text.hpp>
#include <exml/debug.hpp>
#include <exml/internal/Document.hpp>
#include <regex>
// transform the Text with :
// "&lt;" == "<"
@ -15,35 +14,23 @@
// "&amp;" == "&"
// "&apos;" == "'"
// "&quot;" == """
static std::string replaceSpecialChar(const std::string& _inval) {
std::string out;
static std::regex regexLT("&lt;");
static std::regex regexGT("&gt;");
static std::regex regexAPOS("&apos;");
static std::regex regexQUOT("&quot;");
static std::regex regexAMP("&amp;");
out = std::regex_replace(_inval, regexLT, std::string("<"));
out = std::regex_replace(out, regexGT, std::string(">"));
out = std::regex_replace(out, regexAPOS, std::string("'"));
out = std::regex_replace(out, regexQUOT, std::string("\""));
out = std::regex_replace(out, regexAMP, std::string("&"));
static etk::String replaceSpecialChar(const etk::String& _inval) {
etk::String out = _inval;
out.replace("&lt;", "<");
out.replace("&gt;", ">");
out.replace("&apos;", "'");
out.replace("&quot;", "\"");
out.replace("&amp;", "&");
//EXML_ERROR("INNN '"<< _inval << "' => '" << out << "'");
return out;
}
static std::string replaceSpecialCharOut(const std::string& _inval) {
std::string out;
static std::regex regexLT("<");
static std::regex regexGT(">;");
static std::regex regexAMP("&");
static std::regex regexAPOS("'");
static std::regex regexQUOT("\"");
out = std::regex_replace(_inval, regexAMP, std::string("&amp;"));
out = std::regex_replace(out, regexQUOT, std::string("&quot;"));
out = std::regex_replace(out, regexAPOS, std::string("&apos;"));
out = std::regex_replace(out, regexGT, std::string("&gt;"));
out = std::regex_replace(out, regexLT, std::string("&lt;"));
static etk::String replaceSpecialCharOut(const etk::String& _inval) {
etk::String out = _inval;
out.replace("<", "&lt;");
out.replace(">", "&gt;");
out.replace("'", "&apos;");
out.replace("\"", "&quot;");
out.replace("&", "&amp;");
//EXML_ERROR("OUTTT '"<< _inval << "' => '" << out << "'");
return out;
}
@ -58,11 +45,11 @@ static bool isWhiteChar(char32_t _val) {
return false;
}
ememory::SharedPtr<exml::internal::Text> exml::internal::Text::create(const std::string& _data) {
return ememory::SharedPtr<exml::internal::Text>(new exml::internal::Text(_data));
ememory::SharedPtr<exml::internal::Text> exml::internal::Text::create(const etk::String& _data) {
return ememory::SharedPtr<exml::internal::Text>(ETK_NEW(exml::internal::Text, _data));
}
bool exml::internal::Text::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::Text::iGenerate(etk::String& _data, int32_t _indent) const {
_data += replaceSpecialCharOut(m_value);
return true;
}
@ -77,7 +64,7 @@ int32_t exml::internal::Text::countLines() const {
return count;
}
bool exml::internal::Text::iParse(const std::string& _data,
bool exml::internal::Text::iParse(const etk::String& _data,
int32_t& _pos,
bool _caseSensitive,
exml::FilePos& _filePos,
@ -104,7 +91,7 @@ bool exml::internal::Text::iParse(const std::string& _data,
}
}
// find end of value:
m_value = std::string(_data, _pos, newEnd-(_pos));
m_value = etk::String(_data, _pos, newEnd-(_pos));
EXML_VERBOSE(" find text '" << m_value << "'");
_pos = iii-1;
m_value = replaceSpecialChar(m_value);
@ -118,15 +105,15 @@ bool exml::internal::Text::iParse(const std::string& _data,
ememory::SharedPtr<exml::internal::TextCDATA> exml::internal::TextCDATA::create() {
return ememory::SharedPtr<exml::internal::TextCDATA>(new exml::internal::TextCDATA());
return ememory::SharedPtr<exml::internal::TextCDATA>(ETK_NEW(exml::internal::TextCDATA));
}
bool exml::internal::TextCDATA::iGenerate(std::string& _data, int32_t _indent) const {
bool exml::internal::TextCDATA::iGenerate(etk::String& _data, int32_t _indent) const {
_data += "<![CDATA[" + m_value +"]]>";
return true;
}
bool exml::internal::TextCDATA::iParse(const std::string& _data,
bool exml::internal::TextCDATA::iParse(const etk::String& _data,
int32_t& _pos,
bool _caseSensitive,
exml::FilePos& _filePos,
@ -146,7 +133,7 @@ bool exml::internal::TextCDATA::iParse(const std::string& _data,
&& _data[iii+2] == '>') {
// find end of value:
_filePos += 2;
m_value = std::string(_data, _pos, iii-(_pos));
m_value = etk::String(_data, _pos, iii-(_pos));
EXML_VERBOSE(" find text CDATA '" << m_value << "'");
_pos = iii+2;
return true;

View File

@ -1,12 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <exml/internal/Node.hpp>
#include <vector>
#include <etk/Vector.hpp>
namespace exml {
namespace internal {
@ -23,14 +23,14 @@ namespace exml {
* @brief Constructor
* @param[in] _data String data of the current Text
*/
Text(const std::string& _data) : exml::internal::Node(_data) { };
Text(const etk::String& _data) : exml::internal::Node(_data) { };
public:
/**
* @brief defined factory
* @param[in] _data Data in the Text area
* @return Shared pointer on the Text element
*/
static ememory::SharedPtr<exml::internal::Text> create(const std::string& _data="");
static ememory::SharedPtr<exml::internal::Text> create(const etk::String& _data="");
/**
* @brief count the number of line in the current text
* @return The number of lines
@ -40,12 +40,12 @@ namespace exml {
enum nodeType getType() const override{
return nodeType::text;
};
bool iParse(const std::string& _data,
bool iParse(const etk::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;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Text> toText() override {
return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis());
};
@ -69,12 +69,12 @@ namespace exml {
*/
static ememory::SharedPtr<TextCDATA> create();
public:
bool iParse(const std::string& _data,
bool iParse(const etk::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;
bool iGenerate(etk::String& _data, int32_t _indent) const override;
};
}
}

View File

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

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <exml/nodeType.hpp>
@ -9,7 +9,7 @@
std::ostream& exml::operator <<(std::ostream& _os, enum exml::nodeType _obj) {
etk::Stream& exml::operator <<(etk::Stream& _os, enum exml::nodeType _obj) {
switch (_obj) {
case nodeType::unknow:
_os << "exml::nodeType::unknow";

View File

@ -1,11 +1,11 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <ostream>
#include <etk/Stream.hpp>
/**
* @brief exml namespace containing all function for XML interpretor
@ -25,6 +25,6 @@ namespace exml {
text, //!< &lt;XXX&gt; InsideText &lt;/XXX&gt;
};
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, enum nodeType _obj);
etk::Stream& operator <<(etk::Stream& _os, enum nodeType _obj);
}

View File

@ -1,13 +0,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.

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
def get_type():
@ -12,7 +12,7 @@ def get_desc():
return "e-xml sample"
def get_licence():
return "APACHE-2"
return "MPL-2"
def get_compagny_type():
return "com"

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
@ -16,7 +16,7 @@ def get_desc():
return "e-xml test software"
def get_licence():
return "APACHE-2"
return "MPL-2"
def get_compagny_type():
return "com"
@ -44,7 +44,7 @@ def configure(target, my_module):
])
my_module.add_depend([
'exml',
'gtest',
'etest',
'test-debug'
])
return True

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
@ -10,7 +10,7 @@ def get_desc():
return "XML parser and generator"
def get_licence():
return "APACHE-2"
return "MPL-2"
def get_compagny_type():
return "com"

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <test-debug/debug.hpp>
@ -13,7 +13,7 @@ int main(int argc, const char *argv[]) {
// the only one init for etk:
etk::init(argc, argv);
for (int32_t iii=0; iii<argc ; ++iii) {
std::string data = argv[iii];
etk::String data = argv[iii];
if ( data == "-h"
|| data == "--help") {
TEST_PRINT("Help : ");

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
//! [exml_sample_read_all]
@ -17,7 +17,7 @@ static void readFromFile() {
exml::Document doc;
//! [exml_sample_declare_doc]
//! [exml_sample_read_file]
bool retParse = doc.load("DATA:read.xml");
bool retParse = doc.load(etk::Uri("DATA:///read.xml"));
//! [exml_sample_read_file]
TEST_INFO("parse ret = " << retParse);
TEST_INFO("Debug display of the tree:");
@ -28,7 +28,7 @@ static void readFromString1() {
exml::Document doc;
TEST_INFO("parse");
//! [exml_sample_read_stream1]
std::string stream = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"
etk::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);
@ -42,7 +42,7 @@ 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'?>"
etk::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);
@ -56,7 +56,7 @@ static void readFromString2() {
static void readFull() {
exml::Document doc;
TEST_INFO("parse");
bool retParse = doc.load("DATA:read.xml");
bool retParse = doc.load(etk::Uri("DATA:///read.xml"));
TEST_INFO("parse ret = " << retParse);
TEST_INFO("Debug display of the tree:");
doc.display();
@ -90,7 +90,7 @@ static void readFull() {
TEST_INFO(" list of attribute:");
//! [exml_sample_read_folow_attributes]
for (const auto itElem: element.attributes) {
std::string value = itElem.getValue();
etk::String value = itElem.getValue();
TEST_INFO(" '" << value << "'");
}
TEST_INFO(" list of attribute in C:");
@ -98,12 +98,12 @@ static void readFull() {
//! [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();
etk::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"];
etk::String attributeValue = element.attributes["attributeExample"];
TEST_INFO(" direct get: '" << attributeValue << "'");
//! [exml_sample_read_get_direct_attribute]
TEST_INFO(" list of sub-node:");
@ -111,7 +111,7 @@ static void readFull() {
for (const auto itElem: element.nodes) {
if (itElem.isElement() == true) {
// get the <XXXX ... name
std::string value = itElem.toElement().getValue();
etk::String value = itElem.toElement().getValue();
TEST_INFO(" '" << value << "'");
} else {
// simple debug for other type:
@ -125,7 +125,7 @@ static void readFull() {
const exml::Node node = element.nodes[iii];
if (node.isElement() == true) {
// get the <XXXX ... name
std::string value = node.toElement().getValue();
etk::String value = node.toElement().getValue();
TEST_INFO(" '" << value << "'");
} else {
// simple debug for other type:
@ -134,7 +134,7 @@ static void readFull() {
}
//! [exml_sample_read_folow_nodes_c]
//! [exml_sample_read_get_all_under_string]
std::string internalData = element.getText();
etk::String internalData = element.getText();
//! [exml_sample_read_get_all_under_string]
}

View File

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

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
//! [exml_sample_write_all]
@ -18,7 +18,7 @@ static void writeToFile() {
doc.nodes.add(exml::Comment("basic comment"));
TEST_INFO("store");
//! [exml_sample_write_file]
bool retGenerate = doc.store("generate.xml");
bool retGenerate = doc.store(etk::Path("generate.xml"));
//! [exml_sample_write_file]
TEST_INFO("parse ret = " << retGenerate);
TEST_INFO("Debug display of the tree:");
@ -33,7 +33,7 @@ static void writeToString() {
doc.nodes.add(exml::Comment("basic comment"));
TEST_INFO("generate");
//! [exml_sample_write_stream]
std::string streamOut;
etk::String streamOut;
bool retGenerate = doc.generate(streamOut);
//! [exml_sample_write_stream]
TEST_INFO("parse ret = " << retGenerate);

View File

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

View File

@ -1,11 +1,11 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include "exmlTestCommon.hpp"
#include <gtest/gtest.h>
#include <etest/etest.hpp>
TEST(TestAll, testBase) {

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <exml/exml.hpp>
#include <exml/Attribute.hpp>

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <exml/exml.hpp>
#include <exml/Comment.hpp>

View File

@ -1,17 +1,17 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <test-debug/debug.hpp>
#include <exml/exml.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
// _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
void exmlLocalTest(const std::string& _ref,
const std::string& _input,
void exmlLocalTest(const etk::String& _ref,
const etk::String& _input,
int32_t _errorPos,
bool _caseInSensitive=false) {
exml::Document doc;
@ -24,7 +24,7 @@ void exmlLocalTest(const std::string& _ref,
} else {
EXPECT_EQ(retParse, true);
}
std::string out("");
etk::String out("");
bool retGenerate = doc.generate(out);
if (_errorPos == 2) {
EXPECT_EQ(retGenerate, false);

View File

@ -1,15 +1,15 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
// _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
void exmlLocalTest(const std::string& _ref,
const std::string& _input,
void exmlLocalTest(const etk::String& _ref,
const etk::String& _input,
int32_t _errorPos,
bool _caseInSensitive=false);

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <exml/exml.hpp>
#include <exml/Declaration.hpp>

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <exml/exml.hpp>
#include <exml/Declaration.hpp>

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <exml/exml.hpp>
#include <exml/Element.hpp>

View File

@ -1,11 +1,11 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include "exmlTestCommon.hpp"
#include <gtest/gtest.h>
#include <etest/etest.hpp>

View File

@ -1,11 +1,11 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include "exmlTestCommon.hpp"
#include <gtest/gtest.h>
#include <etest/etest.hpp>

View File

@ -1,11 +1,11 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include "exmlTestCommon.hpp"
#include <gtest/gtest.h>
#include <etest/etest.hpp>

View File

@ -1,14 +1,14 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include "exmlTestCommon.hpp"
#include <gtest/gtest.h>
#include <etest/etest.hpp>
static std::string refOutputElement("<exemple/>\n");
static etk::String refOutputElement("<exemple/>\n");
TEST(TestParseElement, testBase) {
exmlLocalTest(refOutputElement, "<exemple/>\n", -1);

View File

@ -1,21 +1,18 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <test-debug/debug.hpp>
#include <gtest/gtest.h>
#include <etk/os/FSNode.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
int main(int argc, const char *argv[]) {
// init Google test :
::testing::InitGoogleTest(&argc, const_cast<char **>(argv));
// the only one init for etk:
etk::init(argc, argv);
etest::init(argc, argv);
for (int32_t iii=0; iii<argc ; ++iii) {
std::string data = argv[iii];
etk::String data = argv[iii];
if ( data == "-h"
|| data == "--help") {
TEST_PRINT("Help : ");
@ -24,6 +21,5 @@ int main(int argc, const char *argv[]) {
exit(0);
}
}
etk::initDefaultFolder("exml_test");
return RUN_ALL_TESTS();
}

View File

@ -1 +1 @@
0.7.0
1.0.0