From 43ddd2549c0638d3463be37d8f0c651437de7d7b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 11 Nov 2013 20:18:35 +0100 Subject: [PATCH] [DEV] integarate std x11 --- ejson/Array.cpp | 26 ++++++------- ejson/Array.h | 12 +++--- ejson/Boolean.cpp | 4 +- ejson/Boolean.h | 4 +- ejson/Null.cpp | 4 +- ejson/Null.h | 4 +- ejson/Number.cpp | 6 +-- ejson/Number.h | 4 +- ejson/Object.cpp | 46 +++++++++++------------ ejson/Object.h | 38 +++++++++---------- ejson/String.cpp | 4 +- ejson/String.h | 12 +++--- ejson/Value.cpp | 10 ++--- ejson/Value.h | 16 ++++---- ejson/ejson.cpp | 24 ++++++------ ejson/ejson.h | 20 +++++----- ejson/test.cpp | 94 +++++++++++++++++++++++------------------------ 17 files changed, 164 insertions(+), 164 deletions(-) diff --git a/ejson/Array.cpp b/ejson/Array.cpp index 37527cd..3f8c2ba 100644 --- a/ejson/Array.cpp +++ b/ejson/Array.cpp @@ -31,7 +31,7 @@ void ejson::Array::clear(void) { m_value.clear(); } -bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Array::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { JSON_PARSE_ELEMENT("start parse : 'Object' "); for (int32_t iii=_pos+1; iii<_data.size(); iii++) { _filePos.check(_data[iii]); @@ -58,7 +58,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if (_data[iii] == '"') { // find a string: JSON_PARSE_ELEMENT("find String quoted"); @@ -69,7 +69,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if (_data[iii] == '[') { // find a list: JSON_PARSE_ELEMENT("find List"); @@ -80,7 +80,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if( _data[iii] == 'f' || _data[iii] == 't' ) { // find boolean: @@ -92,7 +92,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if( _data[iii] == 'n') { // find null: JSON_PARSE_ELEMENT("find Null"); @@ -103,7 +103,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if(true == checkNumber(_data[iii])) { // find number: JSON_PARSE_ELEMENT("find Number"); @@ -114,7 +114,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.pushBack(tmpElement); + m_value.push_back(tmpElement); } else if(_data[iii] == ',') { // find Separator : Restart cycle ... // TODO : check if element are separated with ',' @@ -131,7 +131,7 @@ bool ejson::Array::iParse(const etk::UString& _data, int32_t& _pos, ejson::fileP } -bool ejson::Array::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Array::iGenerate(std::u32string& _data, int32_t _indent) const { bool oneLine=true; if (m_value.size()>3) { oneLine=false; @@ -193,11 +193,11 @@ bool ejson::Array::add(ejson::Value* _element) { JSON_ERROR("Request add on an NULL pointer"); return false; } - m_value.pushBack(_element); + m_value.push_back(_element); return true; } -bool ejson::Array::addString(const etk::UString& _value) { +bool ejson::Array::addString(const std::u32string& _value) { return add(new ejson::String(_value)); } @@ -298,8 +298,8 @@ ejson::Boolean* ejson::Array::getBoolean(esize_t _id) { return tmpElement->toBoolean(); } -const etk::UString& ejson::Array::getStringValue(esize_t _id) { - static const etk::UString errorValue(""); +const std::u32string& ejson::Array::getStringValue(esize_t _id) { + static const std::u32string errorValue(""); ejson::String* tmpElement = getString(_id); if (NULL == tmpElement) { return errorValue; @@ -307,7 +307,7 @@ const etk::UString& ejson::Array::getStringValue(esize_t _id) { return tmpElement->get(); } -etk::UString ejson::Array::getStringValue(esize_t _id, const etk::UString& _errorValue) { +std::u32string ejson::Array::getStringValue(esize_t _id, const std::u32string& _errorValue) { ejson::String* tmpElement = getString(_id); if (NULL == tmpElement) { return _errorValue; diff --git a/ejson/Array.h b/ejson/Array.h index c88929e..e7ecfd4 100644 --- a/ejson/Array.h +++ b/ejson/Array.h @@ -32,7 +32,7 @@ namespace ejson }; private: - etk::Vector m_value; //!< vector of sub elements + std::vector m_value; //!< vector of sub elements public: /** * @brief get the number of sub element in the current one @@ -69,14 +69,14 @@ namespace ejson * @param[in] _id Id of the element. * @return value of the element. */ - const etk::UString& getStringValue(esize_t _id); + const std::u32string& getStringValue(esize_t _id); /** * @brief get the value of the string element * @param[in] _id Id of the element. * @param[in] _errorValue The return value if an error occured. * @return value of the element, or the _errorValue. */ - etk::UString getStringValue(esize_t _id, const etk::UString& _errorValue); + std::u32string getStringValue(esize_t _id, const std::u32string& _errorValue); /** * @brief get the pointer on an element reference with his ID (casted in Array if it is an Array). * @param[in] _id Id of the element. @@ -126,7 +126,7 @@ namespace ejson * @param[in] _value string value to add * @return false if an error occured */ - bool addString(const etk::UString& _value); + bool addString(const std::u32string& _value); /** * @brief add a "null" element in the Object (automatic creation) * @return false if an error occured @@ -146,8 +146,8 @@ namespace ejson bool addNumber(double _value); public: // herited function : - virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); - virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; + virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); + virtual bool iGenerate(std::u32string& _data, int32_t _indent) const; virtual enum nodeType getType(void) const { return typeArray; }; diff --git a/ejson/Boolean.cpp b/ejson/Boolean.cpp index 496c88b..ccca2df 100644 --- a/ejson/Boolean.cpp +++ b/ejson/Boolean.cpp @@ -13,7 +13,7 @@ #undef __class__ #define __class__ "Boolean" -bool ejson::Boolean::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Boolean::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { JSON_PARSE_ELEMENT("start parse : 'Boolean' "); m_value=false; if( _data[_pos] == 't' @@ -42,7 +42,7 @@ bool ejson::Boolean::iParse(const etk::UString& _data, int32_t& _pos, ejson::fil } -bool ejson::Boolean::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Boolean::iGenerate(std::u32string& _data, int32_t _indent) const { if (true == m_value) { _data += "true"; } else { diff --git a/ejson/Boolean.h b/ejson/Boolean.h index e08b009..1b59379 100644 --- a/ejson/Boolean.h +++ b/ejson/Boolean.h @@ -50,8 +50,8 @@ namespace ejson return m_value; }; public: // herited function : - virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); - virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; + virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); + virtual bool iGenerate(std::u32string& _data, int32_t _indent) const; virtual enum nodeType getType(void) const { return typeString; }; diff --git a/ejson/Null.cpp b/ejson/Null.cpp index c989020..531943e 100644 --- a/ejson/Null.cpp +++ b/ejson/Null.cpp @@ -14,7 +14,7 @@ #undef __class__ #define __class__ "Null" -bool ejson::Null::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Null::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { JSON_PARSE_ELEMENT("start parse : 'Null' "); if (_pos+3 >= _data.size()){ EJSON_CREATE_ERROR(_doc, _data, _pos, _filePos, "can not parse null !!! "); @@ -33,7 +33,7 @@ bool ejson::Null::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePo } -bool ejson::Null::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Null::iGenerate(std::u32string& _data, int32_t _indent) const { _data += "null"; return true; } diff --git a/ejson/Null.h b/ejson/Null.h index dc33339..9bceece 100644 --- a/ejson/Null.h +++ b/ejson/Null.h @@ -28,8 +28,8 @@ namespace ejson */ virtual ~Null(void) { }; public: // herited function : - virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); - virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; + virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); + virtual bool iGenerate(std::u32string& _data, int32_t _indent) const; virtual enum nodeType getType(void) const { return typeString; }; diff --git a/ejson/Number.cpp b/ejson/Number.cpp index 40c5eea..ea73e64 100644 --- a/ejson/Number.cpp +++ b/ejson/Number.cpp @@ -14,9 +14,9 @@ #undef __class__ #define __class__ "Number" -bool ejson::Number::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Number::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { JSON_PARSE_ELEMENT("start parse : 'Number' "); - etk::UString tmpVal; + std::u32string tmpVal; for (int32_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); #ifdef ENABLE_DISPLAY_PARSED_ELEMENT @@ -37,7 +37,7 @@ bool ejson::Number::iParse(const etk::UString& _data, int32_t& _pos, ejson::file } -bool ejson::Number::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Number::iGenerate(std::u32string& _data, int32_t _indent) const { _data += m_value; return true; } diff --git a/ejson/Number.h b/ejson/Number.h index 98995cb..1f2ae67 100644 --- a/ejson/Number.h +++ b/ejson/Number.h @@ -62,8 +62,8 @@ namespace ejson return (int64_t)m_value; }; public: // herited function : - virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); - virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; + virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); + virtual bool iGenerate(std::u32string& _data, int32_t _indent) const; virtual enum nodeType getType(void) const { return typeString; }; diff --git a/ejson/Object.cpp b/ejson/Object.cpp index 8958754..9acdd95 100644 --- a/ejson/Object.cpp +++ b/ejson/Object.cpp @@ -37,9 +37,9 @@ enum statusParsing { parseValue, }; -bool ejson::Object::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Object::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { enum statusParsing mode = parseName; - etk::UString currentName; + std::u32string currentName; JSON_PARSE_ELEMENT("start parse : 'Object' "); bool standalone = true; int32_t startPos = _pos+1; @@ -188,7 +188,7 @@ bool ejson::Object::iParse(const etk::UString& _data, int32_t& _pos, ejson::file currentName = ""; } else { // find an error .... - EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, etk::UString("Find '") + _data[iii] + "' with no element in the element..."); + EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, std::u32string("Find '") + _data[iii] + "' with no element in the element..."); // move the curent index _pos = iii+1; return false; @@ -202,7 +202,7 @@ bool ejson::Object::iParse(const etk::UString& _data, int32_t& _pos, ejson::file } return false; } -bool ejson::Object::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Object::iGenerate(std::u32string& _data, int32_t _indent) const { bool oneLine=true; if (m_value.size()>3) { oneLine=false; @@ -263,18 +263,18 @@ bool ejson::Object::iGenerate(etk::UString& _data, int32_t _indent) const { return true; } -bool ejson::Object::exist(const etk::UString& _name) const { +bool ejson::Object::exist(const std::u32string& _name) const { return m_value.exist(_name); } -ejson::Value* ejson::Object::get(const etk::UString& _name) const { +ejson::Value* ejson::Object::get(const std::u32string& _name) const { if (false == m_value.exist(_name)) { return NULL; } return m_value[_name]; } -ejson::Object* ejson::Object::getObject(const etk::UString& _name) const { +ejson::Object* ejson::Object::getObject(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -282,7 +282,7 @@ ejson::Object* ejson::Object::getObject(const etk::UString& _name) const { return tmp->toObject(); } -ejson::Array* ejson::Object::getArray(const etk::UString& _name) const { +ejson::Array* ejson::Object::getArray(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -290,7 +290,7 @@ ejson::Array* ejson::Object::getArray(const etk::UString& _name) const { return tmp->toArray(); } -ejson::Null* ejson::Object::getNull(const etk::UString& _name) const { +ejson::Null* ejson::Object::getNull(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -298,7 +298,7 @@ ejson::Null* ejson::Object::getNull(const etk::UString& _name) const { return tmp->toNull(); } -ejson::String* ejson::Object::getString(const etk::UString& _name) const { +ejson::String* ejson::Object::getString(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -306,8 +306,8 @@ ejson::String* ejson::Object::getString(const etk::UString& _name) const { return tmp->toString(); } -const etk::UString& ejson::Object::getStringValue(const etk::UString& _name) const { - static const etk::UString errorString(""); +const std::u32string& ejson::Object::getStringValue(const std::u32string& _name) const { + static const std::u32string errorString(""); ejson::String* tmpp = getString(_name); if (NULL == tmpp) { return errorString; @@ -315,7 +315,7 @@ const etk::UString& ejson::Object::getStringValue(const etk::UString& _name) con return tmpp->get(); } -etk::UString ejson::Object::getStringValue(const etk::UString& _name, const etk::UString& _errorValue) const { +std::u32string ejson::Object::getStringValue(const std::u32string& _name, const std::u32string& _errorValue) const { ejson::String* tmpp = getString(_name); if (NULL == tmpp) { return _errorValue; @@ -323,7 +323,7 @@ etk::UString ejson::Object::getStringValue(const etk::UString& _name, const etk: return tmpp->get(); } -ejson::Boolean* ejson::Object::getBoolean(const etk::UString& _name) const { +ejson::Boolean* ejson::Object::getBoolean(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -331,7 +331,7 @@ ejson::Boolean* ejson::Object::getBoolean(const etk::UString& _name) const { return tmp->toBoolean(); } -bool ejson::Object::getBooleanValue(const etk::UString& _name, bool _errorValue) const { +bool ejson::Object::getBooleanValue(const std::u32string& _name, bool _errorValue) const { ejson::Boolean* tmpp = getBoolean(_name); if (NULL == tmpp) { return _errorValue; @@ -339,7 +339,7 @@ bool ejson::Object::getBooleanValue(const etk::UString& _name, bool _errorValue) return tmpp->get(); } -ejson::Number* ejson::Object::getNumber(const etk::UString& _name) const { +ejson::Number* ejson::Object::getNumber(const std::u32string& _name) const { ejson::Value* tmp = get(_name); if (NULL == tmp) { return NULL; @@ -347,7 +347,7 @@ ejson::Number* ejson::Object::getNumber(const etk::UString& _name) const { return tmp->toNumber(); } -double ejson::Object::getNumberValue(const etk::UString& _name, double _errorValue) const { +double ejson::Object::getNumberValue(const std::u32string& _name, double _errorValue) const { ejson::Number* tmpp = getNumber(_name); if (NULL == tmpp) { return _errorValue; @@ -356,7 +356,7 @@ double ejson::Object::getNumberValue(const etk::UString& _name, double _errorVal } -bool ejson::Object::add(const etk::UString& _name, ejson::Value* _value) { +bool ejson::Object::add(const std::u32string& _name, ejson::Value* _value) { if (NULL == _value) { return false; } @@ -373,19 +373,19 @@ bool ejson::Object::add(const etk::UString& _name, ejson::Value* _value) { return true; } -bool ejson::Object::addString(const etk::UString& _name, const etk::UString& _value) { +bool ejson::Object::addString(const std::u32string& _name, const std::u32string& _value) { return add(_name, new ejson::String(_value)); } -bool ejson::Object::addNull(const etk::UString& _name) { +bool ejson::Object::addNull(const std::u32string& _name) { return add(_name, new ejson::Null()); } -bool ejson::Object::addBoolean(const etk::UString& _name, bool _value) { +bool ejson::Object::addBoolean(const std::u32string& _name, bool _value) { return add(_name, new ejson::Boolean(_value)); } -bool ejson::Object::addNumber(const etk::UString& _name, double _value) { +bool ejson::Object::addNumber(const std::u32string& _name, double _value) { return add(_name, new ejson::Number(_value)); } @@ -417,7 +417,7 @@ ejson::Value* ejson::Object::duplicate(void) const { } for (esize_t iii=0; iii?@[\]^`{|}~ \n\t\r). * @param[in] _val Value to check the conformity. */ - bool checkString(const etk::UChar& _val) const; + bool checkString(char32_t _val) const; /** * @brief check if an number -+.0123456789e). * @param[in] _val Value to check the conformity. */ - bool checkNumber(const etk::UChar& _val) const; + bool checkNumber(char32_t _val) const; /** * @brief count the number of white char in the string from the specify position (stop at the first element that is not a white char) * @param[in] _data Data to parse. @@ -184,7 +184,7 @@ namespace ejson { * @param[out] _filePos new poistion of te file to add. * @return number of white element. */ - int32_t countWhiteChar(const etk::UString& _data, int32_t _pos, ejson::filePos& _filePos) const; + int32_t countWhiteChar(const std::u32string& _data, int32_t _pos, ejson::filePos& _filePos) const; public: /** * @brief Cast the element in a Value if it is possible. diff --git a/ejson/ejson.cpp b/ejson/ejson.cpp index 9af784c..b05de94 100644 --- a/ejson/ejson.cpp +++ b/ejson/ejson.cpp @@ -32,13 +32,13 @@ ejson::Document::~Document(void) { } -bool ejson::Document::iGenerate(etk::UString& _data, int32_t _indent) const { +bool ejson::Document::iGenerate(std::u32string& _data, int32_t _indent) const { ejson::Object::iGenerate(_data, _indent+1); _data += "\n"; return true; } -bool ejson::Document::parse(const etk::UString& _data) { +bool ejson::Document::parse(const std::u32string& _data) { JSON_VERBOSE("Start parsing document (type: string) size=" << _data.size()); clear(); ejson::filePos filePos(1,0); @@ -46,12 +46,12 @@ bool ejson::Document::parse(const etk::UString& _data) { return iParse(_data, parsePos, filePos, *this); } -bool ejson::Document::generate(etk::UString& _data) { +bool ejson::Document::generate(std::u32string& _data) { _data = ""; return iGenerate(_data,0); } -bool ejson::Document::load(const etk::UString& _file) { +bool ejson::Document::load(const std::u32string& _file) { // Start loading the XML : JSON_VERBOSE("open file (xml) \"" << _file << "\""); clear(); @@ -83,7 +83,7 @@ bool ejson::Document::load(const etk::UString& _file) { tmpFile.fileClose(); // convert in UTF8 : - etk::UString tmpDataUnicode(fileBuffer, unicode::charsetUTF8); + std::u32string tmpDataUnicode(fileBuffer, unicode::charsetUTF8); // remove temporary buffer: delete(fileBuffer); // parse the data : @@ -92,8 +92,8 @@ bool ejson::Document::load(const etk::UString& _file) { return ret; } -bool ejson::Document::store(const etk::UString& _file) { - etk::UString createData; +bool ejson::Document::store(const std::u32string& _file) { + std::u32string createData; if (false == generate(createData)) { JSON_ERROR("Error while creating the XML : " << _file); return false; @@ -114,13 +114,13 @@ bool ejson::Document::store(const etk::UString& _file) { } void ejson::Document::display(void) { - etk::UString tmpp; + std::u32string tmpp; iGenerate(tmpp, 0); JSON_INFO("Generated JSON : \n" << tmpp); } -static etk::UString createPosPointer(const etk::UString& _line, int32_t _pos) { - etk::UString out; +static std::u32string createPosPointer(const std::u32string& _line, int32_t _pos) { + std::u32string out; int32_t iii; for (iii=0; iii<_pos && iii<_line.size(); iii++) { if (_line[iii] == '\t') { @@ -149,7 +149,7 @@ void ejson::Document::displayError(void) { #endif } -void ejson::Document::createError(const etk::UString& _data, int32_t _pos, const ejson::filePos& _filePos, const etk::UString& _comment) { +void ejson::Document::createError(const std::u32string& _data, int32_t _pos, const ejson::filePos& _filePos, const std::u32string& _comment) { m_comment = _comment; m_Line = _data.extractLine(_pos); m_filePos = _filePos; @@ -158,7 +158,7 @@ void ejson::Document::createError(const etk::UString& _data, int32_t _pos, const } } -bool ejson::Document::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { +bool ejson::Document::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) { JSON_PARSE_ELEMENT("start parse : 'Document' "); bool haveMainNode=false; bool nodeParsed=false; diff --git a/ejson/ejson.h b/ejson/ejson.h index 5b3555e..99f0eb0 100644 --- a/ejson/ejson.h +++ b/ejson/ejson.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -37,36 +37,36 @@ namespace ejson * @return false : An error occured * @return true : Parsing is OK */ - bool parse(const etk::UString& _data); + bool parse(const std::u32string& _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(etk::UString& _data); + bool generate(std::u32string& _data); /** * @brief Load the file that might contain the xml * @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @return false : An error occured * @return true : Parsing is OK */ - bool load(const etk::UString& _file); + bool load(const std::u32string& _file); /** * @brief Store the Xml in the file * @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @return false : An error occured * @return true : Parsing is OK */ - bool store(const etk::UString& _file); + bool store(const std::u32string& _file); /** * @brief Display the Document on console */ void display(void); private: bool m_writeErrorWhenDetexted; - etk::UString m_comment; - etk::UString m_Line; + std::u32string m_comment; + std::u32string m_Line; ejson::filePos m_filePos; public: void displayErrorWhenDetected(void) { @@ -76,14 +76,14 @@ namespace ejson m_writeErrorWhenDetexted=false; }; - void createError(const etk::UString& _data, int32_t _pos, const ejson::filePos& _filePos, const etk::UString& _comment); + void createError(const std::u32string& _data, int32_t _pos, const ejson::filePos& _filePos, const std::u32string& _comment); void displayError(void); public: // herited function: virtual enum nodeType getType(void) const { return typeDocument; }; - virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); - virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; + virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc); + virtual bool iGenerate(std::u32string& _data, int32_t _indent) const; virtual ejson::Document* toDocument(void) { return this; }; diff --git a/ejson/test.cpp b/ejson/test.cpp index a3377fe..3c7bd05 100644 --- a/ejson/test.cpp +++ b/ejson/test.cpp @@ -6,7 +6,7 @@ * @license BSD v3 (see license file) */ -#include +#include #include #include #include @@ -16,148 +16,148 @@ class testCheck { public: - etk::UString m_ref; - etk::UString m_input; + std::u32string m_ref; + std::u32string m_input; int32_t m_errorPos; // -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? testCheck(void) {}; - void set(const etk::UString& _ref, int32_t _pos, const etk::UString& _input) { + void set(const std::u32string& _ref, int32_t _pos, const std::u32string& _input) { m_ref = _ref; m_input = _input; m_errorPos = _pos; } }; -etk::Vector l_list; +std::vector l_list; void init(void) { - etk::UString reference; - etk::UString input; + std::u32string reference; + std::u32string input; testCheck check; // == ==================================================== check.set("test ejson::Doc", -2, ""); - l_list.pushBack(check); + l_list.push_back(check); // == ==================================================== reference = "{\n}\n"; check.set(reference, -1, "{}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "{ \t\r }\n"); - l_list.pushBack(check); + l_list.push_back(check); // == ==================================================== check.set("test ejson::null", -2, ""); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n\t\"tmpElement\": null\n}\n"; check.set(reference, -1, "{ tmpElement:null }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "{ \t\ntmpElement:null \t\n }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "tmpElement:null\n"); - l_list.pushBack(check); + l_list.push_back(check); // == ==================================================== check.set("test ejson::boolean", -2, ""); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n\t\"tmpElement\": true\n}\n"; check.set(reference, -1, "{ tmpElement:true }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "{ \t\ntmpElement:true \t\n }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "tmpElement:true\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n\t\"tmpElement\": false\n}\n"; check.set(reference, -1, "{ tmpElement:false }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "{ \t\ntmpElement:false \t\n }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "tmpElement:false\n"); - l_list.pushBack(check); + l_list.push_back(check); // == ==================================================== check.set("test ejson::number", -2, ""); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n\t\"tmpElement\": 956256\n}\n"; check.set(reference, -1, "{ tmpElement:956256 }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "{ \t\ntmpElement:956256 \t\n }\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, "tmpElement:956256\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": 956256\n}\n", -1, "{tmpElement:956256}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": -956256\n}\n", -1, "{tmpElement:-956256}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": -956256\n}\n", -1, "{tmpElement:-956256}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": -956.256\n}\n", -1, "{tmpElement:-956.256}\n"); - l_list.pushBack(check); + l_list.push_back(check); /* // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": -956956544454621184\n}\n", -1, "{tmpElement:-956956544454621354.256}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set("{\n\t\"tmpElement\": 0.000002\n}\n", -1, "{tmpElement:+.000001565464}\n"); - l_list.pushBack(check); + l_list.push_back(check); */ // == ==================================================== check.set("test ejson::all", -2, ""); - l_list.pushBack(check); + l_list.push_back(check); // == ==================================================== reference = "{\n" " \"menu\": {\n" @@ -171,7 +171,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n" " \"menu\": {\n" @@ -190,7 +190,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, @@ -220,7 +220,7 @@ void init(void) { " }\n" " }\n" "}\n"); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ check.set(reference, -1, @@ -248,7 +248,7 @@ void init(void) { " ]\n" " }\n" "}\n"); - l_list.pushBack(check); + l_list.push_back(check); ////////////////////////////////////////////////////////////////////////// reference = "{\n" @@ -276,7 +276,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n" " \"menu\": {\n" @@ -294,7 +294,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n" " \"widget\": {\n" @@ -327,7 +327,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n" " \"web-app\": {\n" @@ -423,7 +423,7 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ reference = "{\n" " \"menu\": {\n" @@ -457,12 +457,12 @@ void init(void) { check.set(reference, -1, reference); - l_list.pushBack(check); + l_list.push_back(check); // ------------------------------------------------------ } int main(int argc, const char *argv[]) { - debug::setGeneralLevel(etk::LOG_LEVEL_VERBOSE); + debug::setGeneralLevel(etk::logLevelVerbose); init(); int32_t countError = 0; int32_t countSeparator = 0; @@ -479,7 +479,7 @@ int main(int argc, const char *argv[]) { } sectionID++; ejson::Document doc; - etk::UString out(""); + std::u32string out(""); //JSON_DEBUG("parse : \n" << l_list[iii].m_input); if (false == doc.parse(l_list[iii].m_input)) { if (l_list[iii].m_errorPos == 1) { @@ -518,8 +518,8 @@ int main(int argc, const char *argv[]) { JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } Result in error (normal case)"); } else { JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } different output"); - etk::Vector tmpout = out.split('\n'); - etk::Vector tmpref = l_list[iii].m_ref.split('\n'); + std::vector tmpout = out.split('\n'); + std::vector tmpref = l_list[iii].m_ref.split('\n'); //JSON_ERROR("generate : \n" << out); //JSON_ERROR("reference : \n" << l_list[iii].m_ref); for (int32_t jjj=0; jjj tmpout = out.split('\n'); - etk::Vector tmpref = l_list[iii].m_ref.split('\n'); + std::vector tmpout = out.split('\n'); + std::vector tmpref = l_list[iii].m_ref.split('\n'); //JSON_ERROR("generate : \n" << out); //JSON_ERROR("reference : \n" << l_list[iii].m_ref); for (int32_t jjj=0; jjj