[DEV] integarate std x11

This commit is contained in:
Edouard DUPIN 2013-11-11 20:16:55 +01:00
parent 51606313ab
commit b83c99e371
36 changed files with 1649 additions and 2070 deletions

View File

@ -211,18 +211,18 @@ namespace etk
* @param[in] _nbElement Number of element needed. * @param[in] _nbElement Number of element needed.
* @return The data requested * @return The data requested
*/ */
etk::Vector<int8_t> get(int32_t _pos, int32_t _nbElement) { std::vector<int8_t> get(int32_t _pos, int32_t _nbElement) {
etk::Vector<int8_t> tmpBuffer; std::vector<int8_t> tmpBuffer;
tmpBuffer.clear(); tmpBuffer.clear();
if (_pos < m_gapStart) { if (_pos < m_gapStart) {
if (_pos + _nbElement < m_gapStart) { if (_pos + _nbElement < m_gapStart) {
tmpBuffer.pushBack(&m_data[_pos], _nbElement); tmpBuffer.push_back(&m_data[_pos], _nbElement);
} else { } else {
tmpBuffer.pushBack(&m_data[_pos], m_gapStart - _pos); tmpBuffer.push_back(&m_data[_pos], m_gapStart - _pos);
tmpBuffer.pushBack(&m_data[m_gapEnd], _nbElement - (m_gapStart - _pos) ); tmpBuffer.push_back(&m_data[m_gapEnd], _nbElement - (m_gapStart - _pos) );
} }
} else { } else {
tmpBuffer.pushBack(&m_data[_pos+(m_gapEnd-m_gapStart)], _nbElement); tmpBuffer.push_back(&m_data[_pos+(m_gapEnd-m_gapStart)], _nbElement);
} }
return tmpBuffer; return tmpBuffer;
} }
@ -230,7 +230,7 @@ namespace etk
* @brief Add at the Last position of the Vector * @brief Add at the Last position of the Vector
* @param[in] _item Element to add at the end of vector * @param[in] _item Element to add at the end of vector
*/ */
void pushBack(const int8_t& _item) { void push_back(const int8_t& _item) {
insert(size(), _item); insert(size(), _item);
} }
/** /**
@ -270,7 +270,7 @@ namespace etk
* @param[in] _pos Position where data might be inserted * @param[in] _pos Position where data might be inserted
* @param[in] _items Data that might be inserted. * @param[in] _items Data that might be inserted.
*/ */
void insert(int32_t _pos, etk::Vector<int8_t>& _items) { void insert(int32_t _pos, std::vector<int8_t>& _items) {
insert(_pos, _items.dataPointer(), _items.size()); insert(_pos, _items.dataPointer(), _items.size());
} }
/** /**
@ -323,7 +323,7 @@ namespace etk
* @param[in] _nbRemoveElement number of element to remove. * @param[in] _nbRemoveElement number of element to remove.
* @param[in] _items Data that might be inserted. * @param[in] _items Data that might be inserted.
*/ */
void replace(int32_t _pos, int32_t _nbRemoveElement, etk::Vector<int8_t>& _items) { void replace(int32_t _pos, int32_t _nbRemoveElement, std::vector<int8_t>& _items) {
replace(_pos, _nbRemoveElement, _items.dataPointer(), _items.size()); replace(_pos, _nbRemoveElement, _items.dataPointer(), _items.size());
} }
/** /**

View File

@ -6,45 +6,4 @@
* @license BSD v3 (see license file) * @license BSD v3 (see license file)
*/ */
#include <etk/Char.h>
#include <etk/debug.h>
#include <etk/Stream.h>
etk::Char::Char(void) {
m_data.pushBack('\0');
}
etk::Char::~Char(void)
{
}
etk::Char::operator const char *()
{
return &m_data[0];
};
etk::Char::operator void *()
{
return &m_data[0];
};
void etk::Char::setValue(const etk::Vector<char>& _data)
{
m_data = _data;
// check presence of '\0' (note : start by the end might be faster ...
for (int32_t iii=m_data.size()-1; iii>=0; iii--) {
if (m_data[iii] == '\0') {
return;
}
}
m_data.pushBack('\0');
}
int64_t etk::Char::size(void)
{
return m_data.size()-1;
}

View File

@ -9,24 +9,6 @@
#ifndef __ETK_CHAR_H__ #ifndef __ETK_CHAR_H__
#define __ETK_CHAR_H__ #define __ETK_CHAR_H__
#include <etk/Vector.h>
namespace etk
{
class Char
{
private:
etk::Vector<char> m_data;
public:
Char(void);
~Char(void);
operator const char *();
operator void *();
void setValue(const etk::Vector<char>& _data);
int64_t size(void);
};
};
#endif #endif

View File

