[DEV] update to the etk normalisation

This commit is contained in:
Edouard DUPIN 2013-12-28 14:21:48 +01:00
parent bf82bb3bbd
commit 39dfd1793b
10 changed files with 42 additions and 35 deletions

View File

@ -10,14 +10,12 @@
#define __ETK_JSON_ARRAY_H__ #define __ETK_JSON_ARRAY_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>
namespace ejson namespace ejson {
{ class Array : public ejson::Value {
class Array : public ejson::Value
{
public: public:
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure

View File

@ -10,14 +10,12 @@
#define __ETK_JSON_BOOLEAN_H__ #define __ETK_JSON_BOOLEAN_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>
namespace ejson namespace ejson {
{ class Boolean : public ejson::Value {
class Boolean : public ejson::Value
{
public: public:
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure

View File

@ -10,14 +10,12 @@
#define __ETK_JSON_NULL_H__ #define __ETK_JSON_NULL_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>
namespace ejson namespace ejson {
{ class Null : public ejson::Value {
class Null : public ejson::Value
{
public: public:
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure

View File

@ -10,14 +10,12 @@
#define __ETK_JSON_NUMBER_H__ #define __ETK_JSON_NUMBER_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>
namespace ejson namespace ejson {
{ class Number : public ejson::Value {
class Number : public ejson::Value
{
public: public:
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure

View File

@ -10,7 +10,7 @@
#define __ETK_JSON_OBJECT_H__ #define __ETK_JSON_OBJECT_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/Hash.h> #include <etk/Hash.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>

View File

@ -10,14 +10,12 @@
#define __ETK_JSON_STRING_H__ #define __ETK_JSON_STRING_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <ejson/Value.h> #include <ejson/Value.h>
namespace ejson namespace ejson {
{ class String : public ejson::Value {
class String : public ejson::Value
{
public: public:
/** /**
* @brief basic element of a xml structure * @brief basic element of a xml structure

View File

@ -14,6 +14,7 @@
#define __class__ "Value" #define __class__ "Value"
ejson::Value::~Value(void) { ejson::Value::~Value(void) {
clear(); clear();
} }
@ -28,6 +29,17 @@ etk::CCout& ejson::operator <<(etk::CCout& _os, const ejson::filePos& _obj) {
} }
bool ejson::Value::isWhiteChar(char32_t _val) {
if( _val == ' '
|| _val == '\t'
|| _val == '\n'
|| _val == '\r') {
return true;
}
return false;
}
void ejson::Value::addIndent(std::string& _data, size_t _indent) const { void ejson::Value::addIndent(std::string& _data, size_t _indent) const {
for (size_t iii=0; iii<_indent; iii++) { for (size_t iii=0; iii<_indent; iii++) {
_data+="\t"; _data+="\t";
@ -49,7 +61,7 @@ int32_t ejson::Value::countWhiteChar(const std::string& _data, size_t _pos, ejso
size_t white=0; size_t white=0;
for (size_t iii=_pos; iii<_data.size(); iii++) { for (size_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]); _filePos.check(_data[iii]);
if(true == etk::isWhiteChar(_data[iii])) { if(true == isWhiteChar(_data[iii])) {
white++; white++;
} else { } else {
break; break;

View File

@ -10,7 +10,7 @@
#define __ETK_JSON_VALUE_H__ #define __ETK_JSON_VALUE_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
namespace ejson { namespace ejson {
@ -336,6 +336,12 @@ namespace ejson {
virtual ejson::Value* duplicate(void) const { virtual ejson::Value* duplicate(void) const {
return NULL; return NULL;
}; };
protected:
/**
* @brief check if the current element is white or not : '\t' '\n' '\r' ' '
* @return tue if it is white char
*/
static bool isWhiteChar(char32_t _val);
}; };
}; };

View File

@ -10,9 +10,8 @@
#define __ETK_JSON_H__ #define __ETK_JSON_H__
#include <ejson/Value.h> #include <ejson/Value.h>
#include <etk/unicode.h>
#include <vector> #include <vector>
#include <etk/UString.h> #include <etk/types.h>
#include <ejson/String.h> #include <ejson/String.h>
#include <ejson/Array.h> #include <ejson/Array.h>
#include <ejson/Object.h> #include <ejson/Object.h>

View File

@ -7,7 +7,7 @@
*/ */
#include <vector> #include <vector>
#include <etk/UString.h> #include <etk/types.h>
#include <ejson/debug.h> #include <ejson/debug.h>
#include <ejson/ejson.h> #include <ejson/ejson.h>
@ -518,8 +518,8 @@ int main(int argc, const char *argv[]) {
JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } Result in error (normal case)"); JSON_INFO("[TEST] " << sectionID << ":" << jjj << " { OK } Result in error (normal case)");
} else { } else {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } different output"); JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR } different output");
std::vector<std::string> tmpout = string_split(out, '\n'); std::vector<std::string> tmpout = std::split(out, '\n');
std::vector<std::string> tmpref = string_split(l_list[iii].m_ref, '\n'); std::vector<std::string> tmpref = std::split(l_list[iii].m_ref, '\n');
//JSON_ERROR("generate : \n" << out); //JSON_ERROR("generate : \n" << out);
//JSON_ERROR("reference : \n" << l_list[iii].m_ref); //JSON_ERROR("reference : \n" << l_list[iii].m_ref);
for (int32_t jjj=0; jjj<tmpout.size() || jjj<tmpref.size(); ++jjj) { 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) { if (l_list[iii].m_errorPos == 3) {
JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR} checking result might be in error..."); JSON_ERROR("[TEST] " << sectionID << ":" << jjj << " {ERROR} checking result might be in error...");
std::vector<std::string> tmpout = string_split(out, '\n'); std::vector<std::string> tmpout = std::split(out, '\n');
std::vector<std::string> tmpref = string_split(l_list[iii].m_ref, '\n'); std::vector<std::string> tmpref = std::split(l_list[iii].m_ref, '\n');
//JSON_ERROR("generate : \n" << out); //JSON_ERROR("generate : \n" << out);
//JSON_ERROR("reference : \n" << l_list[iii].m_ref); //JSON_ERROR("reference : \n" << l_list[iii].m_ref);
for (int32_t jjj=0; jjj<tmpout.size() || jjj<tmpref.size(); ++jjj) { for (int32_t jjj=0; jjj<tmpout.size() || jjj<tmpref.size(); ++jjj) {