[DEV] integarate std x11
This commit is contained in:
parent
a94a1c6e60
commit
43ddd2549c
@ -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;
|
||||
|
@ -32,7 +32,7 @@ namespace ejson
|
||||
|
||||
};
|
||||
private:
|
||||
etk::Vector<ejson::Value*> m_value; //!< vector of sub elements
|
||||
std::vector<ejson::Value*> 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;
|
||||
};
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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<m_value.size(); ++iii) {
|
||||
ejson::Value* val = m_value.getValue(iii);
|
||||
etk::UString key = m_value.getKey(iii);
|
||||
std::u32string key = m_value.getKey(iii);
|
||||
if (NULL == val) {
|
||||
continue;
|
||||
}
|
||||
|
@ -36,76 +36,76 @@ namespace ejson
|
||||
* @param[in] _name name of the object.
|
||||
* @return The existance of the element.
|
||||
*/
|
||||
bool exist(const etk::UString& _name) const;
|
||||
bool exist(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (no cast check)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Value* get(const etk::UString& _name) const;
|
||||
ejson::Value* get(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as Object if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Object* getObject(const etk::UString& _name) const;
|
||||
ejson::Object* getObject(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as Array if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Array* getArray(const etk::UString& _name) const;
|
||||
ejson::Array* getArray(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as Null if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Null* getNull(const etk::UString& _name) const;
|
||||
ejson::Null* getNull(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as String if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::String* getString(const etk::UString& _name) const;
|
||||
ejson::String* getString(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub string value of the requested element
|
||||
* @param[in] _name name of the object
|
||||
* @return Value of the string or an error string (empty)
|
||||
*/
|
||||
const etk::UString& getStringValue(const etk::UString& _name) const;
|
||||
const std::u32string& getStringValue(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub string value of the requested element (with error return value)
|
||||
* @param[in] _name name of the object
|
||||
* @param[in] _errorValue The return value if the element does not exist.
|
||||
* @return Value of the string or an error string (empty)
|
||||
*/
|
||||
etk::UString getStringValue(const etk::UString& _name, const etk::UString& _errorValue) const;
|
||||
std::u32string getStringValue(const std::u32string& _name, const std::u32string& _errorValue) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as Boolean if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Boolean* getBoolean(const etk::UString& _name) const;
|
||||
ejson::Boolean* getBoolean(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub boolean value of the requested element.
|
||||
* @param[in] _name name of the object.
|
||||
* @param[in] _errorValue The return value if the element does not exist.
|
||||
* @return Value of the Boolean or the _errorValue;
|
||||
*/
|
||||
bool getBooleanValue(const etk::UString& _name, bool _errorValue=false) const;
|
||||
bool getBooleanValue(const std::u32string& _name, bool _errorValue=false) const;
|
||||
/**
|
||||
* @brief get the sub element with his name (Casted as Number if it is possible)
|
||||
* @param[in] _name name of the object
|
||||
* @return pointer on the element requested or NULL if it not the corect type or does not existed
|
||||
*/
|
||||
ejson::Number* getNumber(const etk::UString& _name) const;
|
||||
ejson::Number* getNumber(const std::u32string& _name) const;
|
||||
/**
|
||||
* @brief get the sub Number value of the requested element.
|
||||
* @param[in] _name name of the object.
|
||||
* @param[in] _errorValue The return value if the element does not exist.
|
||||
* @return Value of the Number or the _errorValue;
|
||||
*/
|
||||
double getNumberValue(const etk::UString& _name, double _errorValue=false) const;
|
||||
double getNumberValue(const std::u32string& _name, double _errorValue=false) const;
|
||||
public:
|
||||
/**
|
||||
* @brief add an element in the Object
|
||||
@ -113,37 +113,37 @@ namespace ejson
|
||||
* @param[in] _value Element to add
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool add(const etk::UString& _name, ejson::Value* _value);
|
||||
bool add(const std::u32string& _name, ejson::Value* _value);
|
||||
/**
|
||||
* @brief add a string element in the Object (automatic creation)
|
||||
* @param[in] _name name of the object
|
||||
* @param[in] _value string value to add
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool addString(const etk::UString& _name, const etk::UString& _value);
|
||||
bool addString(const std::u32string& _name, const std::u32string& _value);
|
||||
/**
|
||||
* @brief add a "null" element in the Object (automatic creation)
|
||||
* @param[in] _name name of the object
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool addNull(const etk::UString& _name);
|
||||
bool addNull(const std::u32string& _name);
|
||||
/**
|
||||
* @brief add a boolean element in the Object (automatic creation)
|
||||
* @param[in] _name name of the object
|
||||
* @param[in] _value boolean value to add
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool addBoolean(const etk::UString& _name, bool _value);
|
||||
bool addBoolean(const std::u32string& _name, bool _value);
|
||||
/**
|
||||
* @brief add a double element in the Object (automatic creation)
|
||||
* @param[in] _name name of the object
|
||||
* @param[in] _value double value to add
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool addNumber(const etk::UString& _name, double _value);
|
||||
bool addNumber(const std::u32string& _name, 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 typeObject;
|
||||
};
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
|
||||
bool ejson::String::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
|
||||
bool ejson::String::iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
|
||||
JSON_PARSE_ELEMENT("start parse : 'String' ");
|
||||
for (int32_t iii=_pos+1; iii<_data.size(); iii++) {
|
||||
_filePos.check(_data[iii]);
|
||||
@ -40,7 +40,7 @@ bool ejson::String::iParse(const etk::UString& _data, int32_t& _pos, ejson::file
|
||||
}
|
||||
|
||||
|
||||
bool ejson::String::iGenerate(etk::UString& _data, int32_t _indent) const {
|
||||
bool ejson::String::iGenerate(std::u32string& _data, int32_t _indent) const {
|
||||
_data += "\"";;
|
||||
_data += m_value;
|
||||
_data += "\"";;
|
||||
|
@ -22,27 +22,27 @@ namespace ejson
|
||||
/**
|
||||
* @brief basic element of a xml structure
|
||||
*/
|
||||
String(const etk::UString& _value="") : m_value(_value) { };
|
||||
String(const std::u32string& _value="") : m_value(_value) { };
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
virtual ~String(void) { };
|
||||
protected:
|
||||
etk::UString m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
|
||||
std::u32string 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.
|
||||
*/
|
||||
void set(const etk::UString& _value) { m_value = _value; };
|
||||
void set(const std::u32string& _value) { m_value = _value; };
|
||||
/**
|
||||
* @brief get the current element Value.
|
||||
* @return the reference of the string value.
|
||||
*/
|
||||
const etk::UString& get(void) const { return m_value; };
|
||||
const std::u32string& get(void) const { 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;
|
||||
};
|
||||
|
@ -28,13 +28,13 @@ etk::CCout& ejson::operator <<(etk::CCout& _os, const ejson::filePos& _obj) {
|
||||
}
|
||||
|
||||
|
||||
void ejson::Value::addIndent(etk::UString& _data, int32_t _indent) const {
|
||||
void ejson::Value::addIndent(std::u32string& _data, int32_t _indent) const {
|
||||
for (int32_t iii=0; iii<_indent; iii++) {
|
||||
_data+="\t";
|
||||
}
|
||||
}
|
||||
|
||||
void ejson::Value::drawElementParsed(const etk::UChar& _val, const ejson::filePos& _filePos) const {
|
||||
void ejson::Value::drawElementParsed(char32_t _val, const ejson::filePos& _filePos) const {
|
||||
if (_val == '\n') {
|
||||
JSON_DEBUG(_filePos << " parse '\\n'");
|
||||
} else if (_val == '\t') {
|
||||
@ -44,7 +44,7 @@ void ejson::Value::drawElementParsed(const etk::UChar& _val, const ejson::filePo
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ejson::Value::countWhiteChar(const etk::UString& _data, int32_t _pos, ejson::filePos& _filePos) const {
|
||||
int32_t ejson::Value::countWhiteChar(const std::u32string& _data, int32_t _pos, ejson::filePos& _filePos) const {
|
||||
_filePos.clear();
|
||||
int32_t white=0;
|
||||
for (int32_t iii=_pos; iii<_data.size(); iii++) {
|
||||
@ -60,7 +60,7 @@ int32_t ejson::Value::countWhiteChar(const etk::UString& _data, int32_t _pos, ej
|
||||
}
|
||||
|
||||
|
||||
bool ejson::Value::checkString(const etk::UChar& _val) const {
|
||||
bool ejson::Value::checkString(char32_t _val) const {
|
||||
if( _val == '!'
|
||||
|| _val == '"'
|
||||
|| _val == '#'
|
||||
@ -99,7 +99,7 @@ bool ejson::Value::checkString(const etk::UChar& _val) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ejson::Value::checkNumber(const etk::UChar& _val) const {
|
||||
bool ejson::Value::checkNumber(char32_t _val) const {
|
||||
if( _val == '-'
|
||||
|| _val == '+'
|
||||
|| _val == 'e'
|
||||
|
@ -94,7 +94,7 @@ namespace ejson {
|
||||
m_col=0;
|
||||
m_line++;
|
||||
};
|
||||
bool check(const etk::UChar& _val) {
|
||||
bool check(char32_t _val) {
|
||||
m_col++;
|
||||
if (_val == '\n') {
|
||||
newLine();
|
||||
@ -138,14 +138,14 @@ namespace ejson {
|
||||
* @param[in,out] file parsing position (line x col x)
|
||||
* @return false if an error occured.
|
||||
*/
|
||||
virtual bool iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) = 0;
|
||||
virtual bool iParse(const std::u32string& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::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] current indentation of the file
|
||||
* @return false if an error occured.
|
||||
*/
|
||||
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const = 0;
|
||||
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const = 0;
|
||||
public:
|
||||
/**
|
||||
* @brief get the node type.
|
||||
@ -160,23 +160,23 @@ namespace ejson {
|
||||
* @param[in,out] _data String where the indentation is done.
|
||||
* @param[in] _indent Number of tab to add at the string.
|
||||
*/
|
||||
void addIndent(etk::UString& _data, int32_t _indent) const;
|
||||
void addIndent(std::u32string& _data, int32_t _indent) const;
|
||||
/**
|
||||
* @brief Display the cuurent element that is curently parse.
|
||||
* @param[in] _val Char that is parsed.
|
||||
* @param[in] _filePos Position of the char in the file.
|
||||
*/
|
||||
void drawElementParsed(const etk::UChar& _val, const ejson::filePos& _filePos) const;
|
||||
void drawElementParsed(char32_t _val, const ejson::filePos& _filePos) const;
|
||||
/**
|
||||
* @brief check if an name (for object named) (not : !"#$%&'()*+,/;<=>?@[\]^`{|}~ \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.
|
||||
|
@ -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;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <ejson/Value.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <vector>
|
||||
#include <etk/UString.h>
|
||||
#include <ejson/String.h>
|
||||
#include <ejson/Array.h>
|
||||
@ -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;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/Vector.h>
|
||||
#include <vector>
|
||||
#include <etk/UString.h>
|
||||
#include <ejson/debug.h>
|
||||
#include <ejson/ejson.h>
|
||||
@ -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<testCheck> l_list;
|
||||
std::vector<testCheck> 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<etk::UString> tmpout = out.split('\n');
|
||||
etk::Vector<etk::UString> tmpref = l_list[iii].m_ref.split('\n');
|
||||
std::vector<std::u32string> tmpout = out.split('\n');
|
||||
std::vector<std::u32string> 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.size() || jjj<tmpref.size(); ++jjj) {
|
||||
@ -538,8 +538,8 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
if (l_list[iii].m_errorPos == 3) {
|
||||
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR} checking result might be in error...");
|
||||
etk::Vector<etk::UString> tmpout = out.split('\n');
|
||||
etk::Vector<etk::UString> tmpref = l_list[iii].m_ref.split('\n');
|
||||
std::vector<std::u32string> tmpout = out.split('\n');
|
||||
std::vector<std::u32string> 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.size() || jjj<tmpref.size(); ++jjj) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user