@ -10,9 +10,10 @@
#include <etk/tool.h> #include <etk/tool.h>
#include <etk/Color.h> #include <etk/Color.h>
#include <etk/debug.h> #include <etk/debug.h>
#include <string>
#include <sstream>
static bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxLen) static bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxLen) {
{
int32_t iii=0; int32_t iii=0;
while ('\0' != *input1 && '\0' != *input2 && iii < maxLen) { while ('\0' != *input1 && '\0' != *input2 && iii < maxLen) {
char in1 = *input1; char in1 = *input1;
@ -43,110 +44,103 @@ typedef struct {
static esize_t getColorSize(void); static esize_t getColorSize(void);
static const colorList_ts* getColorList(void); static const colorList_ts* getColorList(void);
namespace etk namespace etk {
{ template<> void Color<uint8_t>::set(float _r, float _g, float _b, float _a) {
template<> void Color<uint8_t>::set(float _r, float _g, float _b, float _a)
{
m_r = (uint8_t)(_r*255.0f); m_r = (uint8_t)(_r*255.0f);
m_g = (uint8_t)(_g*255.0f); m_g = (uint8_t)(_g*255.0f);
m_b = (uint8_t)(_b*255.0f); m_b = (uint8_t)(_b*255.0f);
m_a = (uint8_t)(_a*255.0f); m_a = (uint8_t)(_a*255.0f);
} }
template<> void Color<float>::set(float _r, float _g, float _b, float _a) template<> void Color<float>::set(float _r, float _g, float _b, float _a) {
{
m_r = _r; m_r = _r;
m_g = _g; m_g = _g;
m_b = _b; m_b = _b;
m_a = _a; m_a = _a;
} }
template<> void Color<uint8_t>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) template<> void Color<uint8_t>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) {
{
m_r = _r; m_r = _r;
m_g = _g; m_g = _g;
m_b = _b; m_b = _b;
m_a = _a; m_a = _a;
} }
template<> void Color<float>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) template<> void Color<float>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) {
{
m_r = ((float)_r)/255.0f; m_r = ((float)_r)/255.0f;
m_g = ((float)_g)/255.0f; m_g = ((float)_g)/255.0f;
m_b = ((float)_b)/255.0f; m_b = ((float)_b)/255.0f;
m_a = ((float)_a)/255.0f; m_a = ((float)_a)/255.0f;
} }
template<> uint32_t Color<uint8_t>::get(void) const template<> uint32_t Color<uint8_t>::get(void) const {
{
return (((uint32_t)m_r)<<24) return (((uint32_t)m_r)<<24)
+ (((uint32_t)m_g)<<16) + (((uint32_t)m_g)<<16)
+ (((uint32_t)m_b)<<8) + (((uint32_t)m_b)<<8)
+ (uint32_t)m_a; + (uint32_t)m_a;
} }
template<> uint32_t Color<float>::get(void) const template<> uint32_t Color<float>::get(void) const {
{
return Color<uint8_t>(*this).get(); return Color<uint8_t>(*this).get();
} }
template<> Color<uint8_t>::Color(const etk::UString& _input) : template<> Color<uint8_t>::Color(std::u32string _input) :
m_r(255), m_r(255),
m_g(255), m_g(255),
m_b(255), m_b(255),
m_a(255) m_a(255) {
{ if ( _input.size() >=1
etk::Char input = _input.c_str(); && _input[0] == '#') {
const char* inputData = input; // remove '#'
size_t len = strlen(input); _input.erase(0, 1);
if( len >=1 uint32_t val = 0;
&& inputData[0] == '#') { //std::ostringstream oss;
if(len == 4) { //oss << to_u8string(_input);
int32_t red=0, green=0, blue=0; //oss >> std::hex >> val;
if (sscanf(inputData + 1, "%1x%1x%1x", &red, &green, &blue) == 3) { std::string plop = to_u8string(_input);
m_r = (red | red << 4); val = stoul(plop);
m_g = (green | green << 4); if(_input.size() == 3) {
m_b = (blue | blue << 4); m_r = (val & 0x00000F00) >> 8;
m_r = (m_r | m_r << 4);
m_g = (val & 0x000000F0) >> 4;
m_g = (m_g | m_g << 4);
m_b = (val & 0x0000000F) >> 0;
m_b = (m_b | m_b << 4);
} else if (_input.size() == 4) {
m_r = (val & 0x0000F000) >> 12;
m_r = (m_r | m_r << 4);
m_g = (val & 0x00000F00) >> 8;
m_g = (m_g | m_g << 4);
m_b = (val & 0x000000F0) >> 4;
m_b = (m_b | m_b << 4);
m_a = (val & 0x0000000F) >> 0;
m_a = (m_a | m_a << 4);
} else if (_input.size() == 6) {
m_r = (val & 0x00FF0000) >> 16;
m_r = (m_r | m_r << 4);
m_g = (val & 0x0000FF00) >> 8;
m_g = (m_g | m_g << 4);
m_b = (val & 0x000000FF) >> 0;
m_b = (m_b | m_b << 4);
} else if (_input.size() == 8) {
m_r = (val & 0xFF000000) >> 24;
m_r = (m_r | m_r << 4);
m_g = (val & 0x00FF0000) >> 16;
m_g = (m_g | m_g << 4);
m_b = (val & 0x0000FF00) >> 8;
m_b = (m_b | m_b << 4);
m_a = (val & 0x000000FF) >> 0;
m_a = (m_a | m_a << 4);
} else { } else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\""); TK_ERROR(" pb in parsing the color : \"" << _input << "\" ==> unknown methode ...");
} }
} else if (len==5) { } else if( _input.size() >= 4
int32_t red=0, green=0, blue=0, alpha=0; && _input[0] == 'r'
if (sscanf(inputData + 1, "%1x%1x%1x%1x", &red, &green, &blue, &alpha) == 4) { && _input[1] == 'g'
m_r = (red | red << 4); && _input[2] == 'b'
m_g = (green | green << 4); && _input[3] == '(' ) {
m_b = (blue | blue << 4); /*
m_a = (alpha | alpha << 4);
} else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
}
} else if (len == 7) {
int32_t red=0, green=0, blue=0;
if (sscanf(inputData + 1, "%2x%2x%2x", &red, &green, &blue) == 3) {
m_r = red;
m_g = green;
m_b = blue;
} else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
}
} else if (len == 9) {
int32_t red=0, green=0, blue=0, alpha=0;
if (sscanf(inputData + 1, "%2x%2x%2x%2x", &red, &green, &blue, &alpha) == 4) {
m_r = red;
m_g = green;
m_b = blue;
m_a = alpha;
} else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
}
} else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> unknown methode ...");
}
} else if( 4 <= len
&& inputData[0] == 'r'
&& inputData[1] == 'g'
&& inputData[2] == 'b'
&& inputData[3] == '(' ) {
int32_t _red=0, _green=0, _blue=0, _alpha=0; int32_t _red=0, _green=0, _blue=0, _alpha=0;
float fred=0, fgreen=0, fblue=0, falpha=0; float fred=0, fgreen=0, fblue=0, falpha=0;
if (sscanf(inputData + 4, "%u,%u,%u,%u", &_red, &_green, &_blue, &_alpha) == 4) { if (sscanf(inputData + 4, "%u,%u,%u,%u", &_red, &_green, &_blue, &_alpha) == 4) {
@ -177,11 +171,13 @@ namespace etk
} else { } else {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> unknown methode ..."); TK_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> unknown methode ...");
} }
*/
} else { } else {
bool findIt = false; bool findIt = false;
std::string tmputf8string = to_u8string(_input);
// direct named color ... // direct named color ...
for (esize_t iii=0; iii<getColorSize(); iii++) { for (esize_t iii=0; iii<getColorSize(); iii++) {
if (strnCmpNoCase(getColorList()[iii].colorName, inputData, strlen(getColorList()[iii].colorName)) == true) { if (strnCmpNoCase(getColorList()[iii].colorName, tmputf8string.c_str(), strlen(getColorList()[iii].colorName)) == true) {
findIt = true; findIt = true;
*this = getColorList()[iii].color; *this = getColorList()[iii].color;
// stop searching // stop searching
@ -190,13 +186,13 @@ namespace etk
} }
// not find color ... // not find color ...
if (findIt == false) { if (findIt == false) {
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" not find ..."); TK_ERROR(" pb in parsing the color : \"" << _input << "\" not find ...");
} }
} }
TK_VERBOSE("Parse color : \"" << inputData << "\" ==> " << *this); TK_VERBOSE("Parse color : \"" << _input << "\" ==> " << *this);
} }
template<> Color<float>::Color(const etk::UString& _input) template<> Color<float>::Color(std::u32string _input)
{ {
etk::Color<uint8_t> tmpColor(_input); etk::Color<uint8_t> tmpColor(_input);
*this = tmpColor; *this = tmpColor;

View File

@ -34,7 +34,7 @@ namespace etk {
}; };
Color(const etk::Color<float>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); }; Color(const etk::Color<float>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
Color(const etk::Color<uint8_t>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); }; Color(const etk::Color<uint8_t>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
Color(const etk::UString& _input); Color(std::u32string _input);
~Color(void) { }; ~Color(void) { };
Color<MY_TYPE>& operator=(const etk::Color<MY_TYPE>& _input) Color<MY_TYPE>& operator=(const etk::Color<MY_TYPE>& _input)
{ {
@ -73,20 +73,36 @@ namespace etk {
(uint8_t)(etk_avg(0,_b,255)), (uint8_t)(etk_avg(0,_b,255)),
(uint8_t)(etk_avg(0,_a,255)) ); (uint8_t)(etk_avg(0,_a,255)) );
} }
etk::UString getHexString(void) const { std::u32string getHexString(void) const {
return etk::UString(get(), etk::UString::printModeHexadecimal, true); return U"0x" + to_u32string<uint32_t>(get(), std::hex);
}; };
etk::UString getString(void) const { std::u32string getString(void) const {
return etk::UString("#") + etk::UString(get(), etk::UString::printModeHexadecimal); return U"#" + to_u32string<uint32_t>(get(), std::hex);
};
MY_TYPE r(void) const {
return m_r;
};
MY_TYPE g(void) const {
return m_g;
};
MY_TYPE b(void) const {
return m_b;
};
MY_TYPE a(void) const {
return m_a;
};
void setR(MY_TYPE _r) {
m_r=_r;
};
void setG(MY_TYPE _g) {
m_g=_g;
};
void setB(MY_TYPE _b) {
m_b=_b;
};
void setA(MY_TYPE _a) {
m_a=_a;
}; };
MY_TYPE r(void) const { return m_r; };
MY_TYPE g(void) const { return m_g; };
MY_TYPE b(void) const { return m_b; };
MY_TYPE a(void) const { return m_a; };
void setR(MY_TYPE _r) { m_r=_r; };
void setG(MY_TYPE _g) { m_g=_g; };
void setB(MY_TYPE _b) { m_b=_b; };
void setA(MY_TYPE _a) { m_a=_a; };
}; };
etk::CCout& operator <<(etk::CCout &_os, const Color<uint8_t>& _obj); etk::CCout& operator <<(etk::CCout &_os, const Color<uint8_t>& _obj);
etk::CCout& operator <<(etk::CCout &_os, const Color<float>& _obj); etk::CCout& operator <<(etk::CCout &_os, const Color<float>& _obj);

View File

@ -11,7 +11,7 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/Vector.h> #include <vector>
#include <etk/UString.h> #include <etk/UString.h>
#undef __class__ #undef __class__
@ -21,9 +21,9 @@
namespace etk { namespace etk {
template<class MY_TYPE> class HashData { template<class MY_TYPE> class HashData {
public: public:
etk::UString m_key; //!< name of the current hash std::u32string m_key; //!< name of the current hash
MY_TYPE m_value; //!< data of the current Hash MY_TYPE m_value; //!< data of the current Hash
HashData(const etk::UString& _key, const MY_TYPE& _val) : HashData(const std::u32string& _key, const MY_TYPE& _val) :
m_key(_key), m_key(_key),
m_value(_val) { m_value(_val) {
// nothing to do ... // nothing to do ...
@ -32,7 +32,7 @@ namespace etk {
template<class MY_TYPE> class Hash { template<class MY_TYPE> class Hash {
private: private:
etk::Vector<HashData<MY_TYPE>* > m_data; //!< Data of the hash ==> the Hash table is composed of pointer, this permit to have high speed when resize the vestor ... std::vector<HashData<MY_TYPE>* > m_data; //!< Data of the hash ==> the Hash table is composed of pointer, this permit to have high speed when resize the vestor ...
public: public:
Hash(int32_t _count=0) : Hash(int32_t _count=0) :
m_data(_count) { m_data(_count) {
@ -58,7 +58,7 @@ namespace etk {
* @param[in] _key Name of the hash requested * @param[in] _key Name of the hash requested
* @return Id of the element in the table or -1 of it does not existed * @return Id of the element in the table or -1 of it does not existed
*/ */
int64_t getId(const etk::UString& _key) const { int64_t getId(const std::u32string& _key) const {
for (int32_t iii=0; iii<m_data.size(); iii++) { for (int32_t iii=0; iii<m_data.size(); iii++) {
if (m_data[iii] != NULL) { if (m_data[iii] != NULL) {
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" ); //TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
@ -75,7 +75,7 @@ namespace etk {
* @param[in] _key Name of the hash requested * @param[in] _key Name of the hash requested
* @return true if the element exist * @return true if the element exist
*/ */
bool exist(const etk::UString& _name) const { bool exist(const std::u32string& _name) const {
int64_t elementId = getId(_name); int64_t elementId = getId(_name);
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId ); //TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
if (elementId<0) { if (elementId<0) {
@ -90,7 +90,7 @@ namespace etk {
* @param[in] _key Name of the hash requested * @param[in] _key Name of the hash requested
* @return Reference on the Element * @return Reference on the Element
*/ */
MY_TYPE& get(const etk::UString& _key) const { MY_TYPE& get(const std::u32string& _key) const {
static MY_TYPE g_error; static MY_TYPE g_error;
int64_t elementId = getId(_key); int64_t elementId = getId(_key);
if (elementId<0) { if (elementId<0) {
@ -104,14 +104,14 @@ namespace etk {
* @param[in] _key Name of the hash requested * @param[in] _key Name of the hash requested
* @return An reference on the copy of selected element * @return An reference on the copy of selected element
*/ */
MY_TYPE& operator[] (const etk::UString& _key) { MY_TYPE& operator[] (const std::u32string& _key) {
return get(_key); return get(_key);
} }
const MY_TYPE& operator[] (const etk::UString& _key) const { const MY_TYPE& operator[] (const std::u32string& _key) const {
return get(_key); return get(_key);
} }
void add(const etk::UString& _key, const MY_TYPE& _value) { void add(const std::u32string& _key, const MY_TYPE& _value) {
int64_t elementId = getId(_key); int64_t elementId = getId(_key);
if (elementId <0) { if (elementId <0) {
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value); HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
@ -119,15 +119,15 @@ namespace etk {
TK_ERROR("allocation error in Hash table : '" << _key << "'"); TK_ERROR("allocation error in Hash table : '" << _key << "'");
return; return;
} }
m_data.pushBack(tmp); m_data.push_back(tmp);
return; return;
} }
m_data[elementId]->m_value = _value; m_data[elementId]->m_value = _value;
} }
void set(const etk::UString& _key, const MY_TYPE& _value) { void set(const std::u32string& _key, const MY_TYPE& _value) {
add(_key, _value); add(_key, _value);
} }
void remove(const etk::UString& _key) { void remove(const std::u32string& _key) {
int64_t elementId = getId(_key); int64_t elementId = getId(_key);
if (elementId <0) { if (elementId <0) {
//nothing to do ==> not existed //nothing to do ==> not existed
@ -150,7 +150,7 @@ namespace etk {
const MY_TYPE& operator[] (esize_t _pos) const { const MY_TYPE& operator[] (esize_t _pos) const {
return getValue(_pos); return getValue(_pos);
} }
const etk::UString& getKey(esize_t _pos) const { const std::u32string& getKey(esize_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode // NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
if(_pos>m_data.size()){ if(_pos>m_data.size()){

View File

@ -11,7 +11,7 @@
#include <etk/os/Mutex.h> #include <etk/os/Mutex.h>
#include <etk/os/Semaphore.h> #include <etk/os/Semaphore.h>
#include <etk/Vector.h> #include <vector>
namespace etk namespace etk
{ {
@ -20,7 +20,7 @@ namespace etk
private : private :
etk::Mutex m_mutex; etk::Mutex m_mutex;
etk::Semaphore m_semaphore; etk::Semaphore m_semaphore;
etk::Vector<MY_TYPE> m_data; std::vector<MY_TYPE> m_data;
public : public :
MessageFifo(void) MessageFifo(void)
{ {
@ -85,7 +85,7 @@ namespace etk
void post(MY_TYPE &_data) void post(MY_TYPE &_data)
{ {
m_mutex.lock(); m_mutex.lock();
m_data.pushBack(_data); m_data.push_back(_data);
m_semaphore.post(); m_semaphore.post();
m_mutex.unLock(); m_mutex.unLock();
}; };

View File

@ -21,7 +21,7 @@ etk::BaseNoise::BaseNoise(ivec2 _size, float _min, float _max) :
m_data(_size.x()*_size.y()), m_data(_size.x()*_size.y()),
m_size(_size) m_size(_size)
{ {
m_data.reSize(_size.x()*_size.y(), 0); m_data.resize(_size.x()*_size.y(), 0);
for(int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) { for(int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
m_data[iii] = etk::tool::frand(_min, _max); m_data[iii] = etk::tool::frand(_min, _max);
@ -98,7 +98,7 @@ etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
m_size(_size), m_size(_size),
m_type(_type) m_type(_type)
{ {
m_data.reSize(_size.x()*_size.y(), 0); m_data.resize(_size.x()*_size.y(), 0);
switch(m_type) { switch(m_type) {
default: default:
case etk::Noise::NOISE_BASE: case etk::Noise::NOISE_BASE:

View File

@ -17,7 +17,7 @@ namespace etk {
class BaseNoise class BaseNoise
{ {
private: private:
etk::Vector<float> m_data; std::vector<float> m_data;
ivec2 m_size; ivec2 m_size;
public: public:
BaseNoise(ivec2 _size, float _min, float _max); BaseNoise(ivec2 _size, float _min, float _max);
@ -37,7 +37,7 @@ namespace etk {
NOISE_WOOD NOISE_WOOD
}; };
private: private:
etk::Vector<float> m_data; std::vector<float> m_data;
ivec2 m_size; ivec2 m_size;
enum noise m_type; enum noise m_type;
float smoothNoise(float _x, float _y, const etk::BaseNoise& _noise); float smoothNoise(float _x, float _y, const etk::BaseNoise& _noise);

View File

@ -64,11 +64,10 @@ const etk::convertionTable_ts etk::constConvertionTable[] = {
}; };
const esize_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ; const esize_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ;
void etk::displayElem(const etk::Vector<etk::UChar>& _data, esize_t _start, esize_t _stop) void etk::displayElem(const std::vector<char32_t>& _data, esize_t _start, esize_t _stop) {
{
etk::cout<< ETK_BASH_COLOR_NORMAL; etk::cout<< ETK_BASH_COLOR_NORMAL;
for (esize_t iii=_start; iii<_data.size() && iii<_stop ; iii++) { for (esize_t iii=_start; iii<_data.size() && iii<_stop ; iii++) {
switch(_data[iii].get()) switch(_data[iii])
{ {
case REGEXP_OPCODE_PTHESE_IN: etk::cout<<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break; case REGEXP_OPCODE_PTHESE_IN: etk::cout<<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_PTHESE_OUT: etk::cout<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break; case REGEXP_OPCODE_PTHESE_OUT: etk::cout<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break;
@ -99,8 +98,8 @@ void etk::displayElem(const etk::Vector<etk::UChar>& _data, esize_t _start, esiz
} }
} }
} }
char * etk::levelSpace(uint32_t _level)
{ char * etk::levelSpace(uint32_t _level) {
switch(_level) switch(_level)
{ {
case 0: return (char*)""; case 0: return (char*)"";
@ -125,8 +124,7 @@ char * etk::levelSpace(uint32_t _level)
} }
esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UChar>& _data, esize_t _startPos) esize_t etk::getLenOfPTheseElem(const std::vector<char32_t>& _data, esize_t _startPos) {
{
if (_startPos>=_data.size()){ if (_startPos>=_data.size()){
return 0; return 0;
} }
@ -166,8 +164,7 @@ esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UChar>& _data, esize_t _s
return pos - _startPos; return pos - _startPos;
} }
esize_t etk::getLenOfPThese(const etk::Vector<etk::UChar>& _data, esize_t _startPos) esize_t etk::getLenOfPThese(const std::vector<char32_t>& _data, esize_t _startPos) {
{
esize_t pos = _startPos; esize_t pos = _startPos;
int32_t nbOpen = 0; int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')' // special case of the (...) or | ==> we search '|' or ')'
@ -208,8 +205,7 @@ esize_t etk::getLenOfPThese(const etk::Vector<etk::UChar>& _data, esize_t _start
} }
esize_t etk::getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _startPos) esize_t etk::getLenOfBracket(const std::vector<char32_t>& _data, esize_t _startPos) {
{
esize_t pos = _startPos; esize_t pos = _startPos;
// special case of the (...) or | ==> we search '|' or ')' // special case of the (...) or | ==> we search '|' or ')'
if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) { if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) {
@ -233,7 +229,7 @@ esize_t etk::getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _star
return sizeInside; return sizeInside;
} else if( _data[pos] != REGEXP_OPCODE_TO } else if( _data[pos] != REGEXP_OPCODE_TO
&& _data[pos] > 0xFF ) { && _data[pos] > 0xFF ) {
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos].get() << "'"); TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos] << "'");
return 0; return 0;
} }
pos++; pos++;
@ -242,8 +238,7 @@ esize_t etk::getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _star
} }
esize_t etk::getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startPos) esize_t etk::getLenOfBrace(const std::vector<char32_t>& _data, esize_t _startPos) {
{
int32_t pos = _startPos; int32_t pos = _startPos;
// special case of the (...) or | ==> we search '|' or ')' // special case of the (...) or | ==> we search '|' or ')'
if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) { if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) {
@ -268,7 +263,7 @@ esize_t etk::getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startP
} else if( _data[pos] != ',' } else if( _data[pos] != ','
&& ( _data[pos] < '0' && ( _data[pos] < '0'
|| _data[pos] > '9') ) { || _data[pos] > '9') ) {
TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos].get() << "'"); TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos] << "'");
return 0; return 0;
} }
pos++; pos++;
@ -277,14 +272,11 @@ esize_t etk::getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startP
} }
esize_t etk::getLenOfNormal(const etk::Vector<etk::UChar>& _data, esize_t _startPos) esize_t etk::getLenOfNormal(const std::vector<char32_t>& _data, esize_t _startPos) {
{
esize_t pos = _startPos; esize_t pos = _startPos;
// find size ... // find size ...
while (pos < _data.size() ) { while (pos < _data.size() ) {
switch(_data[pos].get()) switch(_data[pos]) {
{
case REGEXP_OPCODE_PTHESE_IN: case REGEXP_OPCODE_PTHESE_IN:
case REGEXP_OPCODE_PTHESE_OUT: case REGEXP_OPCODE_PTHESE_OUT:
case REGEXP_OPCODE_BRACKET_IN: case REGEXP_OPCODE_BRACKET_IN:
@ -329,7 +321,7 @@ esize_t etk::getLenOfNormal(const etk::Vector<etk::UChar>& _data, esize_t _start
} }
bool etk::parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint32_t& _max) bool etk::parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _max)
{ {
//TK_INFO("parse {...} in "; DisplayElem(data); ); //TK_INFO("parse {...} in "; DisplayElem(data); );
esize_t k=0; esize_t k=0;
@ -344,11 +336,11 @@ bool etk::parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint3
} if (_data[k] == '}' ) { } if (_data[k] == '}' ) {
SecondElement = firstElement; SecondElement = firstElement;
goto allIsSet; goto allIsSet;
} else if(true==_data[k].isInteger()) { } else if(etk::isInteger(_data[k]) == true) {
firstElement *= 10; firstElement *= 10;
firstElement += _data[k].toInt32(); firstElement += etk::toInt32(_data[k]);
} else { } else {
TK_ERROR("Can not parse this element " << (char)_data[k].get() << " at pos " << k); TK_ERROR("Can not parse this element " << (char)_data[k] << " at pos " << k);
return false; return false;
} }
k++; k++;
@ -362,9 +354,9 @@ bool etk::parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint3
return false; return false;
} if (_data[k] == '}') { } if (_data[k] == '}') {
goto allIsSet; goto allIsSet;
} else if (true==_data[k].isInteger()) { } else if (true == etk::isInteger(_data[k])) {
SecondElement *= 10; SecondElement *= 10;
SecondElement += _data[k].toInt32(); SecondElement += etk::toInt32(_data[k]);
} else { } else {
TK_ERROR("Can not parse this element " << _data[k] << " at pos " << k); TK_ERROR("Can not parse this element " << _data[k] << " at pos " << k);
return false; return false;

View File

@ -12,7 +12,7 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/UString.h> #include <etk/UString.h>
#include <etk/Vector.h> #include <vector>
#define TK_REG_EXP_DBG_MODE TK_VERBOSE #define TK_REG_EXP_DBG_MODE TK_VERBOSE
@ -56,14 +56,14 @@ typedef struct {
extern const convertionTable_ts constConvertionTable[]; extern const convertionTable_ts constConvertionTable[];
extern const esize_t constConvertionTableSize; extern const esize_t constConvertionTableSize;
void displayElem(const etk::Vector<etk::UChar>& _data, esize_t _start=0, esize_t _stop=0x7FFFFFFF); void displayElem(const std::vector<char32_t>& _data, esize_t _start=0, esize_t _stop=0x7FFFFFFF);
char * levelSpace(uint32_t _level); char * levelSpace(uint32_t _level);
esize_t getLenOfPTheseElem(const etk::Vector<etk::UChar>& _data, esize_t _startPos); esize_t getLenOfPTheseElem(const std::vector<char32_t>& _data, esize_t _startPos);
esize_t getLenOfPThese(const etk::Vector<etk::UChar>& _data, esize_t _startPos); esize_t getLenOfPThese(const std::vector<char32_t>& _data, esize_t _startPos);
esize_t getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _startPos); esize_t getLenOfBracket(const std::vector<char32_t>& _data, esize_t _startPos);
esize_t getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startPos); esize_t getLenOfBrace(const std::vector<char32_t>& _data, esize_t _startPos);
esize_t getLenOfNormal(const etk::Vector<etk::UChar>& _data, esize_t _startPos); esize_t getLenOfNormal(const std::vector<char32_t>& _data, esize_t _startPos);
bool parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint32_t& _max); bool parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _max);
#undef __class__ #undef __class__
@ -78,7 +78,7 @@ template<class CLASS_TYPE> class RegExpNode
uint32_t m_multipleMin; //!< minimum repetition (included) uint32_t m_multipleMin; //!< minimum repetition (included)
uint32_t m_multipleMax; //!< maximum repetition (included) uint32_t m_multipleMax; //!< maximum repetition (included)
// Data Section ... (can have no data...) // Data Section ... (can have no data...)
etk::Vector<etk::UChar> m_RegExpData; //!< data to parse and compare in some case ... std::vector<char32_t> m_RegExpData; //!< data to parse and compare in some case ...
public : public :
/** /**
* @brief Constructor * @brief Constructor
@ -98,7 +98,7 @@ template<class CLASS_TYPE> class RegExpNode
* @param[in] _data Property of the regexp * @param[in] _data Property of the regexp
* @return the number of element used * @return the number of element used
*/ */
virtual int32_t generate(const etk::Vector<etk::UChar>& _data) virtual int32_t generate(const std::vector<char32_t>& _data)
{ {
return 0; return 0;
}; };
@ -151,7 +151,7 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
{ {
protected : protected :
// SubNodes : // SubNodes :
etk::Vector<etk::UChar> m_data; std::vector<char32_t> m_data;
public : public :
/** /**
@ -164,13 +164,13 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
*/ */
~RegExpNodeValue(void) { }; ~RegExpNodeValue(void) { };
int32_t generate(const etk::Vector<etk::UChar>& _data) int32_t generate(const std::vector<char32_t>& _data)
{ {
RegExpNode<CLASS_TYPE>::m_RegExpData = _data; RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse \"Value\" data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData);); TK_REG_EXP_DBG_MODE("Request Parse \"Value\" data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
m_data.clear(); m_data.clear();
for (int32_t i=0; i<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); i++) { for (int32_t i=0; i<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); i++) {
m_data.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[i]); m_data.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[i]);
} }
return _data.size(); return _data.size();
}; };
@ -234,7 +234,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
{ {
protected : protected :
// SubNodes : // SubNodes :
etk::Vector<etk::UChar> m_data; std::vector<char32_t> m_data;
public : public :
/** /**
@ -247,13 +247,13 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
*/ */
~RegExpNodeBracket(void) { }; ~RegExpNodeBracket(void) { };
int32_t generate(const etk::Vector<etk::UChar>& _data) int32_t generate(const std::vector<char32_t>& _data)
{ {
RegExpNode<CLASS_TYPE>::m_RegExpData = _data; RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse [...] data="; displayElem(_data);); TK_REG_EXP_DBG_MODE("Request Parse [...] data="; displayElem(_data););
m_data.clear(); m_data.clear();
etk::UChar lastElement = 'a'; char32_t lastElement = 'a';
bool multipleElement = false; bool multipleElement = false;
// //
for (int32_t kkk=0; kkk<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); kkk++) { for (int32_t kkk=0; kkk<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); kkk++) {
@ -261,16 +261,16 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
TK_ERROR("Can not have 2 consecutive - in [...]"); TK_ERROR("Can not have 2 consecutive - in [...]");
return 0; return 0;
} else if (multipleElement == true) { } else if (multipleElement == true) {
etk::UChar jjj='\0'; char32_t jjj='\0';
for (jjj=lastElement+1; jjj <= RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]; jjj+=1) { for (jjj=lastElement+1; jjj <= RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]; jjj+=1) {
m_data.pushBack(jjj); m_data.push_back(jjj);
} }
multipleElement = false; multipleElement = false;
} else if(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == REGEXP_OPCODE_TO) { } else if(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == REGEXP_OPCODE_TO) {
multipleElement = true; multipleElement = true;
} else { } else {
lastElement = RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]; lastElement = RegExpNode<CLASS_TYPE>::m_RegExpData[kkk];
m_data.pushBack(lastElement); m_data.push_back(lastElement);
} }
} }
// check size ... // check size ...
@ -347,7 +347,7 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE>
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
TK_REG_EXP_DBG_MODE("compare : " << tmpVal); TK_REG_EXP_DBG_MODE("compare : " << tmpVal);
if( tmpVal >= '0' if( tmpVal >= '0'
&& tmpVal <= '9') && tmpVal <= '9')
@ -402,7 +402,7 @@ template<class CLASS_TYPE> class RegExpNodeDigitNot : public RegExpNode<CLASS_TY
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( tmpVal < '0' if( tmpVal < '0'
|| tmpVal > '9') { || tmpVal > '9') {
_findLen += 1; _findLen += 1;
@ -451,7 +451,7 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z') && tmpVal <= 'z')
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -505,7 +505,7 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( ( tmpVal < 'a' if( ( tmpVal < 'a'
&& tmpVal > 'Z') && tmpVal > 'Z')
|| tmpVal < 'A' || tmpVal < 'A'
@ -559,7 +559,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( tmpVal == ' ' if( tmpVal == ' '
|| tmpVal == '\t' || tmpVal == '\t'
|| tmpVal == '\n' || tmpVal == '\n'
@ -615,7 +615,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( tmpVal != ' ' if( tmpVal != ' '
&& tmpVal != '\t' && tmpVal != '\t'
&& tmpVal != '\n' && tmpVal != '\n'
@ -670,7 +670,7 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TY
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z' ) && tmpVal <= 'z' )
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -725,7 +725,7 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( ( tmpVal < 'A' if( ( tmpVal < 'A'
&& tmpVal > '9' ) && tmpVal > '9' )
|| ( tmpVal < 'a' || ( tmpVal < 'a'
@ -782,7 +782,7 @@ template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE>
bool tmpFind = true; bool tmpFind = true;
uint32_t jjj; uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UChar tmpVal = _data[_currentPos+jjj]; char32_t tmpVal = _data[_currentPos+jjj];
if( ( tmpVal > 0x08 if( ( tmpVal > 0x08
&& tmpVal < 0x0A ) && tmpVal < 0x0A )
|| ( tmpVal > 0x1F || ( tmpVal > 0x1F
@ -896,7 +896,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
{ {
protected : protected :
// SubNodes : // SubNodes :
etk::Vector<RegExpNode<CLASS_TYPE>*> m_subNode; std::vector<RegExpNode<CLASS_TYPE>*> m_subNode;
public : public :
/** /**
* @brief Constructor * @brief Constructor
@ -908,13 +908,13 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
*/ */
~RegExpNodePTheseElem(void) { }; ~RegExpNodePTheseElem(void) { };
int32_t generate(const etk::Vector<etk::UChar>& _data) int32_t generate(const std::vector<char32_t>& _data)
{ {
RegExpNode<CLASS_TYPE>::m_RegExpData = _data; RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData);); TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
esize_t pos = 0; esize_t pos = 0;
esize_t elementSize = 0; esize_t elementSize = 0;
etk::Vector<etk::UChar> tmpData; std::vector<char32_t> tmpData;
while (pos < RegExpNode<CLASS_TYPE>::m_RegExpData.size()) { while (pos < RegExpNode<CLASS_TYPE>::m_RegExpData.size()) {
tmpData.clear(); tmpData.clear();
switch (RegExpNode<CLASS_TYPE>::m_RegExpData[pos].get()) { switch (RegExpNode<CLASS_TYPE>::m_RegExpData[pos].get()) {
@ -922,12 +922,12 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
{ {
elementSize=getLenOfPThese(RegExpNode<CLASS_TYPE>::m_RegExpData, pos); elementSize=getLenOfPThese(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) { for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]); tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
} }
RegExpNodePThese<CLASS_TYPE> * myElem = new RegExpNodePThese<CLASS_TYPE>(); RegExpNodePThese<CLASS_TYPE> * myElem = new RegExpNodePThese<CLASS_TYPE>();
(void)myElem->generate(tmpData); (void)myElem->generate(tmpData);
// add to the subnode list : // add to the subnode list :
m_subNode.pushBack(myElem); m_subNode.push_back(myElem);
// move current position ... // move current position ...
pos += elementSize+1; pos += elementSize+1;
} }
@ -939,12 +939,12 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
{ {
elementSize=getLenOfBracket(RegExpNode<CLASS_TYPE>::m_RegExpData, pos); elementSize=getLenOfBracket(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) { for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]); tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
} }
RegExpNodeBracket<CLASS_TYPE> * myElem = new RegExpNodeBracket<CLASS_TYPE>(); RegExpNodeBracket<CLASS_TYPE> * myElem = new RegExpNodeBracket<CLASS_TYPE>();
(void)myElem->generate(tmpData); (void)myElem->generate(tmpData);
// add to the subnode list : // add to the subnode list :
m_subNode.pushBack(myElem); m_subNode.push_back(myElem);
// move current position ... // move current position ...
pos += elementSize+1; pos += elementSize+1;
} }
@ -956,7 +956,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
{ {
elementSize=getLenOfBrace(RegExpNode<CLASS_TYPE>::m_RegExpData, pos); elementSize=getLenOfBrace(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) { for (esize_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]); tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
} }
uint32_t min = 0; uint32_t min = 0;
uint32_t max = 0; uint32_t max = 0;
@ -986,49 +986,49 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
TK_ERROR("Impossible case : '|' " << pos); TK_ERROR("Impossible case : '|' " << pos);
return false; return false;
case REGEXP_OPCODE_DOT: case REGEXP_OPCODE_DOT:
m_subNode.pushBack(new RegExpNodeDot<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeDot<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_START_OF_LINE: case REGEXP_OPCODE_START_OF_LINE:
m_subNode.pushBack(new RegExpNodeSOL<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeSOL<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_END_OF_LINE: case REGEXP_OPCODE_END_OF_LINE:
m_subNode.pushBack(new RegExpNodeEOL<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeEOL<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_DIGIT: case REGEXP_OPCODE_DIGIT:
m_subNode.pushBack(new RegExpNodeDigit<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeDigit<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_DIGIT_NOT: case REGEXP_OPCODE_DIGIT_NOT:
m_subNode.pushBack(new RegExpNodeDigitNot<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeDigitNot<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_LETTER: case REGEXP_OPCODE_LETTER:
m_subNode.pushBack(new RegExpNodeLetter<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeLetter<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_LETTER_NOT: case REGEXP_OPCODE_LETTER_NOT:
m_subNode.pushBack(new RegExpNodeLetterNot<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeLetterNot<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_SPACE: case REGEXP_OPCODE_SPACE:
m_subNode.pushBack(new RegExpNodeWhiteSpace<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeWhiteSpace<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_SPACE_NOT: case REGEXP_OPCODE_SPACE_NOT:
m_subNode.pushBack(new RegExpNodeWhiteSpaceNot<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeWhiteSpaceNot<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_WORD: case REGEXP_OPCODE_WORD:
m_subNode.pushBack(new RegExpNodeWordChar<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeWordChar<CLASS_TYPE>());
break; break;
case REGEXP_OPCODE_WORD_NOT: case REGEXP_OPCODE_WORD_NOT:
m_subNode.pushBack(new RegExpNodeWordCharNot<CLASS_TYPE>()); m_subNode.push_back(new RegExpNodeWordCharNot<CLASS_TYPE>());
break; break;
default: default:
{ {
elementSize = getLenOfNormal(RegExpNode<CLASS_TYPE>::m_RegExpData, pos); elementSize = getLenOfNormal(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
for (esize_t kkk=pos; kkk<pos+elementSize; kkk++) { for (esize_t kkk=pos; kkk<pos+elementSize; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]); tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
} }
RegExpNodeValue<CLASS_TYPE> * myElem = new RegExpNodeValue<CLASS_TYPE>(); RegExpNodeValue<CLASS_TYPE> * myElem = new RegExpNodeValue<CLASS_TYPE>();
(void)myElem->generate(tmpData); (void)myElem->generate(tmpData);
// add to the subnode list : // add to the subnode list :
m_subNode.pushBack(myElem); m_subNode.push_back(myElem);
// move current position ... // move current position ...
pos += elementSize-1; pos += elementSize-1;
} }
@ -1105,7 +1105,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE> template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE>
{ {
protected : protected :
etk::Vector<RegExpNode<CLASS_TYPE>*> m_subNode; //!< Subnode list std::vector<RegExpNode<CLASS_TYPE>*> m_subNode; //!< Subnode list
public : public :
/** /**
* @brief Constructor * @brief Constructor
@ -1123,7 +1123,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
}; };
int32_t generate(const etk::Vector<etk::UChar>& _data) int32_t generate(const std::vector<char32_t>& _data)
{ {
RegExpNode<CLASS_TYPE>::m_RegExpData = _data; RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse (...) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData);); TK_REG_EXP_DBG_MODE("Request Parse (...) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
@ -1133,14 +1133,14 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
// generate all the "elemTypePTheseElem" of the Node // generate all the "elemTypePTheseElem" of the Node
while (elementSize>0) { while (elementSize>0) {
// geerate output deta ... // geerate output deta ...
etk::Vector<etk::UChar> tmpData; std::vector<char32_t> tmpData;
for (esize_t kkk=pos; kkk<pos+elementSize; kkk++) { for (esize_t kkk=pos; kkk<pos+elementSize; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]); tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
} }
RegExpNodePTheseElem<CLASS_TYPE> * myElem = new RegExpNodePTheseElem<CLASS_TYPE>(); RegExpNodePTheseElem<CLASS_TYPE> * myElem = new RegExpNodePTheseElem<CLASS_TYPE>();
(void)myElem->generate(tmpData); (void)myElem->generate(tmpData);
// add to the subnode list : // add to the subnode list :
m_subNode.pushBack(myElem); m_subNode.push_back(myElem);
pos += elementSize+1; pos += elementSize+1;
TK_REG_EXP_DBG_MODE("plop="; displayElem(_data, pos, pos+1);); TK_REG_EXP_DBG_MODE("plop="; displayElem(_data, pos, pos+1););
elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos); elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
@ -1207,7 +1207,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
template<class CLASS_TYPE> class RegExp template<class CLASS_TYPE> class RegExp
{ {
private: private:
etk::UString m_expressionRequested; //!< Regular expression parsed ... std::u32string m_expressionRequested; //!< Regular expression parsed ...
elementPos_ts m_areaFind; //!< position around selection elementPos_ts m_areaFind; //!< position around selection
RegExpNodePThese<CLASS_TYPE> m_exprRootNode; //!< The tree where data is set RegExpNodePThese<CLASS_TYPE> m_exprRootNode; //!< The tree where data is set
bool m_isOk; //!< Known if we can process with this regExp bool m_isOk; //!< Known if we can process with this regExp
@ -1220,8 +1220,8 @@ template<class CLASS_TYPE> class RegExp
* @brief Constructor * @brief Constructor
* @param[in,out] _exp Regular expression to parse * @param[in,out] _exp Regular expression to parse
*/ */
RegExp(const etk::UString &_exp="") : RegExp(const std::u32string &_exp=U"") :
m_expressionRequested(""), m_expressionRequested(U""),
m_isOk(false), m_isOk(false),
m_notBeginWithChar(false), m_notBeginWithChar(false),
m_notEndWithChar(false) m_notEndWithChar(false)
@ -1245,10 +1245,10 @@ template<class CLASS_TYPE> class RegExp
* @brief Set a new regular expression matching * @brief Set a new regular expression matching
* @param[in] _regexp the new expression to search * @param[in] _regexp the new expression to search
*/ */
void setRegExp(const etk::UString &_regexp) void setRegExp(const std::u32string &_regexp)
{ {
m_expressionRequested = _regexp; m_expressionRequested = _regexp;
etk::Vector<etk::UChar> tmpExp; std::vector<char32_t> tmpExp;
TK_REG_EXP_DBG_MODE("---------------------------------------------------------------------"); TK_REG_EXP_DBG_MODE("---------------------------------------------------------------------");
TK_REG_EXP_DBG_MODE("Parse RegExp : (" << _regexp << ")" ); TK_REG_EXP_DBG_MODE("Parse RegExp : (" << _regexp << ")" );
@ -1279,9 +1279,9 @@ template<class CLASS_TYPE> class RegExp
&& _regexp[iii+1] == constConvertionTable[jjj].inputValue) && _regexp[iii+1] == constConvertionTable[jjj].inputValue)
{ {
if (constConvertionTable[jjj].newValue==0) { if (constConvertionTable[jjj].newValue==0) {
tmpExp.pushBack(constConvertionTable[jjj].specialChar); tmpExp.push_back(constConvertionTable[jjj].specialChar);
} else { } else {
tmpExp.pushBack(constConvertionTable[jjj].newValue); tmpExp.push_back(constConvertionTable[jjj].newValue);
} }
break; break;
} }
@ -1315,9 +1315,9 @@ template<class CLASS_TYPE> class RegExp
&& _regexp[iii] == constConvertionTable[jjj].inputValue) && _regexp[iii] == constConvertionTable[jjj].inputValue)
{ {
if (constConvertionTable[jjj].newValue==0) { if (constConvertionTable[jjj].newValue==0) {
tmpExp.pushBack(constConvertionTable[jjj].specialChar); tmpExp.push_back(constConvertionTable[jjj].specialChar);
} else { } else {
tmpExp.pushBack(constConvertionTable[jjj].newValue); tmpExp.push_back(constConvertionTable[jjj].newValue);
} }
break; break;
} }
@ -1325,7 +1325,7 @@ template<class CLASS_TYPE> class RegExp
// not find : normal element // not find : normal element
if (jjj==constConvertionTableSize) { if (jjj==constConvertionTableSize) {
//TK_REG_EXP_DBG_MODE("parse : '" << _regexp[iii] << "'" ); //TK_REG_EXP_DBG_MODE("parse : '" << _regexp[iii] << "'" );
tmpExp.pushBack(_regexp[iii]); tmpExp.push_back(_regexp[iii]);
} }
} }
} }
@ -1357,7 +1357,7 @@ template<class CLASS_TYPE> class RegExp
//TK_DEBUG("=> must not begin with char"); //TK_DEBUG("=> must not begin with char");
m_notBeginWithChar = true; m_notBeginWithChar = true;
// remove element // remove element
tmpExp.erase(0); tmpExp.erase(tmpExp.begin());
} }
if ( tmpExp.size()>0 if ( tmpExp.size()>0
&& tmpExp[tmpExp.size()-1] == REGEXP_OPCODE_NO_CHAR) && tmpExp[tmpExp.size()-1] == REGEXP_OPCODE_NO_CHAR)
@ -1365,7 +1365,7 @@ template<class CLASS_TYPE> class RegExp
//TK_DEBUG("=> must not end with char"); //TK_DEBUG("=> must not end with char");
m_notEndWithChar = true; m_notEndWithChar = true;
// remove element // remove element
tmpExp.erase(tmpExp.size()-1); tmpExp.erase(tmpExp.end());
} }
if (tmpExp.size() != m_exprRootNode.generate(tmpExp) ) { if (tmpExp.size() != m_exprRootNode.generate(tmpExp) ) {
@ -1382,7 +1382,7 @@ template<class CLASS_TYPE> class RegExp
* @brief Get the regular expression string * @brief Get the regular expression string
* @return the string representing the RegExp * @return the string representing the RegExp
*/ */
const etk::UString& getRegExp(void) const const std::u32string& getRegExp(void) const
{ {
return m_expressionRequested; return m_expressionRequested;
}; };
@ -1409,7 +1409,7 @@ template<class CLASS_TYPE> class RegExp
bool process(const CLASS_TYPE& _SearchIn, bool process(const CLASS_TYPE& _SearchIn,
esize_t _startPos, esize_t _startPos,
esize_t _endPos, esize_t _endPos,
etk::UChar _escapeChar=0) char32_t _escapeChar=0)
{ {
if (false == m_isOk) { if (false == m_isOk) {
return false; return false;
@ -1426,7 +1426,7 @@ template<class CLASS_TYPE> class RegExp
esize_t maxlen = _endPos-iii; esize_t maxlen = _endPos-iii;
if (true == m_notBeginWithChar) { if (true == m_notBeginWithChar) {
if (iii>0) { if (iii>0) {
etk::UChar tmpVal = _SearchIn[iii-1]; char32_t tmpVal = _SearchIn[iii-1];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z' ) && tmpVal <= 'z' )
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -1451,7 +1451,7 @@ template<class CLASS_TYPE> class RegExp
// Check end : // Check end :
if (true == m_notEndWithChar) { if (true == m_notEndWithChar) {
if (iii+findLen < _SearchIn.size() ) { if (iii+findLen < _SearchIn.size() ) {
etk::UChar tmpVal = _SearchIn[iii+findLen]; char32_t tmpVal = _SearchIn[iii+findLen];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z' ) && tmpVal <= 'z' )
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -1487,7 +1487,7 @@ template<class CLASS_TYPE> class RegExp
bool processOneElement( const CLASS_TYPE& _SearchIn, bool processOneElement( const CLASS_TYPE& _SearchIn,
esize_t _startPos, esize_t _startPos,
esize_t _endPos, esize_t _endPos,
etk::UChar _escapeChar=0) char32_t _escapeChar=0)
{ {
if (false == m_isOk) { if (false == m_isOk) {
return false; return false;
@ -1503,7 +1503,7 @@ template<class CLASS_TYPE> class RegExp
esize_t maxlen = _endPos-_startPos; esize_t maxlen = _endPos-_startPos;
if (true == m_notBeginWithChar) { if (true == m_notBeginWithChar) {
if (_startPos>0) { if (_startPos>0) {
etk::UChar tmpVal = _SearchIn[_startPos-1]; char32_t tmpVal = _SearchIn[_startPos-1];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z' ) && tmpVal <= 'z' )
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -1528,7 +1528,7 @@ template<class CLASS_TYPE> class RegExp
// Check end : // Check end :
if (true == m_notEndWithChar) { if (true == m_notEndWithChar) {
if (_startPos+findLen < _SearchIn.size() ) { if (_startPos+findLen < _SearchIn.size() ) {
etk::UChar tmpVal = _SearchIn[_startPos+findLen]; char32_t tmpVal = _SearchIn[_startPos+findLen];
if( ( tmpVal >= 'a' if( ( tmpVal >= 'a'
&& tmpVal <= 'z' ) && tmpVal <= 'z' )
|| ( tmpVal >= 'A' || ( tmpVal >= 'A'
@ -1574,10 +1574,10 @@ template<class CLASS_TYPE> class RegExp
* @param[in,out] * @param[in,out]
* @return * @return
*/ */
bool checkGoodPosition(const etk::Vector<etk::UChar>& _tmpExp, esize_t& _pos) bool checkGoodPosition(const std::vector<char32_t>& _tmpExp, esize_t& _pos)
{ {
etk::UChar curentCode = _tmpExp[_pos]; char32_t curentCode = _tmpExp[_pos];
etk::UChar endCode = REGEXP_OPCODE_PTHESE_OUT; char32_t endCode = REGEXP_OPCODE_PTHESE_OUT;
const char *input = "(...)"; const char *input = "(...)";
if (curentCode == REGEXP_OPCODE_BRACKET_IN) { if (curentCode == REGEXP_OPCODE_BRACKET_IN) {
endCode = REGEXP_OPCODE_BRACKET_OUT; endCode = REGEXP_OPCODE_BRACKET_OUT;
@ -1603,7 +1603,7 @@ template<class CLASS_TYPE> class RegExp
} else { } else {
// otherwise, we check the error in the element ... // otherwise, we check the error in the element ...
char *find = NULL; char *find = NULL;
switch (_tmpExp[_pos].get()) switch (_tmpExp[_pos])
{ {
case REGEXP_OPCODE_PTHESE_IN: find = (char*)"("; break; case REGEXP_OPCODE_PTHESE_IN: find = (char*)"("; break;
case REGEXP_OPCODE_BRACKET_IN: find = (char*)"["; break; case REGEXP_OPCODE_BRACKET_IN: find = (char*)"["; break;
@ -1679,7 +1679,7 @@ template<class CLASS_TYPE> class RegExp
* @param[in,out] * @param[in,out]
* @return * @return
*/ */
bool checkGoodPosition(const etk::Vector<etk::UChar>& _tmpExp) bool checkGoodPosition(const std::vector<char32_t>& _tmpExp)
{ {
esize_t pos = 0; esize_t pos = 0;
while (pos < _tmpExp.size()) { while (pos < _tmpExp.size()) {

View File

@ -149,10 +149,10 @@ etk::CCout::~CCout()
}; };
etk::CCout& etk::CCout::operator << (const etk::UChar& _t) etk::CCout& etk::CCout::operator << (char32_t _t)
{ {
char output[5]; char output[5];
_t.getUtf8(output); getUtf8(_t, output);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output); snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this; return *this;

View File

@ -31,7 +31,7 @@ namespace etk {
public: public:
CCout(void); CCout(void);
~CCout(void); ~CCout(void);
CCout& operator << (const etk::UChar& _t);; CCout& operator << (char32_t _t);;
CCout& operator << (int8_t _t); CCout& operator << (int8_t _t);
CCout& operator << (int16_t _t); CCout& operator << (int16_t _t);
CCout& operator << (int32_t _t); CCout& operator << (int32_t _t);

View File

@ -12,150 +12,104 @@
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/Stream.h> #include <etk/Stream.h>
#include <etk/Vector.h> #include <vector>
#include <etk/Char.h> #include <etk/Char.h>
const etk::UChar etk::UChar::Null('\0');
const etk::UChar etk::UChar::Return('\n');
const etk::UChar etk::UChar::CarrierReturn('\r');
const etk::UChar etk::UChar::Tabulation('\t');
const etk::UChar etk::UChar::Suppress((const char)127);
const etk::UChar etk::UChar::Delete((const char)8);
const etk::UChar etk::UChar::Space(' ');
const etk::UChar etk::UChar::Escape((const char)27);
void etk::UChar::lower(void) bool etk::isWhiteChar(char32_t _val) {
{ if( _val == ' '
if( m_value>=(uint32_t)'A' || _val == '\t'
&& m_value<=(uint32_t)'Z') { || _val == '\n'
m_value += (uint32_t)'a' - (uint32_t)'A'; || _val == '\r') {
}
}
etk::UChar etk::UChar::toLower(void) const
{
if( m_value>=(uint32_t)'A'
&& m_value<=(uint32_t)'Z') {
return m_value + (uint32_t)'a' - (uint32_t)'A';
}
return m_value;
}
void etk::UChar::upper(void)
{
if( m_value>=(uint32_t)'a'
&& m_value<=(uint32_t)'z') {
m_value += (uint32_t)'A' - (uint32_t)'a';
}
}
etk::UChar etk::UChar::toUpper(void) const
{
if( m_value>=(uint32_t)'a'
&& m_value<=(uint32_t)'z') {
return m_value + (uint32_t)'A' - (uint32_t)'a';
}
return m_value;
}
bool etk::UChar::compareNoCase(const etk::UChar& _obj) const
{
return toUpper() == _obj.toUpper();
}
etk::UChar etk::UChar::changeOrder(void) const
{
if (m_value >= 'A' && m_value <= 'Z') {
return (m_value - (uint32_t)'A')*2 + 'A';
}
if (m_value >= 'a' && m_value <= 'z') {
return (m_value - (uint32_t)'a')*2 + 'A' + 1;
}
if (m_value >= ':' && m_value <= '@') {
return m_value + 52;
}
if (m_value >= '[' && m_value <= '`') {
return m_value +26;
}
return m_value;
}
bool etk::UChar::isWhiteChar(void) const
{
if( m_value == ' '
|| m_value == '\t'
|| m_value == '\n'
|| m_value == '\r') {
return true; return true;
} }
return false; return false;
} }
bool etk::UChar::isSpecialChar(void) const bool etk::isSpecialChar(char32_t _val) {
{ if( _val < '0'
if( m_value < '0' || (_val > '9' && _val < 'A')
|| (m_value > '9' && m_value < 'A') || (_val > 'Z' && _val < 'a')
|| (m_value > 'Z' && m_value < 'a') || (_val > 'z' && _val < 0xFF) ) {
|| (m_value > 'z' && m_value < 0xFF) ) {
return true; return true;
} }
return false; return false;
} }
bool etk::UChar::isInteger(void) const bool etk::isInteger(char32_t _val) {
{ if( _val >= (uint32_t)'0'
if( m_value>=(uint32_t)'0' && _val <= (uint32_t)'9') {
&& m_value<=(uint32_t)'9') {
return true; return true;
} }
return false; return false;
} }
int32_t etk::UChar::toInt32(void) const int32_t etk::toInt32(char32_t _val) {
{ return _val - (uint32_t)'0';
return m_value - (uint32_t)'0';
} }
/*
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UChar& _obj) char32_t etk::toLower(char32_t _val) {
{ if( _val>=(uint32_t)'A'
char output_UTF8[8]; && _val<=(uint32_t)'Z') {
unicode::convertUnicodeToUtf8(_obj, output_UTF8); return _val + (uint32_t)'a' - (uint32_t)'A';
_os << &output_UTF8[0]; }
return _os; return _val;
}
char32_t etk::toUpper(char32_t _val) {
if( _val>=(uint32_t)'a'
&& _val<=(uint32_t)'z') {
return _val + (uint32_t)'A' - (uint32_t)'a';
}
return _val;
}
bool etk::compareNoCase(char32_t _val1, char32_t _val2) {
return toUpper(_val1) == toUpper(_val2);
} }
*/
uint32_t etk::UChar::getUtf8(void) const char32_t etk::changeOrder(char32_t _val) {
{ if (_val >= 'A' && _val <= 'Z') {
return (_val - (uint32_t)'A')*2 + 'A';
}
if (_val >= 'a' && _val <= 'z') {
return (_val - (uint32_t)'a')*2 + 'A' + 1;
}
if (_val >= ':' && _val <= '@') {
return _val + 52;
}
if (_val >= '[' && _val <= '`') {
return _val +26;
}
return _val;
}
static uint32_t getUtf8Val(char32_t _val) {
uint32_t output = 0; uint32_t output = 0;
if (m_value <= 127) { if (_val <= 127) {
output = m_value; output = _val;
} else if (m_value <= 2047) { } else if (_val <= 2047) {
// output ==> 00000000 00000000 110xxxxx 10xxxxxx // output ==> 00000000 00000000 110xxxxx 10xxxxxx
// input ==> -------- -------- -----222 22111111 // input ==> -------- -------- -----222 22111111
output = 0x0000C080; output = 0x0000C080;
output+= (m_value & 0x000007C0)<<2; output+= (_val & 0x000007C0)<<2;
output+= m_value & 0x0000003F; output+= _val & 0x0000003F;
} else if (m_value <= 65535) { } else if (_val <= 65535) {
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx // output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
// input ==> -------- -------- 33332222 22111111 // input ==> -------- -------- 33332222 22111111
output = 0x00E08080; output = 0x00E08080;
output+= (m_value & 0x0000F000)<<4; output+= (_val & 0x0000F000)<<4;
output+= (m_value & 0x00000FC0)<<2; output+= (_val & 0x00000FC0)<<2;
output+= m_value & 0x0000003F; output+= _val & 0x0000003F;
} else if (m_value <= 1114111) { } else if (_val <= 1114111) {
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx // output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// input ==> -------- ---44433 33332222 22111111 // input ==> -------- ---44433 33332222 22111111
output = 0xF0808080; output = 0xF0808080;
output+= (m_value & 0x001C0000)<<6; output+= (_val & 0x001C0000)<<6;
output+= (m_value & 0x0003F000)<<4; output+= (_val & 0x0003F000)<<4;
output+= (m_value & 0x00000FC0)<<2; output+= (_val & 0x00000FC0)<<2;
output+= m_value & 0x0000003F; output+= _val & 0x0000003F;
} else { } else {
TK_ERROR("NON UTF8 caracter input..."); TK_ERROR("NON UTF8 caracter input...");
return 0; return 0;
@ -164,9 +118,8 @@ uint32_t etk::UChar::getUtf8(void) const
return output; return output;
} }
int8_t etk::UChar::getUtf8(char _output[5]) const int8_t etk::getUtf8(char32_t _val, char _output[5]) {
{ uint32_t value = getUtf8Val(_val);
uint32_t value = getUtf8();
if (0xFF >= value) { if (0xFF >= value) {
_output[0] = (char)value; _output[0] = (char)value;
_output[1] = '\0'; _output[1] = '\0';
@ -191,10 +144,134 @@ int8_t etk::UChar::getUtf8(char _output[5]) const
return 4; return 4;
} }
} }
/*
etk::Vector<int8_t> etk::UChar::GetUtf8(void) const uint8_t sizeElement(const char* _data, int32_t _lenMax)
{ {
etk::Vector<int8_t> ret; uint8_t size = 0;
TK_ASSERT(0 <= _lenMax, "size can not be < 0 ...");
if (0 > _lenMax) {
return 0;
}
//4 case
if( _lenMax >= 1
&& (_data[0] & 0x80) == 0x00 ) {
// One Char Element
size = 1;
} else if( _lenMax >= 2
&& (_data[0] & 0xE0) == 0xC0
&& (_data[1] & 0xC0) == 0x80) {
size = 2;
} else if( _lenMax >= 3
&& (_data[0] & 0xF0) == 0xE0
&& (_data[1] & 0xC0) == 0x80
&& (_data[2] & 0xC0) == 0x80) {
size = 3;
} else if( _lenMax >= 4
&& (_data[0] & 0xF8) == 0xF0
&& (_data[1] & 0xC0) == 0x80
&& (_data[2] & 0xC0) == 0x80
&& (_data[3] & 0xC0) == 0x80) {
size = 4;
}
return size;
}
char32_t etk::setUtf8(const char* _input) {
char32_t value = 0;
if (NULL == _input) {
return value;
}
int32_t len = strlen(_input);
len = sizeElement(_input, len);
switch (len) {
default:
// case 0 : An error occured...
value = _input[0];
return value;
case 1:
value = (uint8_t)(_input[0]) & 0x7F;
return value;
case 2:
value = (((uint8_t)_input[0]) & 0x1F)<< 6;
value += ((uint8_t)_input[1]) & 0x3F;
return value;
case 3:
value = (((uint8_t)_input[0]) & 0x0F)<< 12;
value += (((uint8_t)_input[1]) & 0x3F)<< 6;
value += ((uint8_t)_input[2]) & 0x3F;
return value;
case 4:
value = (((uint8_t)_input[0]) & 0x07)<< 18;
value += (((uint8_t)_input[1]) & 0x3F)<< 12;
value += (((uint8_t)_input[2]) & 0x3F)<< 6;
value += ((uint8_t)_input[3]) & 0x3F;
return value;
}
}
#if 0
const char32_t char32_t::Null('\0');
const char32_t char32_t::Return('\n');
const char32_t char32_t::CarrierReturn('\r');
const char32_t char32_t::Tabulation('\t');
const char32_t char32_t::Suppress((const char)127);
const char32_t char32_t::Delete((const char)8);
const char32_t char32_t::Space(' ');
const char32_t char32_t::Escape((const char)27);
bool char32_t::isWhiteChar(void) const
{
if( m_value == ' '
|| m_value == '\t'
|| m_value == '\n'
|| m_value == '\r') {
return true;
}
return false;
}
bool char32_t::isSpecialChar(void) const
{
if( m_value < '0'
|| (m_value > '9' && m_value < 'A')
|| (m_value > 'Z' && m_value < 'a')
|| (m_value > 'z' && m_value < 0xFF) ) {
return true;
}
return false;
}
bool char32_t::isInteger(void) const
{
if( m_value>=(uint32_t)'0'
&& m_value<=(uint32_t)'9') {
return true;
}
return false;
}
int32_t char32_t::toInt32(void) const
{
return m_value - (uint32_t)'0';
}
/*
etk::CCout& etk::operator <<(etk::CCout& _os, char32_t _obj)
{
char output_UTF8[8];
unicode::convertUnicodeToUtf8(_obj, output_UTF8);
_os << &output_UTF8[0];
return _os;
}
*/
/*
std::vector<int8_t> char32_t::GetUtf8(void) const
{
std::vector<int8_t> ret;
uint32_t value = GetUtf8(); uint32_t value = GetUtf8();
if (0xFF >= value) { if (0xFF >= value) {
ret.PushBack((char)value); ret.PushBack((char)value);
@ -246,7 +323,7 @@ uint8_t sizeElement(const char* _data, int32_t _lenMax)
} }
int8_t etk::UChar::setUtf8(const char* _input) int8_t char32_t::setUtf8(const char* _input)
{ {
m_value = 0; m_value = 0;
if (NULL == _input) { if (NULL == _input) {
@ -280,7 +357,7 @@ int8_t etk::UChar::setUtf8(const char* _input)
} }
} }
int8_t etk::UChar::theoricUTF8Len(const char _input) int8_t char32_t::theoricUTF8Len(const char _input)
{ {
if((_input&0x80) == 0x00 ) { if((_input&0x80) == 0x00 ) {
return 1; return 1;
@ -297,7 +374,7 @@ int8_t etk::UChar::theoricUTF8Len(const char _input)
return 1; return 1;
} }
bool etk::UChar::theoricUTF8First(const char _input) bool char32_t::theoricUTF8First(const char _input)
{ {
// When started with the bit 0 then the size is signle element. // When started with the bit 0 then the size is signle element.
if((_input&0x80) == 0x00 ) { if((_input&0x80) == 0x00 ) {
@ -309,3 +386,5 @@ bool etk::UChar::theoricUTF8First(const char _input)
} }
return false; return false;
} }
#endif

View File

@ -39,7 +39,8 @@ namespace etk {
REGEXP_OPCODE_ERROR, // not used REGEXP_OPCODE_ERROR, // not used
}; };
class UChar { #if 0
class UChar : public char32_t{
public: // classic unicar code : public: // classic unicar code :
static const UChar Null; //!< '\0' static const UChar Null; //!< '\0'
static const UChar Return; //!< '\n' static const UChar Return; //!< '\n'
@ -49,126 +50,14 @@ namespace etk {
static const UChar Delete; //!< DEL static const UChar Delete; //!< DEL
static const UChar Space; //!< ' ' SPACE static const UChar Space; //!< ' ' SPACE
static const UChar Escape; //!< ESC Escape static const UChar Escape; //!< ESC Escape
private:
uint32_t m_value;
public:
// note : No preset at this element to prevent unneded set
UChar(void) {
}; };
UChar(const etk::UChar& _obj) :
m_value(_obj.m_value) {
};
UChar(const char _obj) :
m_value((uint32_t)_obj){
};
UChar(const enum regExpPrivateSection _obj) :
m_value((uint32_t)_obj) {
};
~UChar(void) {}
/*****************************************************
* = assigment
*****************************************************/
const etk::UChar& operator= (const etk::UChar& _obj ) {
m_value = _obj.m_value;
return *this;
};
/*****************************************************
* == operator
*****************************************************/
bool operator== (const etk::UChar& _obj) const {
return m_value == _obj.m_value;
};
bool compareNoCase(const etk::UChar& _obj) const;
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const etk::UChar& _obj) const {
return m_value != _obj.m_value;
};
/*****************************************************
* > < >= <= operator
*****************************************************/
bool operator> (const etk::UChar& _obj) const {
return m_value > _obj.m_value;
};
bool operator>= (const etk::UChar& _obj) const {
return m_value >= _obj.m_value;
};
bool operator< (const etk::UChar& _obj) const {
return m_value < _obj.m_value;
};
bool operator<= (const etk::UChar& _obj) const {
return m_value <= _obj.m_value;
};
/*****************************************************
* += operator
*****************************************************/
const etk::UChar& operator+= (const etk::UChar& _obj) {
m_value += _obj.m_value;
return *this;
};
/*****************************************************
* + operator
*****************************************************/
etk::UChar operator+ (const etk::UChar& _obj) const {
etk::UChar tmp = *this;
tmp += _obj;
return tmp;
};
/*****************************************************
* -= operator
*****************************************************/
const etk::UChar& operator-= (const etk::UChar& _obj) {
if (_obj.m_value >= m_value) {
m_value = 0;
} else {
m_value -= _obj.m_value;
}
return *this;
};
/*****************************************************
* - operator
*****************************************************/
etk::UChar operator- (const etk::UChar& _obj) const {
etk::UChar tmp = *this;
tmp -= _obj;
return tmp;
};
/*****************************************************
* () operator
*****************************************************/
//operator uint32_t() const { return m_value; };
/**
* @brief check if the curent element is white or not : '\t' '\n' '\r' ' '
* @return tue if it is white char
*/
bool isWhiteChar(void) const;
bool isSpecialChar(void) const;
/**
* @brief check if the curent element is number or not
* @return tue if it is a number char
*/
bool isInteger(void) const;
int32_t toInt32(void) const;
void lower(void);
UChar toLower(void) const;
void upper(void);
UChar toUpper(void) const;
UChar changeOrder(void) const;
uint32_t get(void) const { return m_value; }; uint32_t get(void) const { return m_value; };
void set(uint32_t _val) { m_value = _val; }; void set(uint32_t _val) { m_value = _val; };
uint32_t getUtf8(void) const; uint32_t getUtf8(void) const;
int8_t getUtf8(char _output[5]) const; int8_t getUtf8(char _output[5]) const;
//etk::Vector<int8_t> GetUtf8(void) const; //std::vector<int8_t> GetUtf8(void) const;
int8_t setUtf8(const char* _input); int8_t setUtf8(const char* _input);
public: public:
/** /**
@ -184,6 +73,30 @@ namespace etk {
*/ */
static bool theoricUTF8First(const char _input); static bool theoricUTF8First(const char _input);
}; };
#endif
/**
* @brief check if the curent element is white or not : '\t' '\n' '\r' ' '
* @return tue if it is white char
*/
bool isWhiteChar(char32_t _val);
bool isSpecialChar(char32_t _val);
/**
* @brief check if the curent element is number or not
* @return tue if it is a number char
*/
bool isInteger(char32_t _val);
int32_t toInt32(char32_t _val);
char32_t toLower(char32_t _val);
char32_t toUpper(char32_t _val);
bool compareNoCase(char32_t _val1, char32_t _val2);
char32_t changeOrder(char32_t _val);
int8_t getUtf8(char32_t _val, char _output[5]);
char32_t setUtf8(const char* _input);
// TODO : Not needed : tolower(int ...)
char32_t toLower(char32_t _val);
char32_t toUpper(char32_t _val);
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,24 @@
#define __ETK_USTRING_H__ #define __ETK_USTRING_H__
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/Vector.h> #include <string>
#include <etk/Char.h> #include <vector>
#include <etk/unicode.h> #include <sstream>
namespace etk { namespace etk {
/*
std::u32string to_string(int _val);
std::u32string to_string(long _val);
std::u32string to_string(long long _val);
std::u32string to_string(unsigned _val);
std::u32string to_string(unsigned long _val);
std::u32string to_string(unsigned long long _val);
std::u32string to_string(float _val);
std::u32string to_string(double _val);
std::u32string to_string(long double _val);
*/
//typedef std::u32string UString;
#if 0
class UString { class UString {
public: public:
enum printMode { enum printMode {
@ -25,18 +38,18 @@ namespace etk {
printModeString, printModeString,
}; };
private : private :
etk::Vector<etk::UChar> m_data; //!< internal data is stored in the Unicode properties ... std::vector<char32_t> m_data; //!< internal data is stored in the Unicode properties ...
public: public:
// Constructeurs // Constructeurs
UString(void); UString(void);
// destructor : // destructor :
~UString(void) { }; ~UString(void) { };
// recopy operator : // recopy operator :
UString(const etk::UString& _obj); UString(const std::string& _obj);
// single element adding // single element adding
UString(const bool _inputData, enum printMode _mode=printModeString, bool _preset=false); UString(const bool _inputData, enum printMode _mode=printModeString, bool _preset=false);
UString(const etk::UChar& _inputData); UString(char32_t _inputData);
UString(const char* _data, enum unicode::charset _inputCharset); UString(const char* _data, enum unicode::charset _inputCharset);
UString(const float _inputData); UString(const float _inputData);
UString(const double _inputData); UString(const double _inputData);
@ -65,17 +78,17 @@ namespace etk {
set(_inputData, _mode, _preset, _leadingZero); set(_inputData, _mode, _preset, _leadingZero);
}; };
// multiple element add // multiple element add
UString(const etk::UChar* _inputData, int32_t _len = -1); UString(const char32_t* _inputData, int32_t _len = -1);
UString(const char* _inputData, int32_t _len = -1); UString(const char* _inputData, int32_t _len = -1);
UString(const etk::Vector<char>& _inputData); UString(const std::vector<char>& _inputData);
UString(const etk::Vector<int8_t>& _inputData); UString(const std::vector<int8_t>& _inputData);
UString(const etk::Vector<etk::UChar>& _inputData); UString(const std::vector<char32_t>& _inputData);
// generic setter // generic setter
void set(const etk::UChar* _inputData, int32_t _len=-1); void set(const char32_t* _inputData, int32_t _len=-1);
void set(const char* _inputData, int32_t _len=-1); void set(const char* _inputData, int32_t _len=-1);
void set(const etk::Vector<char>& _inputData); void set(const std::vector<char>& _inputData);
void set(const etk::Vector<int8_t>& _inputData); void set(const std::vector<int8_t>& _inputData);
void set(const etk::Vector<etk::UChar>& _inputData); void set(const std::vector<char32_t>& _inputData);
private: private:
void setNumber(bool _negative, const uint64_t& _inputData, enum printMode _mode, bool _preset, int32_t _leadingZero); void setNumber(bool _negative, const uint64_t& _inputData, enum printMode _mode, bool _preset, int32_t _leadingZero);
public: public:
@ -85,39 +98,39 @@ namespace etk {
/***************************************************** /*****************************************************
* = assigment * = assigment
*****************************************************/ *****************************************************/
const etk::UString& operator= (const etk::UString& _obj ); const std::string& operator= (const std::string& _obj );
/***************************************************** /*****************************************************
* == operator * == operator
*****************************************************/ *****************************************************/
bool operator== (const etk::UString& _obj) const; bool operator== (const std::string& _obj) const;
bool compareNoCase(const etk::UString& _obj) const; bool compareNoCase(const std::string& _obj) const;
/***************************************************** /*****************************************************
* != operator * != operator
*****************************************************/ *****************************************************/
bool operator!= (const etk::UString& _obj) const; bool operator!= (const std::string& _obj) const;
/***************************************************** /*****************************************************
* > < >= <= operator * > < >= <= operator
*****************************************************/ *****************************************************/
bool operator> (const etk::UString& _obj) const; bool operator> (const std::string& _obj) const;
bool operator>= (const etk::UString& _obj) const; bool operator>= (const std::string& _obj) const;
bool operator< (const etk::UString& _obj) const; bool operator< (const std::string& _obj) const;
bool operator<= (const etk::UString& _obj) const; bool operator<= (const std::string& _obj) const;
/***************************************************** /*****************************************************
* += operator * += operator
*****************************************************/ *****************************************************/
const etk::UString& operator+= (const etk::UString& _obj); const std::string& operator+= (const std::string& _obj);
//const etk::UString& operator+= (const etk::UChar& _obj); //const std::string& operator+= (char32_t _obj);
/***************************************************** /*****************************************************
* + operator * + operator
*****************************************************/ *****************************************************/
etk::UString operator+ (const etk::UString &_obj) const; std::string operator+ (const std::string &_obj) const;
/***************************************************** /*****************************************************
* << operator * << operator
*****************************************************/ *****************************************************/
/* /*
const etk::UString& operator <<= (const char input); const std::string& operator <<= (const char input);
const etk::UString& operator <<= (const int input); const std::string& operator <<= (const int input);
const etk::UString& operator <<= (const unsigned int input); const std::string& operator <<= (const unsigned int input);
*/ */
/***************************************************** /*****************************************************
* >> operator * >> operator
@ -126,14 +139,14 @@ namespace etk {
/***************************************************** /*****************************************************
* Cout << operator * Cout << operator
*****************************************************/ *****************************************************/
friend etk::CCout& operator <<( etk::CCout& _os,const etk::UString& _obj); friend etk::CCout& operator <<( etk::CCout& _os,const std::string& _obj);
/***************************************************** /*****************************************************
* [] operator * [] operator
*****************************************************/ *****************************************************/
const etk::UChar& operator[] (esize_t _pos) const { char32_t operator[] (esize_t _pos) const {
return m_data[_pos]; return m_data[_pos];
} }
etk::UChar& operator[] (esize_t _pos) { char32_t operator[] (esize_t _pos) {
return m_data[_pos]; return m_data[_pos];
} }
@ -141,12 +154,12 @@ namespace etk {
* toolbox * toolbox
*****************************************************/ *****************************************************/
// Start With ... // Start With ...
bool startWith(const etk::UString& _data, bool _caseSensitive=true) const ; bool startWith(const std::string& _data, bool _caseSensitive=true) const ;
// End With ... // End With ...
bool endWith(const etk::UString& _data, bool _caseSensitive=true) const ; bool endWith(const std::string& _data, bool _caseSensitive=true) const ;
// Find element // Find element
int32_t findForward(const etk::UChar _data, int32_t _startPos=0) const; int32_t findForward(const char32_t _data, int32_t _startPos=0) const;
int32_t findBack(const etk::UChar _data, int32_t _startPos=0x7FFFFFFF) const; int32_t findBack(const char32_t _data, int32_t _startPos=0x7FFFFFFF) const;
bool isEmpty(void) const; bool isEmpty(void) const;
int32_t size(void) const; int32_t size(void) const;
@ -155,44 +168,44 @@ namespace etk {
* Generic modification function * Generic modification function
*****************************************************/ *****************************************************/
void add(int32_t _currentID, const char* _inputData); void add(int32_t _currentID, const char* _inputData);
void add(int32_t _currentID, const etk::UChar* _inputData); void add(int32_t _currentID, const char32_t* _inputData);
void add(int32_t _currentID, const etk::UChar _inputData); void add(int32_t _currentID, const char32_t _inputData);
void remove(int32_t _currentID, int32_t _len = 1); void remove(int32_t _currentID, int32_t _len = 1);
void clear(void); void clear(void);
void append(const etk::UChar& _inputData); void append(char32_t _inputData);
/** /**
* @brief Split a string in multiple separate by a specific char * @brief Split a string in multiple separate by a specific char
* @param[in] _val Separate value of the string * @param[in] _val Separate value of the string
* @return The list of all sthe string splited. * @return The list of all sthe string splited.
*/ */
etk::Vector<etk::UString> split(const etk::UChar& _val); std::vector<std::string> split(char32_t _val);
/** /**
* @brief Replace a char with an other * @brief Replace a char with an other
* @param[in] _out element to replace. * @param[in] _out element to replace.
* @param[in] _in Element to set. * @param[in] _in Element to set.
*/ */
void replace(const etk::UChar& _out, const etk::UChar& _in); void replace(char32_t _out, char32_t _in);
etk::Vector<etk::UChar> getVector(void); std::vector<char32_t> getVector(void);
etk::UChar* pointer(void) { return &m_data[0]; }; char32_t* pointer(void) { return &m_data[0]; };
etk::Char c_str(void) const; etk::Char c_str(void) const;
void lower(void); void lower(void);
etk::UString toLower(void) const; std::string toLower(void) const;
void upper(void); void upper(void);
etk::UString toUpper(void) const; std::string toUpper(void) const;
/** /**
* @brief transform tab in \t and '\r' in \r * @brief transform tab in \t and '\r' in \r
* @return the new string * @return the new string
*/ */
//etk::UString WrapHidenChar(void) const; //std::string WrapHidenChar(void) const;
// Sting operation : // Sting operation :
etk::UString extract(int32_t _posStart=0, int32_t _posEnd=0x7FFFFFFF) const; std::string extract(int32_t _posStart=0, int32_t _posEnd=0x7FFFFFFF) const;
etk::UString extractLine(int32_t _pos=0) const; std::string extractLine(int32_t _pos=0) const;
/** /**
* @brief Transform the current string in an int64_t * @brief Transform the current string in an int64_t
* @return the requested int * @return the requested int
@ -249,14 +262,66 @@ namespace etk {
*/ */
bool toBool(void) const; bool toBool(void) const;
}; };
#endif
etk::CCout& operator <<(etk::CCout& _os, const etk::UString& _obj); etk::CCout& operator <<(etk::CCout& _os, const std::u32string& _obj);
etk::CCout& operator <<(etk::CCout& _os, const etk::Vector<etk::UString>& _obj); etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj);
};
std::string to_u8string(const std::u32string& _obj);
std::u32string to_u32string(const std::string& _obj);
std::u32string to_u32string(const char* _obj);
template<class T> std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)) {
std::ostringstream oss;
oss << f << t;
return oss.str();
} }
int32_t strlen(const etk::UChar * _data); template<class T> std::u32string to_u32string(T t, std::ios_base & (*f)(std::ios_base&)) {
std::ostringstream oss;
oss << f << t;
return to_u32string(oss.str());
}
std::u32string to_u32string(int _val);
std::u32string to_u32string(long _val);
std::u32string to_u32string(long long _val);
std::u32string to_u32string(unsigned _val);
std::u32string to_u32string(unsigned long _val);
std::u32string to_u32string(unsigned long long _val);
std::u32string to_u32string(float _val);
std::u32string to_u32string(double _val);
std::u32string to_u32string(long double _val);
double stod(const std::u32string& _str, size_t* _idx = 0);
float stof(const std::u32string& _str, size_t* _idx = 0);
int stoi(const std::u32string& _str, size_t* _idx = 0, int _base = 10);
long stol(const std::u32string& _str, size_t* _idx = 0, int _base = 10);
long double stold(const std::u32string& _str, size_t* _idx = 0);
long long stoll(const std::u32string& _str, size_t* _idx = 0, int _base = 10);
unsigned long stoul(const std::u32string& _str, size_t* _idx = 0, int _base = 10);
unsigned long long stoull(const std::u32string& _str, size_t* _idx = 0, int _base = 10);
bool stobool(const std::u32string& _str);
bool stobool(const std::string& _str);
std::u32string to_lower(const std::u32string& _obj);
std::u32string to_upper(const std::u32string& _obj);
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = false);
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = false);
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val);
bool compare_no_case(const std::string& _obj, const std::string& _val);
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
std::string replace(const std::string& _obj, char _val, char _replace);
int32_t strlen(const char32_t * _data);
std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
#endif #endif

View File

@ -1,729 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_VECTOR_H__
#define __ETK_VECTOR_H__
#include <etk/types.h>
#include <etk/debug.h>
#undef __class__
#define __class__ "etk::Vector"
namespace etk
{
/**
* @brief Vector classes ...
*
* @tparam[in] MY_TYPE class type of the current element.
*
* m_data
* <------------ m_dataSize ------------>
* ----------------------------------------
* | 0 |
* |--------------------------------------|
* | 1 |
* |--------------------------------------|
* | 2 |
* |--------------------------------------|
* m_size | 3 |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* m_allocated | x |
* ----------------------------------------
*
*/
template<class MY_TYPE=int32_t> class Vector
{
public:
class Iterator {
// Private data :
private:
esize_t m_current; //!< curent Id on the vector
Vector<MY_TYPE>* m_vector; //!< Pointer on the curent element of the vectorBin
public:
/**
* @brief Basic itarator constructor with no link with an etkVector
*/
Iterator(void):
m_current(0),
m_vector(NULL) {
// nothing to do ...
}
/**
* @brief Recopy constructor on a specific etkVector.
* @param[in] _obj The Iterator that might be copy
*/
Iterator(const Iterator & _obj):
m_current(_obj.m_current),
m_vector(_obj.m_vector) {
// nothing to do ...
}
/**
* @brief Asignation operator.
* @param[in] _otherIterator The Iterator that might be copy
* @return reference on the curent Iterator
*/
Iterator& operator=(const Iterator & _otherIterator) {
m_current = _otherIterator.m_current;
m_vector = _otherIterator.m_vector;
return *this;
}
/**
* @brief Basic destructor
*/
~Iterator(void) {
m_current = 0;
m_vector = NULL;
}
/**
* @brief basic boolean cast
* @return true if the element is present in the etkVector size
*/
operator bool (void) {
return (m_current < m_vector->size());
}
/**
* @brief Incremental operator
* @return Reference on the current iterator incremented
*/
Iterator& operator++ (void) {
if ( m_vector != NULL
&& m_current < m_vector->size() )
{
m_current++;
}
return *this;
}
/**
* @brief Decremental operator
* @return Reference on the current iterator decremented
*/
Iterator& operator-- (void) {
if ( m_vector != NULL
&& m_current > 0) {
m_current--;
}
return *this;
}
/**
* @brief Incremental operator
* @return Reference on a new iterator and increment the other one
*/
Iterator operator++ (int32_t) {
Iterator it(*this);
++(*this);
return it;
}
/**
* @brief Decremental operator
* @return Reference on a new iterator and decrement the other one
*/
Iterator operator-- (int32_t) {
Iterator it(*this);
--(*this);
return it;
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator-> (void) const {
TK_CHECK_INOUT(m_current < m_vector->size());
return &m_vector->get(m_current);
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator* (void) const {
TK_CHECK_INOUT(m_current < m_vector->size());
return m_vector->get(m_current);
}
private:
Iterator(Vector<MY_TYPE> * _obj, int32_t _pos):
m_current(_pos),
m_vector(_obj) {
// nothing to do ...
}
friend class Vector;
};
private:
MY_TYPE* m_data; //!< pointer on the curetn table of Data
esize_t m_size; //!< nb Element in the buffer
esize_t m_allocated; //!< Current allocated size
public:
/**
* @brief Create an empty vector
* @param[in] _count Minimum request size of the Buffer
*/
Vector(int32_t _count = 0):
m_data(NULL),
m_size(0),
m_allocated(0) {
changeAllocation(_count);
}
/**
* @brief Re-copy constructor (copy all needed data)
* @param[in] _obj Vector that might be copy
*/
Vector(const etk::Vector<MY_TYPE>& _obj) {
m_allocated = _obj.m_allocated;
m_size = _obj.m_size;
m_data = NULL;
//TK_DEBUG("USE Specific vector allocator ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
// allocate all same data
m_data = new MY_TYPE[m_allocated];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation ... might nor work corectly anymore");
return;
}
// Copy all data ...
for(esize_t iii=0; iii<m_allocated; iii++) {
// copy operator ...
m_data[iii] = _obj.m_data[iii];
}
}
/**
* @brief Destructor of the current Class
*/
~Vector(void) {
if (NULL!=m_data) {
delete [] m_data;
m_data = NULL;
}
m_allocated = 0;
m_size = 0;
}
/**
* @brief Swap the data of 2 Vectors
* @param[in] _obj second vector to swap data.
*/
void swap(etk::Vector<MY_TYPE>& _obj) {
// avoid Swap of itself
if(this != &_obj) {
MY_TYPE* tmpData = m_data;
esize_t tmpAllocated = m_allocated;
esize_t tmpSize = m_size;
m_data = _obj.m_data;
m_allocated = _obj.m_allocated;
m_size = _obj.m_size;
_obj.m_data = tmpData;
_obj.m_allocated = tmpAllocated;
_obj.m_size = tmpSize;
}
}
/**
* @brief Re-copy operator
* @param[in] _obj Vector that might be copy
* @return reference on the curent re-copy vector
*/
Vector& operator=(const etk::Vector<MY_TYPE> & _obj) {
//TK_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
if( this != &_obj ) {
if (NULL!=m_data) {
delete[] m_data;
m_data = NULL;
}
// Set the new value
m_allocated = _obj.m_allocated;
m_size = _obj.m_size;
// allocate all same data
m_data = new MY_TYPE[m_allocated];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation ... might nor work corectly anymore");
return *this;
}
for(esize_t iii=0; iii<m_allocated; iii++) {
// copy operator ...
m_data[iii] = _obj.m_data[iii];
}
}
// Return the curent pointer
return *this;
}
/**
* @brief Add at the Last position of the Vector
* @param[in] _obj Element to add at the end of vector
*/
Vector& operator+= (const etk::Vector<MY_TYPE> & _obj) {
esize_t nbElememt = _obj.size();
esize_t idx = m_size;
resize(m_size+nbElememt);
if (m_size<=idx) {
TK_CRITICAL("allocation error");
return *this;
}
for(esize_t iii=0; iii<nbElememt; iii++) {
// copy operator ...
m_data[idx+iii] = _obj.m_data[iii];
}
// Return the curent pointer
return *this;
}
/**
* @brief Get the number of element in the vector
* @return The number requested
*/
esize_t size(void) const {
return m_size;
}
/**
* @brief Get the number of element in the vector
* @return The number requested
*/
void reSize(esize_t _newSize, const MY_TYPE& _basicElement) {
esize_t idx = m_size;
resize(_newSize);
if (m_size != _newSize) {
TK_CRITICAL("error to resize vector");
return;
}
if (_newSize > idx) {
// initialize data ...
for(esize_t iii=idx; iii<_newSize; iii++) {
m_data[iii] = _basicElement;
}
}
}
/**
* @brief Get the Allocated size in the vector
* @return The size of allocation
*/
esize_t allocatedSize(void) const {
return m_allocated;
}
/**
* @brief Get a current element in the vector
* @param[in] _pos Desired position read
* @return Reference on the Element
*/
MY_TYPE& get(esize_t _pos) {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_size){
TK_CRITICAL("[CRITICAL] Access to an unexistant data in vector : " << _pos << "/ " << m_size);
}
#endif
return m_data[_pos];
}
/**
* @brief Get an copy Element an a special position
* @param[in] _pos Position in the vector that might be get [0..Size()]
* @return An reference on the copy of selected element
*/
MY_TYPE& operator[] (esize_t _pos) {
return get(_pos);
}
/**
* @brief Get an Element an a special position
* @param[in] _pos Position in the vector that might be get [0..Size()]
* @return An reference on the selected element
*/
const MY_TYPE& operator[] (esize_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_size){
TK_CRITICAL("[CRITICAL] Access to an unexistant data in vector : " << _pos << "/ " << m_size);
}
#endif
return m_data[_pos];
}
/**
* @brief Add at the First position of the Vector
* @param[in] _item Element to add at the end of vector
*/
void pushFront(const MY_TYPE& _item) {
insert(0, &_item, 1);
}
/**
* @brief Add at the Last position of the Vector
* @param[in] _item Pointer on a list of Element to add at the start of vector
* @param[in] _nbElement Number of element to add.
*/
void pushFront(const MY_TYPE * _item, esize_t _nbElement) {
insert(0, _item, _nbElement);
}
/**
* @brief Add at the Last position of the Vector
* @param[in] _item Element to add at the end of vector
*/
void pushBack(const MY_TYPE& _item) {
esize_t idx = m_size;
resize(m_size+1);
if (idx < m_size) {
m_data[idx] = _item;
} else {
TK_ERROR("Resize does not work corectly ... not added item");
}
}
/**
* @brief Add at the Last position of the Vector
* @param[in] _item Pointer on a list of Element to add at the end of vector
* @param[in] _nbElement Number of element to add.
*/
void pushBack(const MY_TYPE * _item, esize_t _nbElement) {
if (NULL == _item) {
return;
}
esize_t idx = m_size;
resize(m_size+_nbElement);
if (idx > m_size) {
TK_ERROR("Resize does not work corectly ... not added item");
return;
}
for (esize_t iii=0; iii<_nbElement; iii++) {
m_data[idx+iii] = _item[iii];
}
}
/**
* @brief Remove the last element of the vector
*/
void popBack(void) {
if(m_size>0) {
resize(m_size-1);
}
}
/**
* @brief Remove all alement in the current vector
*/
void clear(void) {
if(m_size>0) {
resize(0);
}
}
/**
* @brief Insert N element in the Vector.
* @param[in] _pos Position to add the elements.
* @param[in] _item Pointer on a table of the elements to add.
* @param[in] _nbElement Number of element to add in the Vector
*/
void insert(esize_t _pos, const MY_TYPE * _item, esize_t _nbElement) {
if (_pos>m_size) {
TK_WARNING(" can not insert Element at this position : " << _pos << " > " << m_size << " add it at the end ... ");
pushBack(_item, _nbElement);
return;
}
esize_t idx = m_size;
// Request resize of the current buffer
resize(m_size+_nbElement);
if (idx>=m_size) {
TK_ERROR("Resize does not work corectly ... not added item");
return;
}
// move curent data (after the position)
esize_t sizeToMove = (idx - _pos);
if ( 0 < sizeToMove) {
for (esize_t iii=1; iii<=sizeToMove; iii++) {
m_data[m_size-iii] = m_data[idx-iii];
}
}
// affectation of all input element
for (esize_t iii=0; iii<_nbElement; iii++) {
m_data[_pos+iii] = _item[iii];
}
}
/**
* @brief Insert one element in the Vector at a specific position
* @param[in] _pos Position to add the elements.
* @param[in] _item Element to add.
*/
void insert(esize_t _pos, const MY_TYPE& _item) {
insert(_pos, &_item, 1);
}
/**
* @brief Remove N element
* @param[in] _pos Position to remove the data
* @param[in] _nbElement number of element to remove
*/
void eraseLen(esize_t _pos, esize_t _nbElement) {
if (_pos>m_size) {
TK_ERROR(" can not Erase Len Element at this position : " << _pos << " > " << m_size);
return;
}
if (_pos+_nbElement>m_size) {
_nbElement = m_size - _pos;
}
esize_t idx = m_size;
// move curent data
esize_t sizeToMove = (idx - (_pos+_nbElement));
if ( 0 < sizeToMove) {
for (esize_t iii=0; iii<sizeToMove; iii++) {
m_data[_pos+iii] = m_data[_pos+_nbElement+iii];
}
}
// Request resize of the current buffer
resize(m_size-_nbElement);
}
/**
* @brief Remove one element
* @param[in] _pos Position to remove the data
*/
inline void erase(esize_t _pos) {
eraseLen(_pos, 1);
}
/**
* @brief Remove one element
* @param[in] _pos Position to remove the data
*/
inline void remove(esize_t _pos) {
eraseLen(_pos, 1);
}
/**
* @brief Remove N elements
* @param[in] _pos Position to remove the data
* @param[in] _posEnd Last position number
*/
void erase(esize_t _pos, esize_t _posEnd) {
if (_pos>m_size) {
TK_ERROR(" can not Erase Element at this position : " << _pos << " > " << m_size);
return;
}
if (_posEnd>m_size) {
_posEnd = m_size;
}
esize_t nbElement = m_size - _pos;
esize_t tmpSize = m_size;
// move curent data
esize_t sizeToMove = (tmpSize - (_pos+nbElement));
if ( 0 < sizeToMove) {
for (esize_t iii=0; iii<sizeToMove; iii++) {
m_data[_pos+iii] = m_data[_pos+nbElement+iii];
}
}
// Request resize of the current buffer
resize(m_size-nbElement);
}
/**
* @brief extract data between two point :
* @param[in] _posStart start position to extract data
* @param[in] _posEnd End position to extract data
* @return the extracted vector
*/
Vector<MY_TYPE> extract(esize_t _posStart = 0, esize_t _posEnd=0x7FFFFFFF) const {
Vector<MY_TYPE> out;
if (_posStart >= size() ) {
return out;
}
if (_posEnd >= size() ) {
_posEnd = size();
}
out.pushBack(&m_data[_posStart], _posEnd-_posStart);
return out;
}
/**
* @brief Get the pointer on the sata
* @return the type pointer on data
*/
MY_TYPE* dataPointer(void) {
return &m_data[0];
}
/**
* @brief Get an iterator an an specific position
* @param[in] _pos Requested position of the iterator in the vector
* @return The Iterator
*/
Iterator position(esize_t _pos) {
return iterator(this, _pos);
}
/**
* @brief Get an Iterator on the start position of the Vector
* @return The Iterator
*/
Iterator begin(void) {
return position(0);
}
/**
* @brief Get an Iterator on the end position of the Vector
* @return The Iterator
*/
Iterator end(void) {
return position( size()-1 );
}
private:
/**
* @brief Change the current size of the vector
* @param[in] _newSize New requested size of element in the vector
*/
void resize(esize_t _newSize) {
// Reallocate memory
if (_newSize > m_allocated) {
changeAllocation(_newSize);
}
m_size = _newSize;
}
/**
* @brief Change the current allocation to the corect one (depend on the current size)
* @param[in] _newSize Minimum number of element needed
*/
void changeAllocation(esize_t _newSize) {
// set the minimal size to 1
if(_newSize == 0) {
_newSize = 1;
}
esize_t requestSize = m_allocated;
// set the size with the corect chose type :
if (_newSize == requestSize) {
return;
} else if (_newSize < requestSize) {
// we did not remove data ???
} else {
while(_newSize > requestSize) {
if (0 == requestSize) {
requestSize = 1;
} else {
requestSize = requestSize * 2;
}
}
}
// No reallocation needed :
if (requestSize <= m_allocated) {
return;
}
//TK_INFO("Change vector allocation : " << m_allocated << "==>" << requestSize);
// check if something is allocated :
if (NULL == m_data) {
// no data allocated ==> request an allocation (might be the first)
m_data = new MY_TYPE[requestSize];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
m_allocated = 0;
return;
}
// no data to copy
} else {
// allocate a new pool of data:
MY_TYPE* m_dataTmp = new MY_TYPE[requestSize];
if (NULL==m_dataTmp) {
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
m_allocated = 0;
return;
}
// copy data in the new pool
esize_t nbElements = etk_min(requestSize, m_allocated);
for(esize_t iii=0; iii<nbElements; iii++) {
m_dataTmp[iii] = m_data[iii];
}
// switch pointer:
MY_TYPE* m_dataTmp2 = m_data;
m_data = m_dataTmp;
// remove old pool
if (m_dataTmp2!= NULL) {
delete [] m_dataTmp2;
}
}
// set the new allocation size
m_allocated = requestSize;
}
public :
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Vector<MY_TYPE>& _obj) const {
// check if it was the same pointer
if( this == &_obj ) {
return true;
}
// fiist step : check the size ...
if (m_size!=_obj.m_size) {
return false;
}
if( NULL==m_data
|| NULL==_obj.m_data) {
return false;
}
for (esize_t iii=0; iii<m_size; iii++) {
if (m_data[iii]!=_obj.m_data[iii]) {
return false;
}
}
return true;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Vector<MY_TYPE>& _obj) const {
// check if it was the same pointer
if( this == &_obj ) {
return false;
}
// fiist step : check the size ...
if (m_size!=_obj.m_size) {
return true;
}
if( NULL==m_data
|| NULL==_obj.m_data) {
return false;
}
for (esize_t iii=0; iii<m_size; iii++) {
if (m_data[iii]!=_obj.m_data[iii]) {
return true;
}
}
return false;
}
};
/**
* @brief List classes ...
*
* @tparam[in] T The type of objects to store.
*
* m_data
* ---------- |-----------------------|
* | 0 |-------->| Class Data |
* |--------| |-----------------------|
* | 1 |----|
* |--------| |
* | 2 |====|==============| |-----------------------|
* |--------| | --->| Class Data |
* m_count | 3 |-| | |-----------------------|
* |--------| | |
* | x | | | |-----------------------|
* |--------| | -------->| Class Data |
* | x | | |-----------------------|
* |--------| |
* | x | |
* |--------| | |-----------------------|
* | x | --------------------->| Class Data |
* |--------| |-----------------------|
* | x |
* |--------|
* | x |
* |--------|
* m_size | x |
* ----------
*
*/
/*
template<class MY_CLASS> class List
{
};
*/
}
#undef __class__
#define __class__ NULL
#endif

View File

@ -10,8 +10,7 @@
#include <etk/archive/Zip.h> #include <etk/archive/Zip.h>
#include <etk/debug.h> #include <etk/debug.h>
const etk::Archive::Content& etk::Archive::getContent(const etk::UString& _key) const const etk::Archive::Content& etk::Archive::getContent(const std::u32string& _key) const {
{
static const etk::Archive::Content g_error; static const etk::Archive::Content g_error;
if (m_content.exist(_key)==false) { if (m_content.exist(_key)==false) {
TK_ERROR("File does not exist : " << _key); TK_ERROR("File does not exist : " << _key);
@ -29,13 +28,12 @@ void etk::Archive::display(void)
} }
} }
etk::Archive* etk::Archive::load(const etk::UString& _fileName) etk::Archive* etk::Archive::load(const std::u32string& _fileName) {
{
etk::Archive* output=NULL; etk::Archive* output=NULL;
etk::UString tmpName = _fileName.toLower(); std::u32string tmpName = to_lower(_fileName);
// select the corect Loader : // select the corect Loader :
if( true == tmpName.endWith(".zip") if( true == end_with(tmpName, U".zip")
|| true == tmpName.endWith(".apk") ) { || true == end_with(tmpName, U".apk") ) {
output = new etk::archive::Zip(_fileName); output = new etk::archive::Zip(_fileName);
if (NULL==output) { if (NULL==output) {
TK_ERROR("An error occured when load archive : " << _fileName); TK_ERROR("An error occured when load archive : " << _fileName);
@ -47,8 +45,7 @@ etk::Archive* etk::Archive::load(const etk::UString& _fileName)
} }
void etk::Archive::open(const etk::UString& _key) void etk::Archive::open(const std::u32string& _key) {
{
if (m_content.exist(_key)==false) { if (m_content.exist(_key)==false) {
TK_ERROR("Try open an unexistant file : '" << _key << "'"); TK_ERROR("Try open an unexistant file : '" << _key << "'");
return; return;
@ -60,8 +57,7 @@ void etk::Archive::open(const etk::UString& _key)
m_content[_key].increaseRef(); m_content[_key].increaseRef();
} }
void etk::Archive::close(const etk::UString& _key) void etk::Archive::close(const std::u32string& _key) {
{
if (m_content.exist(_key)==false) { if (m_content.exist(_key)==false) {
TK_ERROR("Try close an unexistant file : '" << _key << "'"); TK_ERROR("Try close an unexistant file : '" << _key << "'");
return; return;

View File

@ -10,7 +10,7 @@
#define __ETK_ARCHIVE_H__ #define __ETK_ARCHIVE_H__
#include <etk/UString.h> #include <etk/UString.h>
#include <etk/Vector.h> #include <vector>
#include <etk/Hash.h> #include <etk/Hash.h>
namespace etk namespace etk
@ -31,24 +31,24 @@ namespace etk
public: public:
esize_t getTheoricSize(void) const { return m_theoricSize; }; esize_t getTheoricSize(void) const { return m_theoricSize; };
private: private:
etk::Vector<char> m_data; std::vector<char> m_data;
public: public:
Content(esize_t _basicSize=0) : m_link(-1), m_theoricSize(_basicSize) { }; Content(esize_t _basicSize=0) : m_link(-1), m_theoricSize(_basicSize) { };
esize_t size(void) const { return m_data.size(); }; esize_t size(void) const { return m_data.size(); };
void* data(void) const { return (void*)&m_data[0]; }; void* data(void) const { return (void*)&m_data[0]; };
etk::Vector<char>& getDataVector(void) { return m_data; }; std::vector<char>& getDataVector(void) { return m_data; };
}; };
public: public:
Archive(const etk::UString& _fileName) : m_fileName(_fileName) { }; Archive(const std::u32string& _fileName) : m_fileName(_fileName) { };
virtual ~Archive(void) { }; virtual ~Archive(void) { };
protected: protected:
etk::UString m_fileName; //!< File name when it came from an file std::u32string m_fileName; //!< File name when it came from an file
public: public:
/** /**
* @brief Get the current file name. * @brief Get the current file name.
* @return the requested file name. * @return the requested file name.
*/ */
const etk::UString& getFileName(void) { return m_fileName; }; const std::u32string& getFileName(void) { return m_fileName; };
protected: protected:
etk::Hash<Content> m_content; etk::Hash<Content> m_content;
public: public:
@ -62,7 +62,7 @@ namespace etk
* @param[in] _id id of the element (must be < Size()) * @param[in] _id id of the element (must be < Size())
* @return FileName of the requested id * @return FileName of the requested id
*/ */
const etk::UString& getName(esize_t _id) const { return m_content.getKey(_id); }; const std::u32string& getName(esize_t _id) const { return m_content.getKey(_id); };
/** /**
* @brief Get the File name of the ID * @brief Get the File name of the ID
* @param[in] _id id of the element (must be < Size()) * @param[in] _id id of the element (must be < Size())
@ -74,23 +74,23 @@ namespace etk
* @param[in] _key name of the file * @param[in] _key name of the file
* @return FileName of the requested id * @return FileName of the requested id
*/ */
const Content& getContent(const etk::UString& _key) const; const Content& getContent(const std::u32string& _key) const;
/** /**
* @brief Check if a file exist * @brief Check if a file exist
* @param[in] _key Name of the file * @param[in] _key Name of the file
* @return true if the file is present * @return true if the file is present
*/ */
bool exist(const etk::UString& _key) const { return m_content.exist(_key); }; bool exist(const std::u32string& _key) const { return m_content.exist(_key); };
/** /**
* @brief Load the specific file in the memory * @brief Load the specific file in the memory
* @param[in] _key Name of the file * @param[in] _key Name of the file
*/ */
void open(const etk::UString& _key); void open(const std::u32string& _key);
/** /**
* @brief Un-Load the specific file from the memory * @brief Un-Load the specific file from the memory
* @param[in] _key Name of the file * @param[in] _key Name of the file
*/ */
void close(const etk::UString& _key); void close(const std::u32string& _key);
/** /**
* @brief Display all Element in the archive * @brief Display all Element in the archive
*/ */
@ -107,14 +107,14 @@ namespace etk
* @param[in] _fileName File name of the specific archive. * @param[in] _fileName File name of the specific archive.
* @return A pointer an the specified archive, the user might delete it. * @return A pointer an the specified archive, the user might delete it.
*/ */
static Archive* load(const etk::UString& _fileName); static Archive* load(const std::u32string& _fileName);
/** /**
* @brief Create an Achive with a specific name. * @brief Create an Achive with a specific name.
* @param[in] _fileName File name of the specific archive. * @param[in] _fileName File name of the specific archive.
* @return A pointer an the specified archive. it is empty due to the fact of create a new archive file. * @return A pointer an the specified archive. it is empty due to the fact of create a new archive file.
*/ */
//Archive* create(const etk::UString& _fileName); //Archive* create(const std::u32string& _fileName);
}; };
}; };
#endif #endif

View File

@ -8,13 +8,14 @@
#include <etk/archive/Zip.h> #include <etk/archive/Zip.h>
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/UString.h>
etk::archive::Zip::Zip(const etk::UString& _fileName) : etk::archive::Zip::Zip(const std::u32string& _fileName) :
etk::Archive(_fileName), etk::Archive(_fileName),
m_ctx(NULL) m_ctx(NULL)
{ {
/* Open the zip file */ /* Open the zip file */
m_ctx = unzOpen(m_fileName.c_str()); m_ctx = unzOpen(to_u8string(m_fileName).c_str());
if(!m_ctx) { if(!m_ctx) {
TK_ERROR("Unable to open the zip file '" << m_fileName << "'"); TK_ERROR("Unable to open the zip file '" << m_fileName << "'");
return; return;
@ -37,7 +38,7 @@ etk::archive::Zip::Zip(const etk::UString& _fileName) :
if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) { if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) {
// find directory ... // find directory ...
} else { } else {
m_content.add(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size)); m_content.add(to_u32string(tmpFileName), etk::Archive::Content(tmpFileInfo.uncompressed_size));
} }
/* Go the the next entry listed in the zip file. */ /* Go the the next entry listed in the zip file. */
if((iii+1) < m_info.number_entry) { if((iii+1) < m_info.number_entry) {
@ -59,7 +60,7 @@ etk::archive::Zip::~Zip(void)
void etk::archive::Zip::loadFile(int32_t _id) void etk::archive::Zip::loadFile(int32_t _id)
{ {
etk::UString fileNameRequested = m_content.getKey(_id); std::u32string fileNameRequested = m_content.getKey(_id);
TK_VERBOSE("Real load file : " << _id << " = '" << fileNameRequested << "'"); TK_VERBOSE("Real load file : " << _id << " = '" << fileNameRequested << "'");
unzGoToFirstFile(m_ctx); unzGoToFirstFile(m_ctx);
@ -73,7 +74,7 @@ void etk::archive::Zip::loadFile(int32_t _id)
TK_ERROR("Could not read file info from the zip file '" << m_fileName << "'"); TK_ERROR("Could not read file info from the zip file '" << m_fileName << "'");
return; return;
} }
if (fileNameRequested == tmpFileName ) { if (fileNameRequested == to_u32string(tmpFileName) ) {
// Entry is a file, so extract it. // Entry is a file, so extract it.
if(unzOpenCurrentFile(m_ctx) != UNZ_OK) { if(unzOpenCurrentFile(m_ctx) != UNZ_OK) {
TK_ERROR("Could not open file '" << fileNameRequested << "' into the zip file '" << m_fileName << "'"); TK_ERROR("Could not open file '" << fileNameRequested << "' into the zip file '" << m_fileName << "'");
@ -81,7 +82,7 @@ void etk::archive::Zip::loadFile(int32_t _id)
} }
int error = UNZ_OK; int error = UNZ_OK;
// request the resize of the data : // request the resize of the data :
m_content.getValue(_id).getDataVector().reSize(m_content.getValue(_id).getTheoricSize(), 0); m_content.getValue(_id).getDataVector().resize(m_content.getValue(_id).getTheoricSize(), 0);
void* data = m_content.getValue(_id).data(); void* data = m_content.getValue(_id).data();
if(NULL == data) { if(NULL == data) {
TK_ERROR("Allocation error..."); TK_ERROR("Allocation error...");

View File

@ -14,17 +14,14 @@ extern "C" {
#include <minizip/unzip.h> #include <minizip/unzip.h>
} }
namespace etk namespace etk {
{ namespace archive {
namespace archive class Zip : public etk::Archive {
{
class Zip : public etk::Archive
{
private: private:
unzFile m_ctx; //!< mini zip context unzFile m_ctx; //!< mini zip context
unz_global_info m_info; //!< global information of the Zip unz_global_info m_info; //!< global information of the Zip
public: public:
Zip(const etk::UString& _fileName); Zip(const std::u32string& _fileName);
virtual ~Zip(void); virtual ~Zip(void);
protected: // herited functions : protected: // herited functions :
virtual void loadFile(int32_t _id); virtual void loadFile(int32_t _id);

View File

@ -11,7 +11,7 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <etk/Vector.h> #include <vector>
namespace etk namespace etk
{ {
@ -19,7 +19,7 @@ namespace etk
{ {
private: private:
etk::Vector2D<int32_t> m_size; etk::Vector2D<int32_t> m_size;
etk::Vector<T> m_data; std::vector<T> m_data;
public: public:
/***************************************************** /*****************************************************
* Constructor * Constructor

View File

@ -10,7 +10,7 @@
#define __ETK_TYPES_PLANE_H__ #define __ETK_TYPES_PLANE_H__
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/Vector.h> #include <vector>
namespace etk { namespace etk {
template <typename T> class Plane { template <typename T> class Plane {

View File

@ -49,153 +49,145 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<bool>& _obj)
} }
namespace etk namespace etk {
{ template<> Vector2D<bool>::operator std::u32string(void) const {
template<> Vector2D<bool>::operator etk::UString(void) const std::u32string str;
{ str = U"(";
etk::UString str;
str = "(";
str += x(); str += x();
str += ","; str += U",";
str += y(); str += y();
str += ")"; str += U")";
return str; return str;
} }
template<> Vector2D<bool>::Vector2D(const etk::UString& _str) template<> Vector2D<bool>::Vector2D(const std::u32string& _str) {
{
m_floats[0] = false; m_floats[0] = false;
m_floats[1] = false; m_floats[1] = false;
// copy to permit to modify it : // copy to permit to modify it :
etk::UString tmpStr = _str; std::u32string tmpStr = _str;
if (_str.startWith("(")) { if (_str[0] == '(') {
tmpStr.remove(0,1); tmpStr.erase(tmpStr.begin());
} }
if (tmpStr.endWith(")")) { if (*tmpStr.end() == ')') {
tmpStr.remove(tmpStr.size()-1,1); tmpStr.erase(tmpStr.end());
} }
int32_t posComa = tmpStr.findForward(','); size_t posComa = tmpStr.find(',');
if (posComa <= 0) { if (posComa == 0) {
// no coma ... // no coma ...
// in every case, we parse the first element : // in every case, we parse the first element :
m_floats[0] = tmpStr.toBool(); m_floats[0] = stobool(tmpStr);
m_floats[1] = m_floats[0]; m_floats[1] = m_floats[0];
} else { } else {
m_floats[0] = tmpStr.extract(0,posComa).toBool(); m_floats[0] = stobool(std::u32string(tmpStr, 0, posComa));
tmpStr.remove(0,posComa+1); tmpStr.erase(0, posComa+1);
m_floats[1] = tmpStr.toBool(); m_floats[1] = stobool(tmpStr);
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
template<> Vector2D<int32_t>::operator etk::UString(void) const template<> Vector2D<int32_t>::operator std::u32string(void) const {
{ std::u32string str;
etk::UString str; str = U"(";
str = "(";
str += x(); str += x();
str += ","; str += U",";
str += y(); str += y();
str += ")"; str += U")";
return str; return str;
} }
template<> Vector2D<int32_t>::Vector2D(const etk::UString& _str) template<> Vector2D<int32_t>::Vector2D(const std::u32string& _str) {
{
m_floats[0] = 0; m_floats[0] = 0;
m_floats[1] = 0; m_floats[1] = 0;
// copy to permit to modify it : // copy to permit to modify it :
etk::UString tmpStr = _str; std::u32string tmpStr = _str;
if (_str.startWith("(")) { if (_str[0] == '(') {
tmpStr.remove(0,1); tmpStr.erase(tmpStr.begin());
} }
if (tmpStr.endWith(")")) { if (*tmpStr.end() == ')') {
tmpStr.remove(tmpStr.size()-1,1); tmpStr.erase(tmpStr.end());
} }
int32_t posComa = tmpStr.findForward(','); size_t posComa = tmpStr.find(',');
if (posComa <= 0) { if (posComa == 0) {
// no coma ... // no coma ...
// in every case, we parse the first element : // in every case, we parse the first element :
m_floats[0] = tmpStr.toInt32(); m_floats[0] = stoi(tmpStr);
m_floats[1] = m_floats[0]; m_floats[1] = m_floats[0];
} else { } else {
m_floats[0] = tmpStr.extract(0,posComa).toInt32(); m_floats[0] = stoi(std::u32string(tmpStr, 0, posComa));
tmpStr.remove(0,posComa+1); tmpStr.erase(0,posComa+1);
m_floats[1] = tmpStr.toInt32(); m_floats[1] = stoi(tmpStr);
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
template<> Vector2D<uint32_t>::operator etk::UString(void) const template<> Vector2D<uint32_t>::operator std::u32string(void) const {
{ std::u32string str;
etk::UString str; str = U"(";
str = "(";
str += x(); str += x();
str += ","; str += U",";
str += y(); str += y();
str += ")"; str += U")";
return str; return str;
} }
template<> Vector2D<uint32_t>::Vector2D(const etk::UString& _str) template<> Vector2D<uint32_t>::Vector2D(const std::u32string& _str)
{ {
m_floats[0] = 0; m_floats[0] = 0;
m_floats[1] = 0; m_floats[1] = 0;
// copy to permit to modify it : // copy to permit to modify it :
etk::UString tmpStr = _str; std::u32string tmpStr = _str;
if (_str.startWith("(")) { if (_str[0] == '(') {
tmpStr.remove(0,1); tmpStr.erase(tmpStr.begin());
} }
if (tmpStr.endWith(")")) { if (*tmpStr.end() == ')') {
tmpStr.remove(tmpStr.size()-1,1); tmpStr.erase(tmpStr.end());
} }
int32_t posComa = tmpStr.findForward(','); size_t posComa = tmpStr.find(',');
if (posComa <= 0) { if (posComa == 0) {
// no coma ... // no coma ...
// in every case, we parse the first element : // in every case, we parse the first element :
m_floats[0] = tmpStr.toUInt32(); m_floats[0] = stoi(tmpStr);
m_floats[1] = m_floats[0]; m_floats[1] = m_floats[0];
} else { } else {
m_floats[0] = tmpStr.extract(0,posComa).toUInt32(); m_floats[0] = stoi(std::u32string(tmpStr, 0, posComa));
tmpStr.remove(0,posComa+1); tmpStr.erase(0,posComa+1);
m_floats[1] = tmpStr.toUInt32(); m_floats[1] = stoi(tmpStr);
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
template<> Vector2D<float>::operator etk::UString(void) const template<> Vector2D<float>::operator std::u32string(void) const {
{ std::u32string str;
etk::UString str; str = U"(";
str = "(";
str += x(); str += x();
str += ","; str += U",";
str += y(); str += y();
str += ")"; str += U")";
return str; return str;
} }
template<> Vector2D<float>::Vector2D(const etk::UString& _str) template<> Vector2D<float>::Vector2D(const std::u32string& _str) {
{
m_floats[0] = 0; m_floats[0] = 0;
m_floats[1] = 0; m_floats[1] = 0;
// copy to permit to modify it : // copy to permit to modify it :
etk::UString tmpStr = _str; std::u32string tmpStr = _str;
if (_str.startWith("(")) { if (_str[0] == '(') {
tmpStr.remove(0,1); tmpStr.erase(tmpStr.begin());
} }
if (tmpStr.endWith(")")) { if (*tmpStr.end() == ')') {
tmpStr.remove(tmpStr.size()-1,1); tmpStr.erase(tmpStr.end());
} }
int32_t posComa = tmpStr.findForward(','); size_t posComa = tmpStr.find(',');
if (posComa <= 0) { if (posComa == 0) {
// no coma ... // no coma ...
// in every case, we parse the first element : // in every case, we parse the first element :
m_floats[0] = tmpStr.toFloat(); m_floats[0] = stof(tmpStr);
m_floats[1] = m_floats[0]; m_floats[1] = m_floats[0];
} else { } else {
m_floats[0] = tmpStr.extract(0,posComa).toFloat(); m_floats[0] = stof(std::u32string(tmpStr, 0, posComa));
tmpStr.remove(0,posComa+1); tmpStr.erase(0,posComa+1);
m_floats[1] = tmpStr.toFloat(); m_floats[1] = stof(tmpStr);
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }

View File

@ -42,7 +42,7 @@ namespace etk
Vector2D(const Vector2D<double>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); }; Vector2D(const Vector2D<double>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); };
Vector2D(const Vector2D<float>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); }; Vector2D(const Vector2D<float>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); };
Vector2D(const Vector2D<int32_t>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); }; Vector2D(const Vector2D<int32_t>& obj) { m_floats[0] = (T)obj.x(); m_floats[1] = (T)obj.y(); };
Vector2D(const etk::UString& str); Vector2D(const std::u32string& str);
~Vector2D(void) { }; ~Vector2D(void) { };
/***************************************************** /*****************************************************
* = assigment * = assigment
@ -364,8 +364,8 @@ namespace etk
return m_floats[0] == 0 && m_floats[1] == 0; return m_floats[0] == 0 && m_floats[1] == 0;
} }
//!< string cast : //!< string cast :
operator etk::UString(void) const; operator std::u32string(void) const;
//etk::UString UString(void) const { return *this; }; //std::u32string UString(void) const { return *this; };
}; };
/** /**
* @brief Debug operator To display the curent element in a Human redeable information * @brief Debug operator To display the curent element in a Human redeable information

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
namespace etk namespace etk
{ {
void setArgZero(const etk::UString& _val); void setArgZero(const std::u32string& _val);
/** /**
* List of Type that a node can have (this wrap some type that not exist on Windows) * List of Type that a node can have (this wrap some type that not exist on Windows)
*/ */
@ -123,8 +123,8 @@ namespace etk
class FSNode class FSNode
{ {
private: private:
etk::UString m_userFileName; //!< the name requested by the User std::u32string m_userFileName; //!< the name requested by the User
etk::UString m_systemFileName; //!< the compleate filename for the system std::u32string m_systemFileName; //!< the compleate filename for the system
enum FSNType m_type; //!< the Type of data requested by the User enum FSNType m_type; //!< the Type of data requested by the User
enum typeNode m_typeNode; //!< type of the current file/Folder/Link enum typeNode m_typeNode; //!< type of the current file/Folder/Link
etk::FSNodeRight m_rights; //!< IO right of the current file etk::FSNodeRight m_rights; //!< IO right of the current file
@ -140,7 +140,7 @@ namespace etk
* @brief Constructor * @brief Constructor
* @param[in] _path Path of the curent file /folder ... * @param[in] _path Path of the curent file /folder ...
*/ */
FSNode(const etk::UString& _path="~"); FSNode(const std::u32string& _path = U"~");
/** /**
* @brief Destructor * @brief Destructor
* @note you will have some warning if you did not close your files * @note you will have some warning if you did not close your files
@ -159,7 +159,7 @@ namespace etk
* @brief Common set name of the Node (if the user decide to change the node selection * @brief Common set name of the Node (if the user decide to change the node selection
* @param[in] _newName Name of the Node * @param[in] _newName Name of the Node
*/ */
void privateSetName(const etk::UString& _newName); void privateSetName(const std::u32string& _newName);
private: private:
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
/** /**
@ -177,17 +177,23 @@ namespace etk
* @return true : The node existed. * @return true : The node existed.
* @return false : The node does not exist. * @return false : The node does not exist.
*/ */
bool exist(void) const { return (m_typeNode!=etk::FSN_UNKNOW); }; bool exist(void) const {
return (m_typeNode!=etk::FSN_UNKNOW);
};
/** /**
* @brief Get the node type * @brief Get the node type
* @return the requested type, FSN_UNKNOW if it does not existed * @return the requested type, FSN_UNKNOW if it does not existed
*/ */
enum typeNode getNodeType(void) const { return m_typeNode; }; enum typeNode getNodeType(void) const {
return m_typeNode;
};
/** /**
* @brief Get the node Right * @brief Get the node Right
* @return the requested right * @return the requested right
*/ */
etk::FSNodeRight getRight(void) const { return m_rights; }; etk::FSNodeRight getRight(void) const {
return m_rights;
};
/** /**
* @brief Set the specific right of the node * @brief Set the specific right of the node
* @param[in] _newRight new right to set * @param[in] _newRight new right to set
@ -201,35 +207,35 @@ namespace etk
* @return true : action done * @return true : action done
* @return false : action not done * @return false : action not done
*/ */
void setName(const etk::UString& _newName); void setName(const std::u32string& _newName);
/** /**
* @brief Get the Generate FileSystem name * @brief Get the Generate FileSystem name
* @return the requested filename * @return the requested filename
*/ */
etk::UString getFileSystemName(void) const; std::u32string getFileSystemName(void) const;
/** /**
* @brief Get the current folder of the Node. (file system name) * @brief Get the current folder of the Node. (file system name)
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/) * @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
* @note Auto remove of ../../../ and // * @note Auto remove of ../../../ and //
*/ */
etk::UString getNameFolder(void) const; std::u32string getNameFolder(void) const;
/** /**
* @brief Get the current compleate node name (file system name) * @brief Get the current compleate node name (file system name)
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk) * @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
* @note Auto remove of ../../../ and // * @note Auto remove of ../../../ and //
*/ */
etk::UString getName(void) const; std::u32string getName(void) const;
/** /**
* @brief Get the file or current folder name (if it was a folder) * @brief Get the file or current folder name (if it was a folder)
* @return the name of the node (like myFile.kkk) * @return the name of the node (like myFile.kkk)
*/ */
etk::UString getNameFile(void) const; std::u32string getNameFile(void) const;
/** /**
* @brief Get the current folder of the Node. * @brief Get the current folder of the Node.
* @return the common name define (like DATA:xxxxx/xxxxx/) * @return the common name define (like DATA:xxxxx/xxxxx/)
* @note Auto remove of ../../../ and // * @note Auto remove of ../../../ and //
*/ */
etk::UString getRelativeFolder(void) const; std::u32string getRelativeFolder(void) const;
/** /**
* @brief update the Time of the file with the current time * @brief update the Time of the file with the current time
* @return true : action done * @return true : action done
@ -242,12 +248,14 @@ namespace etk
* @return true : action done * @return true : action done
* @return false : action not done * @return false : action not done
*/ */
bool move(const etk::UString& _path); bool move(const std::u32string& _path);
/** /**
* @brief Get the node type (DATA/DIRECT...) * @brief Get the node type (DATA/DIRECT...)
* @return the requested type * @return the requested type
*/ */
enum FSNType getTypeAccess(void) const { return m_type; }; enum FSNType getTypeAccess(void) const {
return m_type;
};
/** /**
* @brief Remove the current node ( if folder, this remove all subfolder but not the Link subfolder) * @brief Remove the current node ( if folder, this remove all subfolder but not the Link subfolder)
* @return true : action done * @return true : action done
@ -263,7 +271,7 @@ namespace etk
* @brief Get the creating time of the File * @brief Get the creating time of the File
* @return The time requested (in string) * @return The time requested (in string)
*/ */
etk::UString timeCreatedString(void) const; std::u32string timeCreatedString(void) const;
/** /**
* @brief Get the modifying time of the File * @brief Get the modifying time of the File
* @return The time requested * @return The time requested
@ -273,7 +281,7 @@ namespace etk
* @brief Get the modifying time of the File * @brief Get the modifying time of the File
* @return The time requested (in string) * @return The time requested (in string)
*/ */
etk::UString timeModifiedString(void) const; std::u32string timeModifiedString(void) const;
/** /**
* @brief Get the Accessed time of the File * @brief Get the Accessed time of the File
* @return The time requested * @return The time requested
@ -283,7 +291,7 @@ namespace etk
* @brief Get the Accessed time of the File * @brief Get the Accessed time of the File
* @return The time requested (in string) * @return The time requested (in string)
*/ */
etk::UString timeAccessedString(void) const; std::u32string timeAccessedString(void) const;
/** /**
* @brief copy the other FSnode ==> for vector * @brief copy the other FSnode ==> for vector
* @param[in] _obj input node * @param[in] _obj input node
@ -324,7 +332,7 @@ namespace etk
* @param[in] _temporaryFile add Tmp file like .bck or ~ * @param[in] _temporaryFile add Tmp file like .bck or ~
* @return The requested list * @return The requested list
*/ */
etk::Vector<etk::FSNode*> folderGetSubList(bool _showHidenFile=true, std::vector<etk::FSNode*> folderGetSubList(bool _showHidenFile = true,
bool _getFolderAndOther = true, bool _getFolderAndOther = true,
bool _getFile = true, bool _getFile = true,
bool _temporaryFile = true); bool _temporaryFile = true);
@ -338,7 +346,7 @@ namespace etk
* @param[out] _output List of all the File names (You must clear it before set it in) * @param[out] _output List of all the File names (You must clear it before set it in)
* @param[in] _recursiveEnable Activate the recursive mode (enable by default) * @param[in] _recursiveEnable Activate the recursive mode (enable by default)
*/ */
void folderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable=true); void folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable=true);
/** /**
* @brief Check if the file have an extention ( ***.ccc) * @brief Check if the file have an extention ( ***.ccc)
* @return true The file have an extention. * @return true The file have an extention.
@ -349,7 +357,7 @@ namespace etk
* @brief Get the extention of the Node * @brief Get the extention of the Node
* @return the requested extention * @return the requested extention
*/ */
etk::UString fileGetExtention(void); std::u32string fileGetExtention(void);
/** /**
* @brief Get the File size * @brief Get the File size
* @return the requested size * @return the requested size
@ -426,7 +434,7 @@ namespace etk
* @brief Order the list of subnode the folder first and the alphabetical order * @brief Order the list of subnode the folder first and the alphabetical order
* @param[in,out] _list The list to order * @param[in,out] _list The list to order
*/ */
void sortElementList(etk::Vector<etk::FSNode *>& _list); void sortElementList(std::vector<etk::FSNode *>& _list);
}; };
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNode &_obj); etk::CCout& operator <<(etk::CCout &_os, const etk::FSNode &_obj);
@ -455,33 +463,32 @@ namespace etk
* @brief Get the home folder of the user * @brief Get the home folder of the user
* @return the home folder : like : "/home/machin/" * @return the home folder : like : "/home/machin/"
*/ */
etk::UString getUserHomeFolder(void); std::u32string getUserHomeFolder(void);
/** /**
* @brief Get the folder of the Program is running * @brief Get the folder of the Program is running
* @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder) * @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder)
*/ */
etk::UString getUserRunFolder(void); std::u32string getUserRunFolder(void);
namespace theme namespace theme {
{
// TODO : Add an INIT ... // TODO : Add an INIT ...
/** /**
* @brief Set the Folder of a subset of a theme ... * @brief Set the Folder of a subset of a theme ...
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT" * @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/") * @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
*/ */
void setName(etk::UString _refName, etk::UString _folderName); void setName(std::u32string _refName, std::u32string _folderName);
/** /**
* @brief get the folder from a Reference theme * @brief get the folder from a Reference theme
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT" * @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme * @return the path of the theme
*/ */
etk::UString getName(etk::UString _refName); std::u32string getName(std::u32string _refName);
/** /**
* @brief Get the list of all the theme folder availlable in the user Home/appl * @brief Get the list of all the theme folder availlable in the user Home/appl
* @return The list of elements * @return The list of elements
*/ */
etk::Vector<etk::UString> list(void); std::vector<std::u32string> list(void);
}; };
/** /**
@ -490,14 +497,14 @@ namespace etk
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeRemove(const etk::UString& _path); bool FSNodeRemove(const std::u32string& _path);
/** /**
* @brief Simple access for : count the number of element in a path (if it is not a path ==> return -1) * @brief Simple access for : count the number of element in a path (if it is not a path ==> return -1)
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return number of File inside * @return number of File inside
* @return -1 : An error occured * @return -1 : An error occured
*/ */
int64_t FSNodeGetCount(const etk::UString& _path); int64_t FSNodeGetCount(const std::u32string& _path);
/** /**
* @brief Simple access for : Create a file or a folder depending of the request * @brief Simple access for : Create a file or a folder depending of the request
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
@ -506,14 +513,14 @@ namespace etk
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER); bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
/** /**
* @brief Simple access for : chexk the exestance of an element * @brief Simple access for : chexk the exestance of an element
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeExist(const etk::UString& _path); bool FSNodeExist(const std::u32string& _path);
/** /**
* @brief Simple access for : chexk the exestance of an element * @brief Simple access for : chexk the exestance of an element
* @param[in] _path1 Folder/File/Pipe path of the node sources * @param[in] _path1 Folder/File/Pipe path of the node sources
@ -521,49 +528,49 @@ namespace etk
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeMove(const etk::UString& _path1, const etk::UString& _path2); bool FSNodeMove(const std::u32string& _path1, const std::u32string& _path2);
/** /**
* @brief Simple access for : Get right of the current Node * @brief Simple access for : Get right of the current Node
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
etk::FSNodeRight FSNodeGetRight(const etk::UString& _path); etk::FSNodeRight FSNodeGetRight(const std::u32string& _path);
/** /**
* @brief Simple access for : Get type of the current node * @brief Simple access for : Get type of the current node
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
enum etk::typeNode FSNodeGetType(const etk::UString& _path); enum etk::typeNode FSNodeGetType(const std::u32string& _path);
/** /**
* @brief Simple access for : Getting creation time of the current node * @brief Simple access for : Getting creation time of the current node
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
uint64_t FSNodeGetTimeCreated(const etk::UString& _path); uint64_t FSNodeGetTimeCreated(const std::u32string& _path);
/** /**
* @brief Simple access for : Getting Modification time of the current node * @brief Simple access for : Getting Modification time of the current node
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
uint64_t FSNodeGetTimeModified(const etk::UString& _path); uint64_t FSNodeGetTimeModified(const std::u32string& _path);
/** /**
* @brief Simple access for : Getting Accessing time of the current node * @brief Simple access for : Getting Accessing time of the current node
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
uint64_t FSNodeGetTimeAccessed(const etk::UString& _path); uint64_t FSNodeGetTimeAccessed(const std::u32string& _path);
/** /**
* @brief Simple access for : Update Modification time with the current time of the node (>) * @brief Simple access for : Update Modification time with the current time of the node (>)
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeTouch(const etk::UString& _path); bool FSNodeTouch(const std::u32string& _path);
/** /**
* @brief Simple access for : Basic write on the node (like console echo) * @brief Simple access for : Basic write on the node (like console echo)
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
@ -571,7 +578,7 @@ namespace etk
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeEcho(const etk::UString& _path, const etk::UString& _dataTowrite); bool FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite);
/** /**
* @brief Simple access for : Basic write on the node (like console echo) in adding mode (>>) * @brief Simple access for : Basic write on the node (like console echo) in adding mode (>>)
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
@ -579,13 +586,13 @@ namespace etk
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeEchoAdd(const etk::UString& _path, const etk::UString& _dataTowrite); bool FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite);
/** /**
* @brief move file to generate an history of the current file * @brief move file to generate an history of the current file
* @param[in] _path Folder/File/Pipe path of the node * @param[in] _path Folder/File/Pipe path of the node
* @param[in] _historyCount number of saved file in the history (-xxx) * @param[in] _historyCount number of saved file in the history (-xxx)
*/ */
void FSNodeHistory(const etk::UString& _path, int32_t _historyCount); void FSNodeHistory(const std::u32string& _path, int32_t _historyCount);
}; };
#endif #endif

View File

@ -176,53 +176,53 @@ void etk::FSNodeRight::setOtherRunable(bool _newStatus)
m_rights |= RIGHT_OTHER_EXECUTE; m_rights |= RIGHT_OTHER_EXECUTE;
} }
} }
etk::UString etk::FSNodeRight::getRight(void) const std::u32string etk::FSNodeRight::getRight(void) const
{ {
etk::UString tmp; std::u32string tmp;
if (isUserReadable() == true) { if (isUserReadable() == true) {
tmp += "r"; tmp += U"r";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isUserWritable() == true) { if (isUserWritable() == true) {
tmp += "w"; tmp += U"w";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isUserRunable() == true) { if (isUserRunable() == true) {
tmp += "x"; tmp += U"x";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isGroupReadable() == true) { if (isGroupReadable() == true) {
tmp += "r"; tmp += U"r";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isGroupWritable() == true) { if (isGroupWritable() == true) {
tmp += "w"; tmp += U"w";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isGroupRunable() == true) { if (isGroupRunable() == true) {
tmp += "x"; tmp += U"x";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isOtherReadable() == true) { if (isOtherReadable() == true) {
tmp += "r"; tmp += U"r";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isOtherWritable() == true) { if (isOtherWritable() == true) {
tmp += "w"; tmp += U"w";
} else { } else {
tmp += "-"; tmp += U"-";
} }
if (isOtherRunable() == true) { if (isOtherRunable() == true) {
tmp += "x"; tmp += U"x";
} else { } else {
tmp += "-"; tmp += U"-";
} }
return tmp; return tmp;
} }

View File

@ -49,7 +49,7 @@ namespace etk
void setOtherWritable(bool _newStatus); void setOtherWritable(bool _newStatus);
void setOtherRunable(bool _newStatus); void setOtherRunable(bool _newStatus);
etk::UString getRight(void) const; std::u32string getRight(void) const;
}; };
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj); etk::CCout& operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj);
}; };

View File

@ -25,9 +25,9 @@ int32_t etk::tool::irand(int32_t _a, int32_t _b)
return (int32_t)(( rand()/(float)RAND_MAX ) * ((float)_b-(float)_a) + (float)_a); return (int32_t)(( rand()/(float)RAND_MAX ) * ((float)_b-(float)_a) + (float)_a);
} }
void etk::tool::sortList(etk::Vector<etk::UString *> &_list) void etk::tool::sortList(std::vector<std::u32string *> &_list)
{ {
etk::Vector<etk::UString *> tmpList = _list; std::vector<std::u32string *> tmpList = _list;
_list.clear(); _list.clear();
for(int32_t iii=0; iii<tmpList.size(); iii++) { for(int32_t iii=0; iii<tmpList.size(); iii++) {
@ -39,7 +39,7 @@ void etk::tool::sortList(etk::Vector<etk::UString *> &_list)
} }
} }
//EWOL_DEBUG("position="<<findPos); //EWOL_DEBUG("position="<<findPos);
_list.insert(findPos, tmpList[iii]); _list.insert(_list.begin()+findPos, tmpList[iii]);
} }
} }
@ -69,13 +69,13 @@ bool etk::tool::strnCmpNoCase(const char * _input1, const char * _input2, int32_
} }
etk::UString etk::tool::simplifyPath(etk::UString _input) std::u32string etk::tool::simplifyPath(std::u32string _input)
{ {
int32_t findStartPos = _input.findForward('/') + 1; size_t findStartPos = _input.find('/') + 1;
int32_t findPos = _input.findForward('/', findStartPos); size_t findPos = _input.find('/', findStartPos);
//TK_DEBUG("Siplify : \"" << input << "\""); //TK_DEBUG("Siplify : \"" << input << "\"");
int32_t preventBadCode = 0; int32_t preventBadCode = 0;
while (findPos!=-1) while (findPos!=0)
{ {
//TK_DEBUG(" string=\"" << input << "\""); //TK_DEBUG(" string=\"" << input << "\"");
//TK_DEBUG(" '/' @" << findPos); //TK_DEBUG(" '/' @" << findPos);
@ -87,7 +87,7 @@ etk::UString etk::tool::simplifyPath(etk::UString _input)
|| ( _input[findPos+1] == '.' || ( _input[findPos+1] == '.'
&& _input.size()==findPos+2 )) { && _input.size()==findPos+2 )) {
// cleane the element path // cleane the element path
_input.remove(findPos+1, 1); _input.erase(findPos+1, 1);
//TK_DEBUG(" Remove // string=\"" << input << "\""); //TK_DEBUG(" Remove // string=\"" << input << "\"");
} else { } else {
if (_input.size()<findPos+2) { if (_input.size()<findPos+2) {
@ -97,18 +97,18 @@ etk::UString etk::tool::simplifyPath(etk::UString _input)
if( _input[findPos+1] == '.' if( _input[findPos+1] == '.'
&& _input[findPos+2] == '.') { && _input[findPos+2] == '.') {
// cleane the element path // cleane the element path
_input.remove(findStartPos, findPos+3 - findStartPos ); _input.erase(findStartPos, findPos+3 - findStartPos );
//TK_DEBUG(" Remove xxx/.. string=\"" << input << "\""); //TK_DEBUG(" Remove xxx/.. string=\"" << input << "\"");
} else if( _input[findPos+1] == '.' } else if( _input[findPos+1] == '.'
&& _input[findPos+2] == '/') { && _input[findPos+2] == '/') {
// cleane the element path // cleane the element path
_input.remove(findPos+1, 2); _input.erase(findPos+1, 2);
//TK_DEBUG(" Remove ./ string=\"" << input << "\""); //TK_DEBUG(" Remove ./ string=\"" << input << "\"");
} else { } else {
findStartPos = findPos+1; findStartPos = findPos+1;
} }
} }
findPos = _input.findForward('/', findStartPos); findPos = _input.find('/', findStartPos);
preventBadCode++; preventBadCode++;
if (preventBadCode>5000) { if (preventBadCode>5000) {
TK_CRITICAL("ERROR when getting the small path ... this is loop prevention..."); TK_CRITICAL("ERROR when getting the small path ... this is loop prevention...");
@ -119,12 +119,12 @@ etk::UString etk::tool::simplifyPath(etk::UString _input)
// for the target that supported the Realpath system : // for the target that supported the Realpath system :
char buf[MAX_FILE_NAME]; char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME); memset(buf, 0, MAX_FILE_NAME);
char * ok = realpath(_input.c_str(), buf); char * ok = realpath(to_u8string(_input).c_str(), buf);
if (!ok) { if (!ok) {
TK_ERROR("Error to get the real path"); TK_ERROR("Error to get the real path");
_input = "/"; _input = U"/";
} else { } else {
_input = buf; _input = to_u32string(buf);
} }
#endif #endif

View File

@ -11,15 +11,16 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/UString.h>
#include <vector>
namespace etk { namespace etk {
namespace tool { namespace tool {
float frand(float _a, float _b); float frand(float _a, float _b);
int32_t irand(int32_t _a, int32_t _b); int32_t irand(int32_t _a, int32_t _b);
void sortList(etk::Vector<etk::UString *>& _list); void sortList(std::vector<std::u32string *>& _list);
bool strnCmpNoCase(const char* _input1, const char* _input2, int32_t _maxLen); bool strnCmpNoCase(const char* _input1, const char* _input2, int32_t _maxLen);
etk::UString simplifyPath(etk::UString _input); std::u32string simplifyPath(std::u32string _input);
}; };
}; };

View File

@ -9,6 +9,18 @@
#ifndef __ETK_TYPES_H__ #ifndef __ETK_TYPES_H__
#define __ETK_TYPES_H__ #define __ETK_TYPES_H__
#ifdef __TARGET_OS__Android
// NOTE : This is for compatibility with the C++ stdlib (missing this declaration on android ...
namespace std {
typedef struct {
int dummy;
} mbstate_t;
};
#include <wchar.h>
#include <stdio.h>
#endif
#include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -15,24 +15,24 @@
void unicode::convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, etk::UChar & _output_Unicode) void unicode::convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, char32_t & _output_Unicode)
{ {
switch(_inputCharset) switch(_inputCharset)
{ {
case charsetIso8859_1: _output_Unicode.set(tableIso8859_1[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_1: _output_Unicode = tableIso8859_1[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_2: _output_Unicode.set(tableIso8859_2[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_2: _output_Unicode = tableIso8859_2[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_3: _output_Unicode.set(tableIso8859_3[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_3: _output_Unicode = tableIso8859_3[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_4: _output_Unicode.set(tableIso8859_4[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_4: _output_Unicode = tableIso8859_4[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_5: _output_Unicode.set(tableIso8859_5[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_5: _output_Unicode = tableIso8859_5[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_6: _output_Unicode.set(tableIso8859_6[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_6: _output_Unicode = tableIso8859_6[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_7: _output_Unicode.set(tableIso8859_7[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_7: _output_Unicode = tableIso8859_7[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_8: _output_Unicode.set(tableIso8859_8[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_8: _output_Unicode = tableIso8859_8[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_9: _output_Unicode.set(tableIso8859_9[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_9: _output_Unicode = tableIso8859_9[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_10: _output_Unicode.set(tableIso8859_10[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_10: _output_Unicode = tableIso8859_10[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_11: _output_Unicode.set(tableIso8859_11[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_11: _output_Unicode = tableIso8859_11[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_13: _output_Unicode.set(tableIso8859_13[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_13: _output_Unicode = tableIso8859_13[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_14: _output_Unicode.set(tableIso8859_14[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_14: _output_Unicode = tableIso8859_14[(uint32_t)_input_ISO&0xFF]; break;
case charsetIso8859_15: _output_Unicode.set(tableIso8859_15[(uint32_t)_input_ISO&0xFF]); break; case charsetIso8859_15: _output_Unicode = tableIso8859_15[(uint32_t)_input_ISO&0xFF]; break;
default : default :
TK_WARNING("Unknow charset ... " << _inputCharset); TK_WARNING("Unknow charset ... " << _inputCharset);
_output_Unicode = '?'; _output_Unicode = '?';
@ -41,7 +41,7 @@ void unicode::convertIsoToUnicode(enum charset _inputCharset, const char _input_
} }
void unicode::convertUnicodeToIso(enum charset _inputCharset, const etk::UChar _input_Unicode, char & _output_ISO) void unicode::convertUnicodeToIso(enum charset _inputCharset, const char32_t _input_Unicode, char & _output_ISO)
{ {
const uint32_t *tmpTable = NULL; const uint32_t *tmpTable = NULL;
switch(_inputCharset) switch(_inputCharset)
@ -67,7 +67,7 @@ void unicode::convertUnicodeToIso(enum charset _inputCharset, const etk::UChar _
} }
int32_t i; int32_t i;
for (i=0; i<256; i++) { for (i=0; i<256; i++) {
if (tmpTable[i] == _input_Unicode.get()) { if (tmpTable[i] == _input_Unicode) {
_output_ISO = (char)i; _output_ISO = (char)i;
return; return;
} }
@ -75,107 +75,111 @@ void unicode::convertUnicodeToIso(enum charset _inputCharset, const etk::UChar _
} }
int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode) int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char32_t>& _output_Unicode)
{ {
_output_Unicode.clear(); _output_Unicode.clear();
etk::UChar output; char32_t output;
for(int32_t iii=0; iii<_input_ISO.size(); iii++) { for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output); convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
_output_Unicode.pushBack(output); _output_Unicode.push_back(output);
} }
if (_output_Unicode.size() == 0) { if (_output_Unicode.size() == 0) {
_output_Unicode.pushBack(0); _output_Unicode.push_back(0);
} else if (_output_Unicode[_output_Unicode.size()-1] != 0) { } else if (_output_Unicode[_output_Unicode.size()-1] != 0) {
_output_Unicode.pushBack(0); _output_Unicode.push_back(0);
} }
return _output_Unicode.size(); return _output_Unicode.size();
} }
int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode) int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const std::vector<int8_t>& _input_ISO, std::vector<char32_t>& _output_Unicode)
{ {
_output_Unicode.clear(); _output_Unicode.clear();
etk::UChar output; char32_t output;
for(int32_t iii=0; iii<_input_ISO.size(); iii++) { for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output); convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
_output_Unicode.pushBack(output); _output_Unicode.push_back(output);
} }
if (_output_Unicode.size() == 0) { if (_output_Unicode.size() == 0) {
_output_Unicode.pushBack(0); _output_Unicode.push_back(0);
} else if (_output_Unicode[_output_Unicode.size()-1] != 0) { } else if (_output_Unicode[_output_Unicode.size()-1] != 0) {
_output_Unicode.pushBack(0); _output_Unicode.push_back(0);
} }
return _output_Unicode.size(); return _output_Unicode.size();
} }
int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_ISO) int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_ISO)
{ {
/*
_output_ISO.clear(); _output_ISO.clear();
char output[10]; char output[10];
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) { for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
_input_Unicode[iii].getUtf8(output); _input_Unicode[iii].getUtf8(output);
char * tmp = output; char * tmp = output;
while(*tmp != '\0') { while(*tmp != '\0') {
_output_ISO.pushBack(*tmp); _output_ISO.push_back(*tmp);
tmp++; tmp++;
} }
} }
_output_ISO.pushBack(0); _output_ISO.push_back(0);
return _output_ISO.size(); return _output_ISO.size();
*/
} }
int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_ISO) int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_ISO)
{ {
/*
_output_ISO.clear(); _output_ISO.clear();
char output[10]; char output[10];
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) { for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
_input_Unicode[iii].getUtf8(output); _input_Unicode[iii].getUtf8(output);
char * tmp = output; char * tmp = output;
while(*tmp != '\0') { while(*tmp != '\0') {
_output_ISO.pushBack(*tmp); _output_ISO.push_back(*tmp);
tmp++; tmp++;
} }
} }
_output_ISO.pushBack(0); _output_ISO.push_back(0);
return _output_ISO.size(); return _output_ISO.size();
*/
} }
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_UTF8) int32_t unicode::convertUnicodeToUtf8(const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_UTF8)
{ {
char output[10]; char output[10];
for (int32_t iii=0; iii<_input_Unicode.size(); iii++) { for (int32_t iii=0; iii<_input_Unicode.size(); iii++) {
_input_Unicode[iii].getUtf8(output); etk::getUtf8(_input_Unicode[iii], output);
char * tmp = output ; char * tmp = output ;
while (*tmp != '\0') { while (*tmp != '\0') {
_output_UTF8.pushBack(*tmp); _output_UTF8.push_back(*tmp);
tmp++; tmp++;
} }
} }
_output_UTF8.pushBack('\0'); _output_UTF8.push_back('\0');
return _output_UTF8.size()-1; return _output_UTF8.size()-1;
} }
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8) int32_t unicode::convertUnicodeToUtf8(const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_UTF8)
{ {
char output[10]; char output[10];
for (int32_t iii=0; iii<_input_Unicode.size(); iii++) { for (int32_t iii=0; iii<_input_Unicode.size(); iii++) {
_input_Unicode[iii].getUtf8(output); etk::getUtf8(_input_Unicode[iii], output);
char * tmp = output ; char * tmp = output ;
while (*tmp != '\0') { while (*tmp != '\0') {
_output_UTF8.pushBack((int8_t)*tmp); _output_UTF8.push_back((int8_t)*tmp);
tmp++; tmp++;
} }
} }
_output_UTF8.pushBack('\0'); _output_UTF8.push_back('\0');
return _output_UTF8.size()-1; return _output_UTF8.size()-1;
} }
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode) int32_t unicode::convertUtf8ToUnicode(const std::vector<char>& _input_UTF8, std::vector<char32_t>& _output_Unicode)
{ {
char tmpData[20]; char tmpData[20];
int32_t pos = 0; int32_t pos = 0;
@ -219,14 +223,12 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk:
tmpData[0] = '\0'; tmpData[0] = '\0';
pos += 1; pos += 1;
} }
etk::UChar tmpUnicode; _output_Unicode.push_back(etk::setUtf8(tmpData));
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
} }
return 0; return 0;
} }
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode) int32_t unicode::convertUtf8ToUnicode(const std::vector<int8_t>& _input_UTF8, std::vector<char32_t>& _output_Unicode)
{ {
char tmpData[20]; char tmpData[20];
int32_t pos = 0; int32_t pos = 0;
@ -270,14 +272,12 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, et
tmpData[0] = '\0'; tmpData[0] = '\0';
pos += 1; pos += 1;
} }
etk::UChar tmpUnicode; _output_Unicode.push_back(etk::setUtf8(tmpData));
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
} }
return 0; return 0;
} }
int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode) int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, std::vector<char32_t>& _output_Unicode)
{ {
char tmpData[20]; char tmpData[20];
int32_t pos = 0; int32_t pos = 0;
@ -325,9 +325,7 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<etk:
tmpData[0] = '\0'; tmpData[0] = '\0';
pos += 1; pos += 1;
} }
etk::UChar tmpUnicode; _output_Unicode.push_back(etk::setUtf8(tmpData));
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
} }
return 0; return 0;
} }
@ -336,32 +334,36 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<etk:
// Transform ISO <==> UTF-8 // Transform ISO <==> UTF-8
void unicode::convertIsoToUtf8(enum charset _inputCharset, const char _input_ISO, char * _output_UTF8) void unicode::convertIsoToUtf8(enum charset _inputCharset, const char _input_ISO, char * _output_UTF8)
{ {
etk::UChar tmpUnicode; /*
char32_t tmpUnicode;
// concert Iso in UniCode // concert Iso in UniCode
convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode ); convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode );
// convert UniCode in Utf-8 // convert UniCode in Utf-8
tmpUnicode.getUtf8(_output_UTF8); tmpUnicode.getUtf8(_output_UTF8);
*/
} }
void unicode::convertUtf8ToIso(enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO) void unicode::convertUtf8ToIso(enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO)
{ {
etk::UChar tmpUnicode; /*
char32_t tmpUnicode;
// convert Utf-8 in UniCode // convert Utf-8 in UniCode
tmpUnicode.setUtf8(_input_UTF8); tmpUnicode.setUtf8(_input_UTF8);
// concert UniCode in Iso // concert UniCode in Iso
convertUnicodeToIso(_inputCharset, tmpUnicode, _output_ISO); convertUnicodeToIso(_inputCharset, tmpUnicode, _output_ISO);
*/
} }
int32_t unicode::convertIsoToUtf8(enum charset _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<char>& _output_UTF8) int32_t unicode::convertIsoToUtf8(enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char>& _output_UTF8)
{ {
TK_WARNING("TODO : not coded..."); TK_WARNING("TODO : not coded...");
return 0; return 0;
} }
int32_t unicode::convertUtf8ToIso(enum charset _inputCharset, const etk::Vector<char>& _input_UTF8, etk::Vector<char>& _output_ISO) int32_t unicode::convertUtf8ToIso(enum charset _inputCharset, const std::vector<char>& _input_UTF8, std::vector<char>& _output_ISO)
{ {
TK_WARNING("TODO : not coded..."); TK_WARNING("TODO : not coded...");
return 0; return 0;

View File

@ -10,7 +10,7 @@
#define __UNICODE_H__ #define __UNICODE_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/Vector.h> #include <vector>
namespace unicode { namespace unicode {
enum charset { enum charset {
@ -32,23 +32,23 @@ namespace unicode {
}; };
// transform ISO <==> Unicode // transform ISO <==> Unicode
void convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, etk::UChar & _output_Unicode); void convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, char32_t & _output_Unicode);
void convertUnicodeToIso(enum charset _inputCharset, const etk::UChar _input_Unicode, char & _output_ISO); void convertUnicodeToIso(enum charset _inputCharset, const char32_t _input_Unicode, char & _output_ISO);
int32_t convertIsoToUnicode(enum charset _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode); int32_t convertIsoToUnicode(enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char32_t>& _output_Unicode);
int32_t convertIsoToUnicode(enum charset _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode); int32_t convertIsoToUnicode(enum charset _inputCharset, const std::vector<int8_t>& _input_ISO, std::vector<char32_t>& _output_Unicode);
int32_t convertUnicodeToIso(enum charset _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_ISO); int32_t convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_ISO);
int32_t convertUnicodeToIso(enum charset _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_ISO); int32_t convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_ISO);
// Transform UTF-8 <==> Unicode // Transform UTF-8 <==> Unicode
int32_t convertUnicodeToUtf8( const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_UTF8); int32_t convertUnicodeToUtf8( const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_UTF8);
int32_t convertUnicodeToUtf8( const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8); int32_t convertUnicodeToUtf8( const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_UTF8);
int32_t convertUtf8ToUnicode( const etk::Vector<char>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode); int32_t convertUtf8ToUnicode( const std::vector<char>& _input_UTF8, std::vector<char32_t>& _output_Unicode);
int32_t convertUtf8ToUnicode( const etk::Vector<int8_t>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode); int32_t convertUtf8ToUnicode( const std::vector<int8_t>& _input_UTF8, std::vector<char32_t>& _output_Unicode);
int32_t convertUtf8ToUnicode( const char * _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode); int32_t convertUtf8ToUnicode( const char * _input_UTF8, std::vector<char32_t>& _output_Unicode);
// Transform ISO <==> UTF-8 // Transform ISO <==> UTF-8
void convertIsoToUtf8( enum charset _inputCharset, const char _input_ISO, char * _output_UTF8); void convertIsoToUtf8( enum charset _inputCharset, const char _input_ISO, char * _output_UTF8);
void convertUtf8ToIso( enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO); void convertUtf8ToIso( enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO);
int32_t convertIsoToUtf8( enum charset _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<char>& _output_UTF8); int32_t convertIsoToUtf8( enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char>& _output_UTF8);
int32_t convertUtf8ToIso( enum charset _inputCharset, const etk::Vector<char>& _input_UTF8, etk::Vector<char>& _output_ISO); int32_t convertUtf8ToIso( enum charset _inputCharset, const std::vector<char>& _input_UTF8, std::vector<char>& _output_ISO);
void utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid); void utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid);
int32_t strUtf8Len(const char *_input_UTF8); int32_t strUtf8Len(const char *_input_UTF8);

View File

@ -7,8 +7,8 @@
*/ */
#include <etk/debug.h> #include <etk/debug.h>
#include <etk/Vector.h> #include <vector>
#include <etk/UString.h> #include <string>
#include <etk/Hash.h> #include <etk/Hash.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#include <etk/archive/Archive.h> #include <etk/archive/Archive.h>
@ -16,33 +16,30 @@
#undef __class__ #undef __class__
#define __class__ "etktest" #define __class__ "etktest"
void testVector(void) void testVector(void) {
{
} }
void testUChar(void) void testUChar(void) {
{
} }
void testUString(void) void testUString(void) {
{
for(int32_t iii=0; iii<64; iii++) { for(int32_t iii=0; iii<64; iii++) {
int64_t kkk=((int64_t)1)<<iii; int64_t kkk=((int64_t)1)<<iii;
etk::UString plop(kkk, etk::UString::printModeBinary); std::u32string plop(kkk, std::u32string::printModeBinary);
TK_DEBUG(" test : " << plop); TK_DEBUG(" test : " << plop);
} }
for(int32_t iii=0; iii<64; iii++) { for(int32_t iii=0; iii<64; iii++) {
int64_t kkk=((int64_t)1)<<iii; int64_t kkk=((int64_t)1)<<iii;
etk::UString plop(kkk, etk::UString::printModeOctal); std::u32string plop(kkk, std::u32string::printModeOctal);
TK_DEBUG(" test : " << plop); TK_DEBUG(" test : " << plop);
} }
for(int32_t iii=0; iii<64; iii++) { for(int32_t iii=0; iii<64; iii++) {
int64_t kkk=((int64_t)1)<<iii; int64_t kkk=((int64_t)1)<<iii;
etk::UString plop(kkk, etk::UString::printModeDecimal); std::u32string plop(kkk, std::u32string::printModeDecimal);
TK_DEBUG(" test : " << plop); TK_DEBUG(" test : " << plop);
int64_t resTest = plop.toInt32(); int64_t resTest = plop.toInt32();
TK_DEBUG(" test : " << resTest); TK_DEBUG(" test : " << resTest);
@ -50,15 +47,14 @@ void testUString(void)
for(int32_t iii=0; iii<64; iii++) { for(int32_t iii=0; iii<64; iii++) {
int64_t kkk=((int64_t)1)<<iii; int64_t kkk=((int64_t)1)<<iii;
etk::UString plop(kkk, etk::UString::printModeHexadecimal); std::u32string plop(kkk, std::u32string::printModeHexadecimal);
TK_DEBUG(" test : " << plop); TK_DEBUG(" test : " << plop);
} }
} }
void testHash(void) void testHash(void) {
{
TK_INFO("==> Start test of Hach table"); TK_INFO("==> Start test of Hach table");
etk::Hash<etk::UString> testData; etk::Hash<std::u32string> testData;
testData.add("TEST", "testData"); testData.add("TEST", "testData");
testData.add("TEST", "testData333"); testData.add("TEST", "testData333");
testData.add("TEST2", "22222222222222222"); testData.add("TEST2", "22222222222222222");
@ -74,10 +70,9 @@ void testHash(void)
TK_INFO("==> End test of Hach table"); TK_INFO("==> End test of Hach table");
} }
void testFSNode(void) void testFSNode(void) {
{
TK_INFO("==> Start test of FSNode"); TK_INFO("==> Start test of FSNode");
etk::UString fileName("USERDATA:myFileTest.txt"); std::u32string fileName("USERDATA:myFileTest.txt");
etk::FSNode myNodeTest1(fileName); etk::FSNode myNodeTest1(fileName);
TK_INFO("********************************************"); TK_INFO("********************************************");
TK_INFO("** Filename=\"" << fileName << "\""); TK_INFO("** Filename=\"" << fileName << "\"");
@ -116,8 +111,7 @@ void testFSNode(void)
} }
void testArchive(void) void testArchive(void) {
{
TK_INFO("==> Start test of archive"); TK_INFO("==> Start test of archive");
etk::Archive* tmpArchive = etk::Archive::load("testzip.zip"); etk::Archive* tmpArchive = etk::Archive::load("testzip.zip");
tmpArchive->display(); tmpArchive->display();
@ -126,8 +120,7 @@ void testArchive(void)
} }
/* /*
void testDimension(void) void testDimension(void) {
{
TK_INFO("==> test of Dimension (START)"); TK_INFO("==> test of Dimension (START)");
ewol::Dimension myDimention(vec2(5,5), ewol::Dimension::Centimeter); ewol::Dimension myDimention(vec2(5,5), ewol::Dimension::Centimeter);
@ -145,10 +138,9 @@ void testDimension(void)
exit(0); exit(0);
} }
*/ */
int main(int argc, const char *argv[]) int main(int argc, const char *argv[]) {
{
// the only one init for etk: // the only one init for etk:
debug::setGeneralLevel(etk::LOG_LEVEL_VERBOSE); debug::setGeneralLevel(etk::logLevelVerbose);
//testVector(); //testVector();
//testUChar(); //testUChar();
//testUString(); //testUString();