[DEV] change coding style

This commit is contained in:
Edouard DUPIN 2013-10-03 23:06:37 +02:00
parent 299ca3e6b2
commit a788a3c450
17 changed files with 660 additions and 747 deletions

View File

@ -20,104 +20,102 @@
#define __class__ "Array"
void ejson::Array::Clear(void)
{
for (esize_t iii=0; iii<m_value.Size(); ++iii) {
void ejson::Array::clear(void) {
for (esize_t iii=0; iii<m_value.size(); ++iii) {
if (NULL == m_value[iii]) {
continue;
}
delete(m_value[iii]);
m_value[iii] = NULL;
}
m_value.Clear();
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 etk::UString& _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]);
for (int32_t iii=_pos+1; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
ejson::filePos tmpPos;
if( _data[iii]==' '
|| _data[iii]=='\t'
|| _data[iii]=='\n'
|| _data[iii]=='\r') {
// white space ==> nothing to do ...
} else if(_data[iii]==']') {
if( _data[iii] == ' '
|| _data[iii] == '\t'
|| _data[iii] == '\n'
|| _data[iii] == '\r') {
// white space == > nothing to do ...
} else if(_data[iii] == ']') {
// find end of value:
_pos=iii; // ==> return the end element type ==> usefull to check end and check if adding element is needed
_pos=iii; // == > return the end element type ==> usefull to check end and check if adding element is needed
return true;
} else if (_data[iii]=='{') {
} else if (_data[iii] == '{') {
// find an object:
JSON_PARSE_ELEMENT("find Object");
ejson::Object * tmpElement = new ejson::Object();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in object");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
} else if (_data[iii]=='"') {
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if (_data[iii] == '"') {
// find a string:
JSON_PARSE_ELEMENT("find String quoted");
ejson::String * tmpElement = new ejson::String();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in String");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
} else if (_data[iii]=='[') {
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if (_data[iii] == '[') {
// find a list:
JSON_PARSE_ELEMENT("find List");
ejson::Array * tmpElement = new ejson::Array();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Array");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if( _data[iii] == 'f'
|| _data[iii] == 't' ) {
// find boolean:
JSON_PARSE_ELEMENT("find Boolean");
ejson::Boolean * tmpElement = new ejson::Boolean();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if( _data[iii] == 'n') {
// find null:
JSON_PARSE_ELEMENT("find Null");
ejson::Null * tmpElement = new ejson::Null();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
} else if(true==CheckNumber(_data[iii])) {
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if(true == checkNumber(_data[iii])) {
// find number:
JSON_PARSE_ELEMENT("find Number");
ejson::Number * tmpElement = new ejson::Number();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
m_value.PushBack(tmpElement);
} else if(_data[iii]==',') {
tmpElement->iParse(_data, iii, _filePos, _doc);
m_value.pushBack(tmpElement);
} else if(_data[iii] == ',') {
// find Separator : Restart cycle ...
// TODO : check if element are separated with ','
} else {
@ -128,34 +126,33 @@ bool ejson::Array::IParse(const etk::UString& _data, int32_t& _pos, ejson::fileP
return false;
}
}
_pos = _data.Size();
_pos = _data.size();
return false;
}
bool ejson::Array::IGenerate(etk::UString& _data, int32_t _indent) const
{
bool ejson::Array::iGenerate(etk::UString& _data, int32_t _indent) const {
bool oneLine=true;
if (m_value.Size()>3) {
if (m_value.size()>3) {
oneLine=false;
} else {
for (esize_t iii=0; iii<m_value.Size() ; iii++) {
for (esize_t iii=0; iii<m_value.size() ; iii++) {
ejson::Value* tmp = m_value[iii];
if (tmp == NULL) {
continue;
}
if (true==tmp->IsObject()) {
if (true == tmp->isObject()) {
oneLine=false;
break;
}
if (true==tmp->IsArray()) {
if (true == tmp->isArray()) {
oneLine=false;
break;
}
if (true==tmp->IsString()) {
ejson::String* tmp2 = tmp->ToString();
if (true == tmp->isString()) {
ejson::String* tmp2 = tmp->toString();
if (NULL!=tmp2) {
if(tmp2->Get().Size()>40) {
if(tmp2->get().size()>40) {
oneLine=false;
break;
}
@ -163,192 +160,175 @@ bool ejson::Array::IGenerate(etk::UString& _data, int32_t _indent) const
}
}
}
if (true==oneLine) {
if (true == oneLine) {
_data += "[ ";
} else {
_data += "[\n";
}
for (esize_t iii=0; iii<m_value.Size() ; iii++) {
if (false==oneLine) {
AddIndent(_data, _indent);
for (esize_t iii=0; iii<m_value.size() ; iii++) {
if (false == oneLine) {
addIndent(_data, _indent);
}
if (NULL != m_value[iii]) {
m_value[iii]->IGenerate(_data, _indent+1);
if (iii<m_value.Size()-1) {
m_value[iii]->iGenerate(_data, _indent+1);
if (iii<m_value.size()-1) {
_data += ",";
}
}
if (true==oneLine) {
if (true == oneLine) {
_data += " ";
} else {
_data += "\n";
}
}
if (false==oneLine) {
AddIndent(_data, _indent-1);
if (false == oneLine) {
addIndent(_data, _indent-1);
}
_data += "]";
return true;
}
bool ejson::Array::Add(ejson::Value* _element)
{
if (NULL==_element) {
bool ejson::Array::add(ejson::Value* _element) {
if (NULL == _element) {
JSON_ERROR("Request add on an NULL pointer");
return false;
}
m_value.PushBack(_element);
m_value.pushBack(_element);
return true;
}
bool ejson::Array::AddString(const etk::UString& _value)
{
return Add(new ejson::String(_value));
bool ejson::Array::addString(const etk::UString& _value) {
return add(new ejson::String(_value));
}
bool ejson::Array::AddNull(void)
{
return Add(new ejson::Null());
bool ejson::Array::addNull(void) {
return add(new ejson::Null());
}
bool ejson::Array::AddBoolean(bool _value)
{
return Add(new ejson::Boolean(_value));
bool ejson::Array::addBoolean(bool _value) {
return add(new ejson::Boolean(_value));
}
bool ejson::Array::AddNumber(double _value)
{
return Add(new ejson::Number(_value));
bool ejson::Array::addNumber(double _value) {
return add(new ejson::Number(_value));
}
bool ejson::Array::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::Array::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::Array* other = _obj->ToArray();
if (NULL==other) {
ejson::Array* other = _obj->toArray();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an array");
return false;
}
// remove destination elements
other->Clear();
other->clear();
// Copy to the destination
other->m_value = m_value;
// remove current:
m_value.Clear();
m_value.clear();
return true;
}
// TODO : Manage error ...
ejson::Value* ejson::Array::Duplicate(void) const
{
ejson::Value* ejson::Array::duplicate(void) const {
ejson::Array* output = new ejson::Array();
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}
for (esize_t iii=0; iii<m_value.Size(); ++iii) {
for (esize_t iii=0; iii<m_value.size(); ++iii) {
ejson::Value* val = m_value[iii];
if (NULL == val) {
continue;
}
output->Add(val->Duplicate());
output->add(val->duplicate());
}
return output;
}
ejson::Object* ejson::Array::GetObject(esize_t _id)
{
ejson::Object* ejson::Array::getObject(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToObject();
return tmpElement->toObject();
}
ejson::String* ejson::Array::GetString(esize_t _id)
{
ejson::String* ejson::Array::getString(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToString();
return tmpElement->toString();
}
ejson::Array* ejson::Array::GetArray(esize_t _id)
{
ejson::Array* ejson::Array::getArray(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToArray();
return tmpElement->toArray();
}
ejson::Null* ejson::Array::GetNull(esize_t _id)
{
ejson::Null* ejson::Array::getNull(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToNull();
return tmpElement->toNull();
}
ejson::Number* ejson::Array::GetNumber(esize_t _id)
{
ejson::Number* ejson::Array::getNumber(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToNumber();
return tmpElement->toNumber();
}
ejson::Boolean* ejson::Array::GetBoolean(esize_t _id)
{
ejson::Boolean* ejson::Array::getBoolean(esize_t _id) {
ejson::Value* tmpElement = m_value[_id];
if (NULL == tmpElement) {
return NULL;
}
return tmpElement->ToBoolean();
return tmpElement->toBoolean();
}
const etk::UString& ejson::Array::GetStringValue(esize_t _id)
{
const etk::UString& ejson::Array::getStringValue(esize_t _id) {
static const etk::UString errorValue("");
ejson::String* tmpElement = GetString(_id);
ejson::String* tmpElement = getString(_id);
if (NULL == tmpElement) {
return errorValue;
}
return tmpElement->Get();
return tmpElement->get();
}
etk::UString ejson::Array::GetStringValue(esize_t _id, const etk::UString& _errorValue)
{
ejson::String* tmpElement = GetString(_id);
etk::UString ejson::Array::getStringValue(esize_t _id, const etk::UString& _errorValue) {
ejson::String* tmpElement = getString(_id);
if (NULL == tmpElement) {
return _errorValue;
}
return tmpElement->Get();
return tmpElement->get();
}
double ejson::Array::GetNumberValue(esize_t _id, double _errorValue)
{
ejson::Number* tmpElement = GetNumber(_id);
double ejson::Array::getNumberValue(esize_t _id, double _errorValue) {
ejson::Number* tmpElement = getNumber(_id);
if (NULL == tmpElement) {
return _errorValue;
}
return tmpElement->Get();
return tmpElement->get();
}
bool ejson::Array::GetBooleanValue(esize_t _id, bool _errorValue)
{
ejson::Boolean* tmpElement = GetBoolean(_id);
bool ejson::Array::getBooleanValue(esize_t _id, bool _errorValue) {
ejson::Boolean* tmpElement = getBoolean(_id);
if (NULL == tmpElement) {
return _errorValue;
}
return tmpElement->Get();
return tmpElement->get();
}

View File

@ -31,119 +31,119 @@ namespace ejson
etk::Vector<ejson::Value*> m_value; //!< vector of sub elements
public:
/**
* @brief Get the number of sub element in the current one
* @brief get the number of sub element in the current one
* @return the Number of stored element
*/
esize_t Size(void) const { return m_value.Size(); };
esize_t size(void) const { return m_value.size(); };
/**
* @brief Get the pointer on an element reference with his ID.
* @brief get the pointer on an element reference with his ID.
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
const ejson::Value* Get(esize_t _id) const { return m_value[_id]; };
ejson::Value* Get(esize_t _id) { return m_value[_id]; };
const ejson::Value* get(esize_t _id) const { return m_value[_id]; };
ejson::Value* get(esize_t _id) { return m_value[_id]; };
/**
* @brief Get the pointer on an element reference with his ID (casted in Object if it is an object).
* @brief get the pointer on an element reference with his ID (casted in Object if it is an object).
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
ejson::Object* GetObject(esize_t _id);
ejson::Object* getObject(esize_t _id);
/**
* @brief Get the pointer on an element reference with his ID (casted in String if it is an String).
* @brief get the pointer on an element reference with his ID (casted in String if it is an String).
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
ejson::String* GetString(esize_t _id);
ejson::String* getString(esize_t _id);
/**
* @brief Get the value of the string element (if not a string return "")
* @brief get the value of the string element (if not a string return "")
* @param[in] _id Id of the element.
* @return value of the element.
*/
const etk::UString& GetStringValue(esize_t _id);
const etk::UString& getStringValue(esize_t _id);
/**
* @brief Get the value of the string element
* @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);
etk::UString getStringValue(esize_t _id, const etk::UString& _errorValue);
/**
* @brief Get the pointer on an element reference with his ID (casted in Array if it is an Array).
* @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.
* @return NULL if the element does not exist.
*/
ejson::Array* GetArray(esize_t _id);
ejson::Array* getArray(esize_t _id);
/**
* @brief Get the pointer on an element reference with his ID (casted in Null if it is an Null).
* @brief get the pointer on an element reference with his ID (casted in Null if it is an Null).
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
ejson::Null* GetNull(esize_t _id);
ejson::Null* getNull(esize_t _id);
/**
* @brief Get the pointer on an element reference with his ID (casted in Number if it is an Number).
* @brief get the pointer on an element reference with his ID (casted in Number if it is an Number).
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
ejson::Number* GetNumber(esize_t _id);
ejson::Number* getNumber(esize_t _id);
/**
* @brief Get the value of the Number element
* @brief get the value of the Number 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.
*/
double GetNumberValue(esize_t _id, double _errorValue);
double getNumberValue(esize_t _id, double _errorValue);
/**
* @brief Get the pointer on an element reference with his ID (casted in Boolean if it is an Boolean).
* @brief get the pointer on an element reference with his ID (casted in Boolean if it is an Boolean).
* @param[in] _id Id of the element.
* @return NULL if the element does not exist.
*/
ejson::Boolean* GetBoolean(esize_t _id);
ejson::Boolean* getBoolean(esize_t _id);
/**
* @brief Get the value of the Boolean element
* @brief get the value of the Boolean 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.
*/
bool GetBooleanValue(esize_t _id, bool _errorValue);
bool getBooleanValue(esize_t _id, bool _errorValue);
/**
* @brief Add an element on the array.
* @brief add an element on the array.
* @param[in] _element element to add.
* @return false if an error occured.
*/
bool Add(ejson::Value* _element);
bool add(ejson::Value* _element);
/**
* @brief Add a string element in the Object (automatic creation)
* @brief add a string element in the Object (automatic creation)
* @param[in] _value string value to add
* @return false if an error occured
*/
bool AddString(const etk::UString& _value);
bool addString(const etk::UString& _value);
/**
* @brief Add a "null" element in the Object (automatic creation)
* @brief add a "null" element in the Object (automatic creation)
* @return false if an error occured
*/
bool AddNull(void);
bool addNull(void);
/**
* @brief Add a boolean element in the Object (automatic creation)
* @brief add a boolean element in the Object (automatic creation)
* @param[in] _value boolean value to add
* @return false if an error occured
*/
bool AddBoolean(bool _value);
bool addBoolean(bool _value);
/**
* @brief Add a double element in the Object (automatic creation)
* @brief add a double element in the Object (automatic creation)
* @param[in] _value double value to add
* @return false if an error occured
*/
bool AddNumber(double _value);
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 nodeType_te GetType(void) const { return typeArray; };
virtual ejson::Array* ToArray(void) { return this; };
virtual const ejson::Array* ToArray(void) const{ return this; };
virtual void Clear(void);
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeArray; };
virtual ejson::Array* toArray(void) { return this; };
virtual const ejson::Array* toArray(void) const{ return this; };
virtual void clear(void);
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -13,11 +13,10 @@
#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 etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
JSON_PARSE_ELEMENT("start parse : 'Boolean' ");
if( _data[_pos] == 't'
&& _pos+3 < _data.Size()
&& _pos+3 < _data.size()
&& _data[_pos+1] == 'r'
&& _data[_pos+2] == 'u'
&& _data[_pos+3] == 'e'){
@ -27,7 +26,7 @@ bool ejson::Boolean::IParse(const etk::UString& _data, int32_t& _pos, ejson::fil
return true;
}
if( _data[_pos] == 'f'
&& _pos+4 < _data.Size()
&& _pos+4 < _data.size()
&& _data[_pos+1] == 'a'
&& _data[_pos+2] == 'l'
&& _data[_pos+3] == 's'
@ -42,9 +41,8 @@ bool ejson::Boolean::IParse(const etk::UString& _data, int32_t& _pos, ejson::fil
}
bool ejson::Boolean::IGenerate(etk::UString& _data, int32_t _indent) const
{
if (true==m_value) {
bool ejson::Boolean::iGenerate(etk::UString& _data, int32_t _indent) const {
if (true == m_value) {
_data += "true";
} else {
_data += "false";
@ -53,14 +51,13 @@ bool ejson::Boolean::IGenerate(etk::UString& _data, int32_t _indent) const
}
bool ejson::Boolean::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::Boolean::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::Boolean* other = _obj->ToBoolean();
if (NULL==other) {
ejson::Boolean* other = _obj->toBoolean();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an Boolean");
return false;
}
@ -70,10 +67,9 @@ bool ejson::Boolean::TransfertIn(ejson::Value* _obj)
return true;
}
ejson::Value* ejson::Boolean::Duplicate(void) const
{
ejson::Value* ejson::Boolean::duplicate(void) const {
ejson::Boolean* output = new ejson::Boolean(m_value);
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}

View File

@ -31,23 +31,23 @@ namespace ejson
bool m_value; //!< value of the node
public:
/**
* @brief Set the value of the node.
* @brief set the value of the node.
* @param[in] _value New value of the node.
*/
void Set(bool _value) { m_value = _value; };
void set(bool _value) { m_value = _value; };
/**
* @brief Get the current element Value.
* @brief get the current element Value.
* @return the reference of the string value.
*/
bool Get(void) const { return m_value; };
bool 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 nodeType_te GetType(void) const { return typeString; };
virtual ejson::Boolean* ToBoolean(void) { return this; };
virtual const ejson::Boolean* ToBoolean(void) const{ return this; };
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeString; };
virtual ejson::Boolean* toBoolean(void) { return this; };
virtual const ejson::Boolean* toBoolean(void) const{ return this; };
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -14,10 +14,9 @@
#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 etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
JSON_PARSE_ELEMENT("start parse : 'Null' ");
if (_pos+3 >= _data.Size()){
if (_pos+3 >= _data.size()){
EJSON_CREATE_ERROR(_doc, _data, _pos, _filePos, "can not parse null !!! ");
return false;
}
@ -34,31 +33,28 @@ 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(etk::UString& _data, int32_t _indent) const {
_data += "null";
return true;
}
bool ejson::Null::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::Null::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::Null* other = _obj->ToNull();
if (NULL==other) {
ejson::Null* other = _obj->toNull();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an Null");
return false;
}
return true;
}
ejson::Value* ejson::Null::Duplicate(void) const
{
ejson::Value* ejson::Null::duplicate(void) const {
ejson::Null* output = new ejson::Null();
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}

View File

@ -28,13 +28,13 @@ 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 nodeType_te GetType(void) const { return typeString; };
virtual ejson::Null* ToNull(void) { return this; };
virtual const ejson::Null* ToNull(void) const{ return this; };
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeString; };
virtual ejson::Null* toNull(void) { return this; };
virtual const ejson::Null* toNull(void) const{ return this; };
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -14,45 +14,42 @@
#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 etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
JSON_PARSE_ELEMENT("start parse : 'Number' ");
etk::UString tmpVal;
for (int32_t iii=_pos; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
for (int32_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
if(true==CheckNumber(_data[iii])) {
if(true == checkNumber(_data[iii])) {
tmpVal+=_data[iii];
} else {
_pos = iii-1;
m_value = tmpVal.ToDouble();
m_value = tmpVal.toDouble();
JSON_PARSE_ELEMENT("end parse : 'Number' ");
return true;
}
}
_pos=_data.Size();
_pos=_data.size();
EJSON_CREATE_ERROR(_doc, _data, _pos, _filePos, "get end of string whithout fincding end of quote");
return false;
}
bool ejson::Number::IGenerate(etk::UString& _data, int32_t _indent) const
{
bool ejson::Number::iGenerate(etk::UString& _data, int32_t _indent) const {
_data += m_value;
return true;
}
bool ejson::Number::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::Number::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::Number* other = _obj->ToNumber();
if (NULL==other) {
ejson::Number* other = _obj->toNumber();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an Number");
return false;
}
@ -62,10 +59,9 @@ bool ejson::Number::TransfertIn(ejson::Value* _obj)
return true;
}
ejson::Value* ejson::Number::Duplicate(void) const
{
ejson::Value* ejson::Number::duplicate(void) const {
ejson::Number* output = new ejson::Number(m_value);
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}

View File

@ -31,25 +31,25 @@ namespace ejson
double m_value; //!< value of the node
public:
/**
* @brief Set the value of the node.
* @brief set the value of the node.
* @param[in] _value New value of the node.
*/
void Set(double _value) { m_value = _value; };
void set(double _value) { m_value = _value; };
/**
* @brief Get the current element Value.
* @brief get the current element Value.
* @return the reference of the string value.
*/
double Get(void) const { return m_value; };
int32_t GetInt32(void) const { return (int32_t)m_value; };
int64_t GetInt64(void) const { return (int64_t)m_value; };
double get(void) const { return m_value; };
int32_t getInt32(void) const { return (int32_t)m_value; };
int64_t getInt64(void) const { 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 nodeType_te GetType(void) const { return typeString; };
virtual ejson::Number* ToNumber(void) { return this; };
virtual const ejson::Number* ToNumber(void) const{ return this; };
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeString; };
virtual ejson::Number* toNumber(void) { return this; };
virtual const ejson::Number* toNumber(void) const{ return this; };
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -19,16 +19,15 @@
#undef __class__
#define __class__ "Object"
void ejson::Object::Clear(void)
{
for (esize_t iii=0; iii<m_value.Size(); ++iii) {
void ejson::Object::clear(void) {
for (esize_t iii=0; iii<m_value.size(); ++iii) {
if (NULL == m_value[iii]) {
continue;
}
delete(m_value[iii]);
m_value[iii] = NULL;
}
m_value.Clear();
m_value.clear();
}
@ -38,8 +37,7 @@ typedef enum {
parseValue,
} statusParsing_te;
bool ejson::Object::IParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc)
{
bool ejson::Object::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
statusParsing_te mode = parseName;
etk::UString currentName;
JSON_PARSE_ELEMENT("start parse : 'Object' ");
@ -49,46 +47,46 @@ bool ejson::Object::IParse(const etk::UString& _data, int32_t& _pos, ejson::file
standalone = false;
startPos = _pos;
}
for (int32_t iii=startPos; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
for (int32_t iii=startPos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
ejson::filePos tmpPos;
if( _data[iii]==' '
|| _data[iii]=='\t'
|| _data[iii]=='\n'
|| _data[iii]=='\r') {
// white space ==> nothing to do ...
} else if(_data[iii]=='}') {
if( _data[iii] == ' '
|| _data[iii] == '\t'
|| _data[iii] == '\n'
|| _data[iii] == '\r') {
// white space == > nothing to do ...
} else if(_data[iii] == '}') {
// find end of value:
_pos=iii; // ==> return the end element type ==> usefull to check end and check if adding element is needed
_pos=iii; // == > return the end element type ==> usefull to check end and check if adding element is needed
return true;
} else {
if (mode == parseName) {
JSON_PARSE_ELEMENT("name START " << '"');
if (_data[iii]=='"') {
if (_data[iii] == '"') {
currentName = "";
for (iii++; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
for (iii++; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
if (_data[iii]=='\"') {
if (_data[iii] == '\"') {
mode = parseMiddle;
break;
} else {
currentName += _data[iii];
}
}
} else if (CheckString(_data[iii]) ) {
} else if (checkString(_data[iii]) ) {
currentName += _data[iii];
for (iii++; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
for (iii++; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
if (false==CheckString(_data[iii])) {
if (false == checkString(_data[iii])) {
mode = parseMiddle;
iii--;
break;
@ -104,87 +102,87 @@ bool ejson::Object::IParse(const etk::UString& _data, int32_t& _pos, ejson::file
JSON_PARSE_ELEMENT("name END ");
} else if (mode == parseMiddle) {
JSON_PARSE_ELEMENT(" middle ... ");
if (_data[iii]==':') {
if (_data[iii] == ':') {
mode = parseValue;
} else {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "separator is not ':'");
return false;
}
} else if (mode == parseValue) {
if (_data[iii]=='{') {
if (_data[iii] == '{') {
// find an object:
JSON_PARSE_ELEMENT("find Object");
ejson::Object * tmpElement = new ejson::Object();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in object");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if (_data[iii]=='"') {
} else if (_data[iii] == '"') {
// find a string:
JSON_PARSE_ELEMENT("find String quoted");
ejson::String * tmpElement = new ejson::String();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in String");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if (_data[iii]=='[') {
} else if (_data[iii] == '[') {
// find a list:
JSON_PARSE_ELEMENT("find List");
ejson::Array * tmpElement = new ejson::Array();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Array");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if( _data[iii] == 'f'
|| _data[iii] == 't' ) {
// find boolean:
JSON_PARSE_ELEMENT("find Boolean");
ejson::Boolean * tmpElement = new ejson::Boolean();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if( _data[iii] == 'n') {
// find null:
JSON_PARSE_ELEMENT("find Null");
ejson::Null * tmpElement = new ejson::Null();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if(true==CheckNumber(_data[iii])) {
} else if(true == checkNumber(_data[iii])) {
// find number:
JSON_PARSE_ELEMENT("find Number");
ejson::Number * tmpElement = new ejson::Number();
if (NULL==tmpElement) {
if (NULL == tmpElement) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
return false;
}
tmpElement->IParse(_data, iii, _filePos, _doc);
Add(currentName, tmpElement);
tmpElement->iParse(_data, iii, _filePos, _doc);
add(currentName, tmpElement);
currentName = "";
} else if(_data[iii]==',') {
} else if(_data[iii] == ',') {
// find Separator : Restart cycle ...
mode = parseName;
currentName = "";
@ -198,38 +196,37 @@ bool ejson::Object::IParse(const etk::UString& _data, int32_t& _pos, ejson::file
}
}
}
_pos = _data.Size();
if (false==standalone) {
_pos = _data.size();
if (false == standalone) {
return true;
}
return false;
}
bool ejson::Object::IGenerate(etk::UString& _data, int32_t _indent) const
{
bool ejson::Object::iGenerate(etk::UString& _data, int32_t _indent) const {
bool oneLine=true;
if (m_value.Size()>3) {
if (m_value.size()>3) {
oneLine=false;
} else if (_indent<=1) {
oneLine=false;
} else {
for (esize_t iii=0; iii<m_value.Size() ; iii++) {
for (esize_t iii=0; iii<m_value.size() ; iii++) {
ejson::Value* tmp = m_value[iii];
if (tmp == NULL) {
continue;
}
if (true==tmp->IsObject()) {
if (true == tmp->isObject()) {
oneLine=false;
break;
}
if (true==tmp->IsArray()) {
if (true == tmp->isArray()) {
oneLine=false;
break;
}
if (true==tmp->IsString()) {
ejson::String* tmp2 = tmp->ToString();
if (true == tmp->isString()) {
ejson::String* tmp2 = tmp->toString();
if (NULL!=tmp2) {
if( tmp2->Get().Size()>25
|| m_value.GetKey(iii).Size()>25) {
if( tmp2->get().size()>25
|| m_value.getKey(iii).size()>25) {
oneLine=false;
break;
}
@ -237,213 +234,194 @@ bool ejson::Object::IGenerate(etk::UString& _data, int32_t _indent) const
}
}
}
if (true==oneLine) {
if (true == oneLine) {
_data += "{ ";
} else {
_data += "{\n";
}
for (esize_t iii=0; iii<m_value.Size() ; iii++) {
if (false==oneLine) {
AddIndent(_data, _indent);
for (esize_t iii=0; iii<m_value.size() ; iii++) {
if (false == oneLine) {
addIndent(_data, _indent);
}
_data += "\"";
_data += m_value.GetKey(iii);
_data += m_value.getKey(iii);
_data += "\": ";
m_value.GetValue(iii)->IGenerate(_data, _indent+1);
if (iii<m_value.Size()-1) {
m_value.getValue(iii)->iGenerate(_data, _indent+1);
if (iii<m_value.size()-1) {
_data += ",";
}
if (true==oneLine) {
if (true == oneLine) {
_data += " ";
} else {
_data += "\n";
}
}
if (false==oneLine) {
AddIndent(_data, _indent-1);
if (false == oneLine) {
addIndent(_data, _indent-1);
}
_data += "}";
return true;
}
bool ejson::Object::Exist(const etk::UString& _name) const
{
return m_value.Exist(_name);
bool ejson::Object::exist(const etk::UString& _name) const {
return m_value.exist(_name);
}
ejson::Value* ejson::Object::Get(const etk::UString& _name) const
{
if (false==m_value.Exist(_name)) {
ejson::Value* ejson::Object::get(const etk::UString& _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::Value* tmp = Get(_name);
ejson::Object* ejson::Object::getObject(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToObject();
return tmp->toObject();
}
ejson::Array* ejson::Object::GetArray(const etk::UString& _name) const
{
ejson::Value* tmp = Get(_name);
ejson::Array* ejson::Object::getArray(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToArray();
return tmp->toArray();
}
ejson::Null* ejson::Object::GetNull(const etk::UString& _name) const
{
ejson::Value* tmp = Get(_name);
ejson::Null* ejson::Object::getNull(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToNull();
return tmp->toNull();
}
ejson::String* ejson::Object::GetString(const etk::UString& _name) const
{
ejson::Value* tmp = Get(_name);
ejson::String* ejson::Object::getString(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToString();
return tmp->toString();
}
const etk::UString& ejson::Object::GetStringValue(const etk::UString& _name) const
{
const etk::UString& ejson::Object::getStringValue(const etk::UString& _name) const {
static const etk::UString errorString("");
ejson::String* tmpp = GetString(_name);
if (NULL==tmpp) {
ejson::String* tmpp = getString(_name);
if (NULL == tmpp) {
return errorString;
}
return tmpp->Get();
return tmpp->get();
}
etk::UString ejson::Object::GetStringValue(const etk::UString& _name, const etk::UString& _errorValue) const
{
ejson::String* tmpp = GetString(_name);
if (NULL==tmpp) {
etk::UString ejson::Object::getStringValue(const etk::UString& _name, const etk::UString& _errorValue) const {
ejson::String* tmpp = getString(_name);
if (NULL == tmpp) {
return _errorValue;
}
return tmpp->Get();
return tmpp->get();
}
ejson::Boolean* ejson::Object::GetBoolean(const etk::UString& _name) const
{
ejson::Value* tmp = Get(_name);
ejson::Boolean* ejson::Object::getBoolean(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToBoolean();
return tmp->toBoolean();
}
bool ejson::Object::GetBooleanValue(const etk::UString& _name, bool _errorValue) const
{
ejson::Boolean* tmpp = GetBoolean(_name);
if (NULL==tmpp) {
bool ejson::Object::getBooleanValue(const etk::UString& _name, bool _errorValue) const {
ejson::Boolean* tmpp = getBoolean(_name);
if (NULL == tmpp) {
return _errorValue;
}
return tmpp->Get();
return tmpp->get();
}
ejson::Number* ejson::Object::GetNumber(const etk::UString& _name) const
{
ejson::Value* tmp = Get(_name);
ejson::Number* ejson::Object::getNumber(const etk::UString& _name) const {
ejson::Value* tmp = get(_name);
if (NULL == tmp) {
return NULL;
}
return tmp->ToNumber();
return tmp->toNumber();
}
double ejson::Object::GetNumberValue(const etk::UString& _name, double _errorValue) const
{
ejson::Number* tmpp = GetNumber(_name);
if (NULL==tmpp) {
double ejson::Object::getNumberValue(const etk::UString& _name, double _errorValue) const {
ejson::Number* tmpp = getNumber(_name);
if (NULL == tmpp) {
return _errorValue;
}
return tmpp->Get();
return tmpp->get();
}
bool ejson::Object::Add(const etk::UString& _name, ejson::Value* _value)
{
bool ejson::Object::add(const etk::UString& _name, ejson::Value* _value) {
if (NULL == _value) {
return false;
}
if (_name.Size()==0) {
if (_name.size() == 0) {
return false;
}
if (m_value.Exist(_name)) {
if (m_value.exist(_name)) {
ejson::Value* tmp = m_value[_name];
delete(tmp);
m_value[_name] = _value;
return true;
}
m_value.Add(_name, _value);
m_value.add(_name, _value);
return true;
}
bool ejson::Object::AddString(const etk::UString& _name, const etk::UString& _value)
{
return Add(_name, new ejson::String(_value));
bool ejson::Object::addString(const etk::UString& _name, const etk::UString& _value) {
return add(_name, new ejson::String(_value));
}
bool ejson::Object::AddNull(const etk::UString& _name)
{
return Add(_name, new ejson::Null());
bool ejson::Object::addNull(const etk::UString& _name) {
return add(_name, new ejson::Null());
}
bool ejson::Object::AddBoolean(const etk::UString& _name, bool _value)
{
return Add(_name, new ejson::Boolean(_value));
bool ejson::Object::addBoolean(const etk::UString& _name, bool _value) {
return add(_name, new ejson::Boolean(_value));
}
bool ejson::Object::AddNumber(const etk::UString& _name, double _value)
{
return Add(_name, new ejson::Number(_value));
bool ejson::Object::addNumber(const etk::UString& _name, double _value) {
return add(_name, new ejson::Number(_value));
}
bool ejson::Object::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::Object::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::Object* other = _obj->ToObject();
if (NULL==other) {
ejson::Object* other = _obj->toObject();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an object");
return false;
}
// remove destination elements
other->Clear();
other->clear();
// Copy to the destination
other->m_value = m_value;
// remove current:
m_value.Clear();
m_value.clear();
return true;
}
// TODO : Manage error ...
ejson::Value* ejson::Object::Duplicate(void) const
{
ejson::Value* ejson::Object::duplicate(void) const {
ejson::Object* output = new ejson::Object();
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}
for (esize_t iii=0; iii<m_value.Size(); ++iii) {
ejson::Value* val = m_value.GetValue(iii);
etk::UString key = m_value.GetKey(iii);
for (esize_t iii=0; iii<m_value.size(); ++iii) {
ejson::Value* val = m_value.getValue(iii);
etk::UString key = m_value.getKey(iii);
if (NULL == val) {
continue;
}
output->Add(key, val->Duplicate());
output->add(key, val->duplicate());
}
return output;
}

View File

@ -32,124 +32,124 @@ namespace ejson
etk::Hash<ejson::Value*> m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
public:
/**
* @brief Check if an element exist.
* @brief check if an element exist.
* @param[in] _name name of the object.
* @return The existance of the element.
*/
bool Exist(const etk::UString& _name) const;
bool exist(const etk::UString& _name) const;
/**
* @brief Get the sub element with his name (no cast check)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub element with his name (Casted as Object if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub element with his name (Casted as Array if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub element with his name (Casted as Null if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub element with his name (Casted as String if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub string value of the requested element
* @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 etk::UString& getStringValue(const etk::UString& _name) const;
/**
* @brief Get the sub string value of the requested element (with error return value)
* @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;
etk::UString getStringValue(const etk::UString& _name, const etk::UString& _errorValue) const;
/**
* @brief Get the sub element with his name (Casted as Boolean if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub boolean value of the requested element.
* @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 etk::UString& _name, bool _errorValue=false) const;
/**
* @brief Get the sub element with his name (Casted as Number if it is possible)
* @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 etk::UString& _name) const;
/**
* @brief Get the sub Number value of the requested element.
* @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 etk::UString& _name, double _errorValue=false) const;
public:
/**
* @brief Add an element in the Object
* @brief add an element in the Object
* @param[in] _name name of the object
* @param[in] _value Element to add
* @return false if an error occured
*/
bool Add(const etk::UString& _name, ejson::Value* _value);
bool add(const etk::UString& _name, ejson::Value* _value);
/**
* @brief Add a string element in the Object (automatic creation)
* @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 etk::UString& _name, const etk::UString& _value);
/**
* @brief Add a "null" element in the Object (automatic creation)
* @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 etk::UString& _name);
/**
* @brief Add a boolean element in the Object (automatic creation)
* @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 etk::UString& _name, bool _value);
/**
* @brief Add a double element in the Object (automatic creation)
* @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 etk::UString& _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 nodeType_te GetType(void) const { return typeObject; };
virtual ejson::Object* ToObject(void) { return this; };
virtual const ejson::Object* ToObject(void) const{ return this; };
virtual void Clear(void);
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeObject; };
virtual ejson::Object* toObject(void) { return this; };
virtual const ejson::Object* toObject(void) const{ return this; };
virtual void clear(void);
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -18,13 +18,12 @@
bool ejson::String::IParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc)
{
bool ejson::String::iParse(const etk::UString& _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]);
for (int32_t iii=_pos+1; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
ejson::filePos tmpPos;
// TODO : manage \x
@ -35,14 +34,13 @@ bool ejson::String::IParse(const etk::UString& _data, int32_t& _pos, ejson::file
return true;
}
}
_pos=_data.Size();
_pos=_data.size();
EJSON_CREATE_ERROR(_doc, _data, _pos, _filePos, "get end of string whithout fincding end of quote");
return false;
}
bool ejson::String::IGenerate(etk::UString& _data, int32_t _indent) const
{
bool ejson::String::iGenerate(etk::UString& _data, int32_t _indent) const {
_data += "\"";;
_data += m_value;
_data += "\"";;
@ -50,14 +48,13 @@ bool ejson::String::IGenerate(etk::UString& _data, int32_t _indent) const
}
bool ejson::String::TransfertIn(ejson::Value* _obj)
{
if (NULL==_obj) {
bool ejson::String::transfertIn(ejson::Value* _obj) {
if (NULL == _obj) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
ejson::String* other = _obj->ToString();
if (NULL==other) {
ejson::String* other = _obj->toString();
if (NULL == other) {
JSON_ERROR("Request transfer on an element that is not an String");
return false;
}
@ -66,10 +63,9 @@ bool ejson::String::TransfertIn(ejson::Value* _obj)
return true;
}
ejson::Value* ejson::String::Duplicate(void) const
{
ejson::Value* ejson::String::duplicate(void) const {
ejson::String* output = new ejson::String(m_value);
if (NULL==output) {
if (NULL == output) {
JSON_ERROR("Allocation error ...");
return NULL;
}

View File

@ -31,23 +31,23 @@ namespace ejson
etk::UString 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.
* @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 etk::UString& _value) { m_value = _value; };
/**
* @brief Get the current element Value.
* @brief get the current element Value.
* @return the reference of the string value.
*/
const etk::UString& Get(void) const { return m_value; };
const etk::UString& 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 nodeType_te GetType(void) const { return typeString; };
virtual ejson::String* ToString(void) { return this; };
virtual const ejson::String* ToString(void) const{ return this; };
virtual bool TransfertIn(ejson::Value* _obj);
virtual ejson::Value* Duplicate(void) const;
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 nodeType_te getType(void) const { return typeString; };
virtual ejson::String* toString(void) { return this; };
virtual const ejson::String* toString(void) const{ return this; };
virtual bool transfertIn(ejson::Value* _obj);
virtual ejson::Value* duplicate(void) const;
};
};

View File

@ -14,47 +14,42 @@
#define __class__ "Value"
ejson::Value::~Value(void)
{
Clear();
ejson::Value::~Value(void) {
clear();
}
etk::CCout& ejson::operator <<(etk::CCout& _os, const ejson::filePos& _obj)
{
etk::CCout& ejson::operator <<(etk::CCout& _os, const ejson::filePos& _obj) {
_os << "(l=";
_os << _obj.GetLine();
_os << _obj.getLine();
_os << ",c=";
_os << _obj.GetCol();
_os << _obj.getCol();
_os << ")";
return _os;
}
void ejson::Value::AddIndent(etk::UString& _data, int32_t _indent) const
{
void ejson::Value::addIndent(etk::UString& _data, int32_t _indent) const {
for (int32_t iii=0; iii<_indent; iii++) {
_data+="\t";
}
}
void ejson::Value::DrawElementParsed(const etk::UniChar& _val, const ejson::filePos& _filePos) const
{
if (_val=='\n') {
JSON_DEBUG(_filePos << " Parse '\\n'");
} else if (_val=='\t') {
JSON_DEBUG(_filePos << " Parse '\\t'");
void ejson::Value::drawElementParsed(const etk::UniChar& _val, const ejson::filePos& _filePos) const {
if (_val == '\n') {
JSON_DEBUG(_filePos << " parse '\\n'");
} else if (_val == '\t') {
JSON_DEBUG(_filePos << " parse '\\t'");
} else {
JSON_DEBUG(_filePos << " Parse '" << _val << "'");
JSON_DEBUG(_filePos << " parse '" << _val << "'");
}
}
int32_t ejson::Value::CountWhiteChar(const etk::UString& _data, int32_t _pos, ejson::filePos& _filePos) const
{
_filePos.Clear();
int32_t ejson::Value::countWhiteChar(const etk::UString& _data, int32_t _pos, ejson::filePos& _filePos) const {
_filePos.clear();
int32_t white=0;
for (int32_t iii=_pos; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
if(true == _data[iii].IsWhiteChar()) {
for (int32_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
if(true == _data[iii].isWhiteChar()) {
white++;
} else {
break;
@ -65,8 +60,7 @@ int32_t ejson::Value::CountWhiteChar(const etk::UString& _data, int32_t _pos, ej
}
bool ejson::Value::CheckString(const etk::UniChar& _val) const
{
bool ejson::Value::checkString(const etk::UniChar& _val) const {
if( _val == '!'
|| _val == '"'
|| _val == '#'
@ -105,12 +99,11 @@ bool ejson::Value::CheckString(const etk::UniChar& _val) const
return true;
}
bool ejson::Value::CheckNumber(const etk::UniChar& _val) const
{
if( _val=='-'
|| _val=='+'
|| _val=='e'
|| _val=='.'
bool ejson::Value::checkNumber(const etk::UniChar& _val) const {
if( _val == '-'
|| _val == '+'
|| _val == 'e'
|| _val == '.'
|| ( _val>='0'
&& _val<='9' ) ) {
return true;

View File

@ -57,9 +57,8 @@ namespace ejson
~filePos(void) { };
filePos& operator ++(void) { m_col++; return *this; };
filePos& operator --(void) { m_col--; if(m_col<0) { m_col=0;} return *this; };
const filePos& operator +=(const filePos& _obj)
{
if (_obj.m_line==0) {
const filePos& operator +=(const filePos& _obj) {
if (_obj.m_line == 0) {
m_col += _obj.m_col;
} else {
m_col = _obj.m_col;
@ -67,39 +66,34 @@ namespace ejson
}
return *this;
};
const filePos& operator +=(int32_t _col)
{
const filePos& operator +=(int32_t _col) {
m_col += _col;
return *this;
};
const filePos& operator= (const filePos& _obj )
{
const filePos& operator= (const filePos& _obj ) {
m_col = _obj.m_col;
m_line = _obj.m_line;
return *this;
}
void NewLine(void) { m_col=0; m_line++; };
bool Check(const etk::UniChar& _val)
{
void newLine(void) { m_col=0; m_line++; };
bool check(const etk::UniChar& _val) {
m_col++;
if (_val=='\n') {
NewLine();
if (_val == '\n') {
newLine();
return true;
}
return false;
}
void Set(int32_t _line, int32_t _col)
{
void set(int32_t _line, int32_t _col) {
m_col = _col;
m_line = _line;
}
void Clear(void)
{
void clear(void) {
m_col = 0;
m_line = 0;
}
int32_t GetCol(void) const { return m_col; };
int32_t GetLine(void) const { return m_line; };
int32_t getCol(void) const { return m_col; };
int32_t getLine(void) const { return m_line; };
};
etk::CCout& operator <<(etk::CCout& _os, const filePos& _obj);
@ -116,50 +110,50 @@ namespace ejson
virtual ~Value(void);
public:
/**
* @brief Parse the Current node [pure VIRUAL]
* @brief parse the Current node [pure VIRUAL]
* @param[in] _data data string to parse.
* @param[in,out] _pos position in the string to start parse, return the position end of parsing.
* @param[in] _caseSensitive Request a parsion of element that is not case sensitive (all element is in low case)
* @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 etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) = 0;
/**
* @brief Generate a string with the tree of the xml
* @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(etk::UString& _data, int32_t _indent) const = 0;
public:
/**
* @brief Get the node type.
* @brief get the node type.
* @return the type of the Node.
*/
virtual nodeType_te GetType(void) const { return typeValue; };
virtual nodeType_te getType(void) const { return typeValue; };
protected:
/**
* @brief Add indentation of the string input.
* @brief add indentation of the string input.
* @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(etk::UString& _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::UniChar& _val, const ejson::filePos& _filePos) const;
void drawElementParsed(const etk::UniChar& _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::UniChar& _val) const;
bool checkString(const etk::UniChar& _val) const;
/**
* @brief check if an number -+.0123456789e).
* @param[in] _val Value to check the conformity.
*/
bool CheckNumber(const etk::UniChar& _val) const;
bool checkNumber(const etk::UniChar& _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.
@ -167,109 +161,109 @@ 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 etk::UString& _data, int32_t _pos, ejson::filePos& _filePos) const;
public:
/**
* @brief Cast the element in a Value if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Value* ToValue(void) { return this; };
virtual const ejson::Value* ToValue(void) const { return this; };
virtual ejson::Value* toValue(void) { return this; };
virtual const ejson::Value* toValue(void) const { return this; };
/**
* @brief Cast the element in a Document if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Document* ToDocument(void) { return NULL; };
virtual const ejson::Document* ToDocument(void) const { return NULL; };
virtual ejson::Document* toDocument(void) { return NULL; };
virtual const ejson::Document* toDocument(void) const { return NULL; };
/**
* @brief Cast the element in a Array if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Array* ToArray(void) { return NULL; };
virtual const ejson::Array* ToArray(void) const{ return NULL; };
virtual ejson::Array* toArray(void) { return NULL; };
virtual const ejson::Array* toArray(void) const{ return NULL; };
/**
* @brief Cast the element in a Object if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Object* ToObject(void) { return NULL; };
virtual const ejson::Object* ToObject(void) const{ return NULL; };
virtual ejson::Object* toObject(void) { return NULL; };
virtual const ejson::Object* toObject(void) const{ return NULL; };
/**
* @brief Cast the element in a String if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::String* ToString(void) { return NULL; };
virtual const ejson::String* ToString(void) const{ return NULL; };
virtual ejson::String* toString(void) { return NULL; };
virtual const ejson::String* toString(void) const{ return NULL; };
/**
* @brief Cast the element in a Number if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Number* ToNumber(void) { return NULL; };
virtual const ejson::Number* ToNumber(void) const{ return NULL; };
virtual ejson::Number* toNumber(void) { return NULL; };
virtual const ejson::Number* toNumber(void) const{ return NULL; };
/**
* @brief Cast the element in a Boolean if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Boolean* ToBoolean(void) { return NULL; };
virtual const ejson::Boolean* ToBoolean(void) const{ return NULL; };
virtual ejson::Boolean* toBoolean(void) { return NULL; };
virtual const ejson::Boolean* toBoolean(void) const{ return NULL; };
/**
* @brief Cast the element in a Null if it is possible.
* @return pointer on the class or NULL.
*/
virtual ejson::Null* ToNull(void) { return NULL; };
virtual const ejson::Null* ToNull(void) const{ return NULL; };
virtual ejson::Null* toNull(void) { return NULL; };
virtual const ejson::Null* toNull(void) const{ return NULL; };
/**
* @brief Check if the node is a ejson::Document
* @brief check if the node is a ejson::Document
* @return true if the node is a ejson::Document
*/
bool IsDocument(void) const { return GetType()==ejson::typeDocument; };
bool isDocument(void) const { return getType() == ejson::typeDocument; };
/**
* @brief Check if the node is a ejson::Array
* @brief check if the node is a ejson::Array
* @return true if the node is a ejson::Array
*/
bool IsArray(void) const { return GetType()==ejson::typeArray; };
bool isArray(void) const { return getType() == ejson::typeArray; };
/**
* @brief Check if the node is a ejson::Object
* @brief check if the node is a ejson::Object
* @return true if the node is a ejson::Object
*/
bool IsObject(void) const { return GetType()==ejson::typeObject; };
bool isObject(void) const { return getType() == ejson::typeObject; };
/**
* @brief Check if the node is a ejson::String
* @brief check if the node is a ejson::String
* @return true if the node is a ejson::String
*/
bool IsString(void) const { return GetType()==ejson::typeString; };
bool isString(void) const { return getType() == ejson::typeString; };
/**
* @brief Check if the node is a ejson::Number
* @brief check if the node is a ejson::Number
* @return true if the node is a ejson::Number
*/
bool IsNumber(void) const { return GetType()==ejson::typeNumber; };
bool isNumber(void) const { return getType() == ejson::typeNumber; };
/**
* @brief Check if the node is a ejson::Boolean
* @brief check if the node is a ejson::Boolean
* @return true if the node is a ejson::Boolean
*/
bool IsBoolean(void) const { return GetType()==ejson::typeBoolean; };
bool isBoolean(void) const { return getType() == ejson::typeBoolean; };
/**
* @brief Check if the node is a ejson::Null
* @brief check if the node is a ejson::Null
* @return true if the node is a ejson::Null
*/
bool IsNull(void) const { return GetType()==ejson::typeNull; };
bool isNull(void) const { return getType() == ejson::typeNull; };
/**
* @brief Clear the Node
* @brief clear the Node
*/
virtual void Clear(void) {};
virtual void clear(void) {};
/**
* @brief Tranfert all element in the element set in parameter
* @param[in,out] _obj move all parameter in the selected element
* @return true if transfer is done corectly
* @note all element is remove from the curent element.
*/
virtual bool TransfertIn(ejson::Value* _obj) { return false; };
virtual bool transfertIn(ejson::Value* _obj) { return false; };
/**
* @brief Copy the curent node and all the child in the curent one.
* @return NULL in an error occured, the pointer on the element otherwise
*/
virtual ejson::Value* Duplicate(void) const { return NULL; };
virtual ejson::Value* duplicate(void) const { return NULL; };
};
};

View File

@ -21,57 +21,51 @@
#define __class__ "Document"
ejson::Document::Document(void) :
m_writeErrorWhenDetexted(true),
m_comment(""),
m_Line(""),
m_filePos(0,0)
{
m_writeErrorWhenDetexted(true),
m_comment(""),
m_Line(""),
m_filePos(0,0) {
}
ejson::Document::~Document(void)
{
ejson::Document::~Document(void) {
}
bool ejson::Document::IGenerate(etk::UString& _data, int32_t _indent) const
{
ejson::Object::IGenerate(_data, _indent+1);
bool ejson::Document::iGenerate(etk::UString& _data, int32_t _indent) const {
ejson::Object::iGenerate(_data, _indent+1);
_data += "\n";
return true;
}
bool ejson::Document::Parse(const etk::UString& _data)
{
JSON_VERBOSE("Start parsing document (type: string) size=" << _data.Size());
Clear();
bool ejson::Document::parse(const etk::UString& _data) {
JSON_VERBOSE("Start parsing document (type: string) size=" << _data.size());
clear();
ejson::filePos filePos(1,0);
int32_t parsePos = 0;
return IParse(_data, parsePos, filePos, *this);
return iParse(_data, parsePos, filePos, *this);
}
bool ejson::Document::Generate(etk::UString& _data)
{
bool ejson::Document::generate(etk::UString& _data) {
_data = "";
return IGenerate(_data,0);
return iGenerate(_data,0);
}
bool ejson::Document::Load(const etk::UString& _file)
{
bool ejson::Document::load(const etk::UString& _file) {
// Start loading the XML :
JSON_VERBOSE("open file (xml) \"" << _file << "\"");
Clear();
clear();
etk::FSNode tmpFile(_file);
if (false == tmpFile.Exist()) {
if (false == tmpFile.exist()) {
JSON_ERROR("File Does not exist : " << _file);
return false;
}
int64_t fileSize = tmpFile.FileSize();
if (0==fileSize) {
int64_t fileSize = tmpFile.fileSize();
if (0 == fileSize) {
JSON_ERROR("This file is empty : " << _file);
return false;
}
if (false == tmpFile.FileOpenRead()) {
if (false == tmpFile.fileOpenRead()) {
JSON_ERROR("Can not open (r) the file : " << _file);
return false;
}
@ -84,54 +78,51 @@ bool ejson::Document::Load(const etk::UString& _file)
// TODO : change this ... get the charset from the Declaration element ...
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
tmpFile.FileRead(fileBuffer, 1, fileSize);
tmpFile.fileRead(fileBuffer, 1, fileSize);
// close the file:
tmpFile.FileClose();
tmpFile.fileClose();
// convert in UTF8 :
etk::UString tmpDataUnicode(fileBuffer, unicode::EDN_CHARSET_UTF8);
// remove temporary buffer:
delete(fileBuffer);
// parse the data :
bool ret = Parse(tmpDataUnicode);
bool ret = parse(tmpDataUnicode);
//Display();
return ret;
}
bool ejson::Document::Store(const etk::UString& _file)
{
bool ejson::Document::store(const etk::UString& _file) {
etk::UString createData;
if (false == Generate(createData)) {
if (false == generate(createData)) {
JSON_ERROR("Error while creating the XML : " << _file);
return false;
}
etk::FSNode tmpFile(_file);
if (false == tmpFile.FileOpenWrite()) {
if (false == tmpFile.fileOpenWrite()) {
JSON_ERROR("Can not open (w) the file : " << _file);
return false;
}
etk::Char endTable = createData.c_str();
if (tmpFile.FileWrite(endTable, sizeof(char), endTable.Size()) != endTable.Size()) {
if (tmpFile.fileWrite(endTable, sizeof(char), endTable.size()) != endTable.size()) {
JSON_ERROR("Error while writing output XML file : " << _file);
tmpFile.FileClose();
tmpFile.fileClose();
return false;
}
tmpFile.FileClose();
tmpFile.fileClose();
return true;
}
void ejson::Document::Display(void)
{
void ejson::Document::display(void) {
etk::UString tmpp;
IGenerate(tmpp, 0);
iGenerate(tmpp, 0);
JSON_INFO("Generated JSON : \n" << tmpp);
}
static etk::UString CreatePosPointer(const etk::UString& _line, int32_t _pos)
{
static etk::UString createPosPointer(const etk::UString& _line, int32_t _pos) {
etk::UString out;
int32_t iii;
for (iii=0; iii<_pos && iii<_line.Size(); iii++) {
for (iii=0; iii<_pos && iii<_line.size(); iii++) {
if (_line[iii] == '\t') {
out += "\t";
} else {
@ -145,60 +136,57 @@ static etk::UString CreatePosPointer(const etk::UString& _line, int32_t _pos)
return out;
}
void ejson::Document::DisplayError(void)
{
if (m_comment.Size()==0) {
void ejson::Document::displayError(void) {
if (m_comment.size() == 0) {
JSON_ERROR("No error detected ???");
return;
}
JSON_ERROR(m_filePos << " " << m_comment << "\n"
<< m_Line << "\n"
<< CreatePosPointer(m_Line, m_filePos.GetCol()) );
<< createPosPointer(m_Line, m_filePos.getCol()) );
#ifdef ENABLE_CRITICAL_WHEN_ERROR
JSON_CRITICAL("detect error");
#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 etk::UString& _data, int32_t _pos, const ejson::filePos& _filePos, const etk::UString& _comment) {
m_comment = _comment;
m_Line = _data.ExtractLine(_pos);
m_Line = _data.extractLine(_pos);
m_filePos = _filePos;
if (true==m_writeErrorWhenDetexted) {
DisplayError();
if (true == m_writeErrorWhenDetexted) {
displayError();
}
}
bool ejson::Document::IParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc)
{
bool ejson::Document::iParse(const etk::UString& _data, int32_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
JSON_PARSE_ELEMENT("start parse : 'Document' ");
bool haveMainNode=false;
bool nodeParsed=false;
for (int32_t iii=_pos; iii<_data.Size(); iii++) {
_filePos.Check(_data[iii]);
for (int32_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
DrawElementParsed(_data[iii], _filePos);
drawElementParsed(_data[iii], _filePos);
#endif
ejson::filePos tmpPos;
if( _data[iii]==' '
|| _data[iii]=='\t'
|| _data[iii]=='\n'
|| _data[iii]=='\r') {
// white space ==> nothing to do ...
} else if (_data[iii]=='{') {
if (nodeParsed==true) {
if( _data[iii] == ' '
|| _data[iii] == '\t'
|| _data[iii] == '\n'
|| _data[iii] == '\r') {
// white space == > nothing to do ...
} else if (_data[iii] == '{') {
if (nodeParsed == true) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "element already parsed");
_pos=iii;
}
// find a main object:
// ==> generic sub parsing
// == > generic sub parsing
iii++;
haveMainNode=true;
nodeParsed=true;
ejson::Object::IParse(_data, iii, _filePos, _doc);
} else if(_data[iii]=='}') {
_pos=iii; // ==> return the end element type ==> usefull to check end and check if adding element is needed
if (haveMainNode==true) {
ejson::Object::iParse(_data, iii, _filePos, _doc);
} else if(_data[iii] == '}') {
_pos=iii; // == > return the end element type ==> usefull to check end and check if adding element is needed
if (haveMainNode == true) {
// find end of value:
return true;
} else {
@ -206,14 +194,14 @@ bool ejson::Document::IParse(const etk::UString& _data, int32_t& _pos, ejson::fi
return false;
}
} else {
if (nodeParsed==true) {
if (nodeParsed == true) {
_pos=iii;
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "element already parsed");
return false;
}
nodeParsed=true;
// this might not have the '{' start element !!!
if (false==ejson::Object::IParse(_data, iii, _filePos, _doc)) {
if (false == ejson::Object::iParse(_data, iii, _filePos, _doc)) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Object sub parsing in error");
_pos = iii;
return false;

View File

@ -32,61 +32,61 @@ namespace ejson
virtual ~Document(void);
public:
/**
* @brief Parse a string that contain an XML
* @brief parse a string that contain an XML
* @param[in] _data Data to parse
* @return false : An error occured
* @return true : Parsing is OK
*/
bool Parse(const etk::UString& _data);
bool parse(const etk::UString& _data);
/**
* @brief Generate a string that contain the created XML
* @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(etk::UString& _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 etk::UString& _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 etk::UString& _file);
/**
* @brief Display the Document on console
*/
void Display(void);
void display(void);
private:
bool m_writeErrorWhenDetexted;
etk::UString m_comment;
etk::UString m_Line;
ejson::filePos m_filePos;
public:
void DisplayErrorWhenDetected(void) { m_writeErrorWhenDetexted=true; };
void NotDisplayErrorWhenDetected(void) { m_writeErrorWhenDetexted=false; };
void displayErrorWhenDetected(void) { m_writeErrorWhenDetexted=true; };
void notDisplayErrorWhenDetected(void) { m_writeErrorWhenDetexted=false; };
void CreateError(const etk::UString& _data, int32_t _pos, const ejson::filePos& _filePos, const etk::UString& _comment);
void DisplayError(void);
void createError(const etk::UString& _data, int32_t _pos, const ejson::filePos& _filePos, const etk::UString& _comment);
void displayError(void);
public: // herited function:
virtual nodeType_te 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 ejson::Document* ToDocument(void) { return this; };
virtual const ejson::Document* ToDocument(void) const { return this; };
virtual nodeType_te 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 ejson::Document* toDocument(void) { return this; };
virtual const ejson::Document* toDocument(void) const { return this; };
};
};
#define EJSON_CREATE_ERROR(doc,data,pos,filePos,comment) \
do { \
JSON_ERROR(comment); \
(doc).CreateError((data),(pos),(filePos),(comment)); \
(doc).createError((data),(pos),(filePos),(comment)); \
} while (0)
//__LINE__, __class__, __func__

View File

@ -15,15 +15,13 @@
#undef __class__
#define __class__ "ejson::test"
class testCheck
{
class testCheck {
public:
etk::UString m_ref;
etk::UString 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 etk::UString& _ref, int32_t _pos, const etk::UString& _input) {
m_ref = _ref;
m_input = _input;
m_errorPos = _pos;
@ -32,137 +30,136 @@ class testCheck
etk::Vector<testCheck> l_list;
void Init(void)
{
void Init(void) {
etk::UString reference;
etk::UString input;
testCheck check;
// ======================================================
check.Set("test ejson::Doc", -2, "");
l_list.PushBack(check);
// ======================================================
// == ====================================================
check.set("test ejson::Doc", -2, "");
l_list.pushBack(check);
// == ====================================================
reference = "{\n}\n";
check.Set(reference,
check.set(reference,
-1,
"{}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{ \t\r }\n");
l_list.PushBack(check);
// ======================================================
check.Set("test ejson::null", -2, "");
l_list.PushBack(check);
l_list.pushBack(check);
// == ====================================================
check.set("test ejson::null", -2, "");
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n\t\"tmpElement\": null\n}\n";
check.Set(reference,
check.set(reference,
-1,
"{ tmpElement:null }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{ \t\ntmpElement:null \t\n }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"tmpElement:null\n");
l_list.PushBack(check);
// ======================================================
check.Set("test ejson::boolean", -2, "");
l_list.PushBack(check);
l_list.pushBack(check);
// == ====================================================
check.set("test ejson::boolean", -2, "");
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n\t\"tmpElement\": true\n}\n";
check.Set(reference,
check.set(reference,
-1,
"{ tmpElement:true }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{ \t\ntmpElement:true \t\n }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"tmpElement:true\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n\t\"tmpElement\": false\n}\n";
check.Set(reference,
check.set(reference,
-1,
"{ tmpElement:false }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{ \t\ntmpElement:false \t\n }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"tmpElement:false\n");
l_list.PushBack(check);
// ======================================================
check.Set("test ejson::number", -2, "");
l_list.PushBack(check);
l_list.pushBack(check);
// == ====================================================
check.set("test ejson::number", -2, "");
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n\t\"tmpElement\": 956256\n}\n";
check.Set(reference,
check.set(reference,
-1,
"{ tmpElement:956256 }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{ \t\ntmpElement:956256 \t\n }\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"tmpElement:956256\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": 956256\n}\n",
check.set("{\n\t\"tmpElement\": 956256\n}\n",
-1,
"{tmpElement:956256}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": -956256\n}\n",
check.set("{\n\t\"tmpElement\": -956256\n}\n",
-1,
"{tmpElement:-956256}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": -956256\n}\n",
check.set("{\n\t\"tmpElement\": -956256\n}\n",
-1,
"{tmpElement:-956256}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": -956.256\n}\n",
check.set("{\n\t\"tmpElement\": -956.256\n}\n",
-1,
"{tmpElement:-956.256}\n");
l_list.PushBack(check);
l_list.pushBack(check);
/*
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": -956956544454621184\n}\n",
check.set("{\n\t\"tmpElement\": -956956544454621184\n}\n",
-1,
"{tmpElement:-956956544454621354.256}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set("{\n\t\"tmpElement\": 0.000002\n}\n",
check.set("{\n\t\"tmpElement\": 0.000002\n}\n",
-1,
"{tmpElement:+.000001565464}\n");
l_list.PushBack(check);
l_list.pushBack(check);
*/
// ======================================================
check.Set("test ejson::all", -2, "");
l_list.PushBack(check);
// ======================================================
// == ====================================================
check.set("test ejson::all", -2, "");
l_list.pushBack(check);
// == ====================================================
reference = "{\n"
" \"menu\": {\n"
" \"id\": \"file\",\n"
@ -172,10 +169,10 @@ void Init(void)
" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n"
" \"menu\": {\n"
@ -191,12 +188,12 @@ void Init(void)
" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"{\n"
" menu: {\n"
@ -224,9 +221,9 @@ void Init(void)
" }\n"
" }\n"
"}\n");
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
check.Set(reference,
check.set(reference,
-1,
"menu: {\n"
" id: \"file\",\n"
@ -252,7 +249,7 @@ void Init(void)
" ]\n"
" }\n"
"}\n");
l_list.PushBack(check);
l_list.pushBack(check);
//////////////////////////////////////////////////////////////////////////
reference = "{\n"
@ -277,10 +274,10 @@ void Init(void)
" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n"
" \"menu\": {\n"
@ -295,10 +292,10 @@ void Init(void)
" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n"
" \"widget\": {\n"
@ -328,10 +325,10 @@ void Init(void)
" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n"
" \"web-app\": {\n"
@ -424,10 +421,10 @@ void Init(void)
" \"taglib\": { \"taglib-uri\": \"cofax.tld\", \"taglib-location\": \"/WEB-INF/tlds/cofax.tld\" }\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
reference = "{\n"
" \"menu\": {\n"
@ -458,23 +455,22 @@ void Init(void)
" ]\n"
" }\n"
"}\n";
check.Set(reference,
check.set(reference,
-1,
reference);
l_list.PushBack(check);
l_list.pushBack(check);
// ------------------------------------------------------
}
int main(int argc, const char *argv[])
{
int main(int argc, const char *argv[]) {
GeneralDebugSetLevel(etk::LOG_LEVEL_VERBOSE);
Init();
int32_t countError = 0;
int32_t countSeparator = 0;
int32_t sectionID = 0;
for (int32_t iii=0 ; iii<l_list.Size() ; iii++) {
for (int32_t iii=0 ; iii<l_list.size() ; iii++) {
int32_t jjj= iii-countSeparator+1;
if (l_list[iii].m_errorPos==-2) {
if (l_list[iii].m_errorPos == -2) {
countSeparator++;
sectionID = 0;
JSON_INFO("-------------------------------------------------------------");
@ -486,8 +482,8 @@ int main(int argc, const char *argv[])
ejson::Document doc;
etk::UString 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) {
if (false == doc.parse(l_list[iii].m_input)) {
if (l_list[iii].m_errorPos == 1) {
JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } Parsing in error (correct result)");
} else {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } Parsing might be OK");
@ -496,30 +492,30 @@ int main(int argc, const char *argv[])
}
continue;
}
if (l_list[iii].m_errorPos==1) {
if (l_list[iii].m_errorPos == 1) {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } Parsing might be in error ...");
JSON_ERROR("parse : \n" << l_list[iii].m_input);
doc.Display();
countError++;
continue;
}
if (false == doc.Generate(out)) {
if (l_list[iii].m_errorPos==2) {
if (false == doc.generate(out)) {
if (l_list[iii].m_errorPos == 2) {
JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } generate in error (correct result)");
} else {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } Generate output might be OK");
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } generate output might be OK");
JSON_ERROR("generate : \n" << out);
countError++;
}
continue;
}
if (l_list[iii].m_errorPos==2) {
if (l_list[iii].m_errorPos == 2) {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } Generating might be in error ...");
countError++;
continue;
}
if (l_list[iii].m_ref != out) {
if (l_list[iii].m_errorPos==3) {
if (l_list[iii].m_errorPos == 3) {
JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } Result in error (normal case)");
} else {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } different output");
@ -527,12 +523,12 @@ int main(int argc, const char *argv[])
etk::Vector<etk::UString> 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) {
if (jjj<tmpref.Size()) {
for (int32_t jjj=0; jjj<tmpout.size() || jjj<tmpref.Size(); ++jjj) {
if (jjj<tmpref.size()) {
JSON_INFO("[" << jjj << "] " << tmpref[jjj] );
}
if (jjj<tmpout.Size()) {
if (jjj>=tmpref.Size() || tmpref[jjj] != tmpout[jjj]) {
if (jjj<tmpout.size()) {
if (jjj>=tmpref.size() || tmpref[jjj] != tmpout[jjj]) {
JSON_ERROR("[" << jjj << "] " << tmpout[jjj] );
}
}
@ -541,18 +537,18 @@ int main(int argc, const char *argv[])
}
continue;
}
if (l_list[iii].m_errorPos==3) {
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');
//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) {
if (jjj<tmpref.Size()) {
for (int32_t jjj=0; jjj<tmpout.size() || jjj<tmpref.Size(); ++jjj) {
if (jjj<tmpref.size()) {
JSON_INFO("[" << jjj << "] " << tmpref[jjj] );
}
if (jjj<tmpout.Size()) {
if (jjj>=tmpref.Size() || tmpref[jjj] != tmpout[jjj]) {
if (jjj<tmpout.size()) {
if (jjj>=tmpref.size() || tmpref[jjj] != tmpout[jjj]) {
JSON_ERROR("[" << jjj << "] " << tmpout[jjj] );
}
}
@ -563,9 +559,9 @@ int main(int argc, const char *argv[])
JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK }");
}
if (countError>0) {
JSON_ERROR("[TEST] produce " << countError << " error on " << l_list.Size()-countSeparator << " test");
JSON_ERROR("[TEST] produce " << countError << " error on " << l_list.size()-countSeparator << " test");
} else {
JSON_INFO("[TEST] produce " << countError << " error on " << l_list.Size()-countSeparator << " test");
JSON_INFO("[TEST] produce " << countError << " error on " << l_list.size()-countSeparator << " test");
}
return 0;
}