[DEV] etk normalisation
This commit is contained in:
parent
6f8a4f8510
commit
f2fa6535c5
148
etk/Buffer.h
148
etk/Buffer.h
@ -42,7 +42,8 @@
|
||||
|
||||
namespace etk {
|
||||
/**
|
||||
* @brief Buffer classes. Designed for access o
|
||||
* @brief This is an access on raw data that contain an internal gap.
|
||||
* the gap size has an offset to increase an an offset to decrease.
|
||||
*/
|
||||
class Buffer {
|
||||
private:
|
||||
@ -91,32 +92,36 @@ namespace etk {
|
||||
m_gapEnd = 0;
|
||||
};
|
||||
/**
|
||||
* @brief Save in the current file open
|
||||
* @param[in,out] _file Pointer on the file where data might be writed
|
||||
* @return true if OK / false if an error occured
|
||||
* @brief Store the selected data in the requested file.
|
||||
* @param[in] _file Name of the file that might be written.
|
||||
* @return true if the data corectly stored
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool dumpIn(etk::FSNode& _file) {
|
||||
if (false == _file.fileOpenWrite()) {
|
||||
bool dumpIn(const std::string& _file) {
|
||||
etk::FSNode file(_file);
|
||||
if (false == file.fileOpenWrite()) {
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
// write Data
|
||||
(void)_file.fileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)_file.fileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
_file.fileClose();
|
||||
(void)file.fileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)file.fileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
file.fileClose();
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* @brief Load in the current file open
|
||||
* @param[in,out] _myFile Pointer on the file where data might be read
|
||||
* @return true if OK / false if an error occured
|
||||
* @brief Load data fron a selected file name.
|
||||
* @param[in] _file Name of the file to store buffer data.
|
||||
* @return true if the data corectly stored
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool dumpFrom(etk::FSNode& _file) {
|
||||
if (false == _file.fileOpenRead()) {
|
||||
bool dumpFrom(const std::string& _file) {
|
||||
etk::FSNode file(_file);
|
||||
if (false == file.fileOpenRead()) {
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
uint32_t length = _file.fileSize();
|
||||
uint32_t length = file.fileSize();
|
||||
// error case ...
|
||||
if (length > 2000000000) {
|
||||
return false;
|
||||
@ -124,47 +129,47 @@ namespace etk {
|
||||
// allocate the current buffer :
|
||||
changeAllocation(length + GAP_SIZE_MIN);
|
||||
// insert Data
|
||||
int32_t nbReadData = _file.fileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
int32_t nbReadData = file.fileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
TK_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
|
||||
// check ERROR
|
||||
if (nbReadData != length) {
|
||||
TK_ERROR("load data pb : filesize=" << length << ", readData=" << nbReadData);
|
||||
ret = false;
|
||||
}
|
||||
// set the gapsize at the end ...
|
||||
// set the gapsize at the fd ...
|
||||
m_gapStart = 0;
|
||||
m_gapEnd = GAP_SIZE_MIN;
|
||||
_file.fileClose();
|
||||
file.fileClose();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Re-copy operator
|
||||
* @param[in] _obj Buffer that might be copy
|
||||
* @return reference on the curent re-copy vector
|
||||
* @return reference on the curent copied Buffer
|
||||
*/
|
||||
etk::Buffer& operator=(const etk::Buffer& _obj) {
|
||||
if( this != &_obj ) // avoid copy to itself
|
||||
{
|
||||
if (NULL!=m_data) {
|
||||
free(m_data);
|
||||
m_data = NULL;
|
||||
}
|
||||
// Set the new value
|
||||
m_allocated = _obj.m_allocated;
|
||||
m_gapStart = _obj.m_gapStart;
|
||||
m_gapEnd = _obj.m_gapEnd;
|
||||
// allocate all same data
|
||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
||||
TK_ASSERT(NULL!=m_data, "Error in data allocation");
|
||||
// Copy all data ...
|
||||
memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
|
||||
if( this == &_obj ) {// avoid copy to itself
|
||||
return *this;
|
||||
}
|
||||
if (NULL != m_data) {
|
||||
free(m_data);
|
||||
m_data = NULL;
|
||||
}
|
||||
// Set the new value
|
||||
m_allocated = _obj.m_allocated;
|
||||
m_gapStart = _obj.m_gapStart;
|
||||
m_gapEnd = _obj.m_gapEnd;
|
||||
// allocate all same data
|
||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
||||
TK_ASSERT(NULL!=m_data, "Error in data allocation");
|
||||
// Copy all data ...
|
||||
memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
|
||||
// Return the curent pointer
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Operator [] : Get the data at the requested position (gap abstraction done).
|
||||
* @brief Get the data at the requested position (gap abstraction done).
|
||||
* @param[in] _pos Position in the buffer.
|
||||
* @return Element at the request pos.
|
||||
*/
|
||||
@ -188,21 +193,6 @@ namespace etk {
|
||||
}
|
||||
return m_data[_pos + m_gapEnd-m_gapStart];
|
||||
}
|
||||
#if 0
|
||||
/**
|
||||
* @brief Get a current element in the vector
|
||||
* @param[in] _pos Desired position read
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
int32_t get(int32_t _pos, UChar& _value, charset_te _charset) const
|
||||
{
|
||||
TK_ASSERT(0 <= pos || pos < size(), "try to read an element non existing");
|
||||
if (pos < m_gapStart) {
|
||||
return m_data[pos];
|
||||
}
|
||||
return m_data[pos + m_gapEnd-m_gapStart];
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @brief Get elements from a specific position.
|
||||
* @param[in] _pos Position of the first element.
|
||||
@ -226,15 +216,17 @@ namespace etk {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (size_t iii = _pos+(m_gapEnd-m_gapStart); iii<_pos+(m_gapEnd-m_gapStart)+_nbElement; ++iii) {
|
||||
for (size_t iii = _pos+(m_gapEnd-m_gapStart);
|
||||
iii<_pos+(m_gapEnd-m_gapStart)+_nbElement;
|
||||
++iii) {
|
||||
tmpBuffer.push_back(m_data[iii]);
|
||||
}
|
||||
}
|
||||
return tmpBuffer;
|
||||
}
|
||||
/**
|
||||
* @brief Add at the Last position of the Vector
|
||||
* @param[in] _item Element to add at the end of vector
|
||||
* @brief Add at the Last position of the Buffer.
|
||||
* @param[in] _item Element to add.
|
||||
*/
|
||||
void push_back(const int8_t& _item) {
|
||||
insert(size(), _item);
|
||||
@ -272,11 +264,11 @@ namespace etk {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Insert data in the buffer
|
||||
* @brief Insert data in the Buffer.
|
||||
* @param[in] _pos Position where data might be inserted
|
||||
* @param[in] _items Data that might be inserted.
|
||||
*/
|
||||
void insert(int32_t _pos, std::vector<int8_t>& _items) {
|
||||
void insert(int32_t _pos, const std::vector<int8_t>& _items) {
|
||||
insert(_pos, &_items[0], _items.size());
|
||||
}
|
||||
/**
|
||||
@ -285,7 +277,7 @@ namespace etk {
|
||||
* @param[in] _items Data that might be inserted. (no need of '\0')
|
||||
* @param[in] _nbElement number of element to insert
|
||||
*/
|
||||
void insert(int32_t _pos, int8_t* _items, int32_t _nbElement) {
|
||||
void insert(int32_t _pos, const int8_t* _items, int32_t _nbElement) {
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
@ -300,15 +292,15 @@ namespace etk {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for(int32_t iii=0; iii<_nbElement; iii++) {
|
||||
for(int32_t iii=0; iii<_nbElement; ++iii) {
|
||||
m_data[m_gapStart+iii] = _items[iii];
|
||||
}
|
||||
m_gapStart += _nbElement;
|
||||
}
|
||||
/**
|
||||
* @brief Replace one element in the buffer
|
||||
* @param[in] _pos The first element to remove.
|
||||
* @param[in] _items Data that might be inserted.
|
||||
* @brief Replace one element in the buffer with an other.
|
||||
* @param[in] _pos Position of the element to remove.
|
||||
* @param[in] _items Element that might be inserted.
|
||||
*/
|
||||
void replace(int32_t _pos, const int8_t& _item) {
|
||||
if( _pos > size()
|
||||
@ -324,22 +316,22 @@ namespace etk {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Replace specified data.
|
||||
* @brief Replace a part of the buffer with the specified data.
|
||||
* @param[in] _pos The first element to remove.
|
||||
* @param[in] _nbRemoveElement number of element to remove.
|
||||
* @param[in] _items Data that might be inserted.
|
||||
* @param[in] _items Data that will be inserted.
|
||||
*/
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, std::vector<int8_t>& _items) {
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, const std::vector<int8_t>& _items) {
|
||||
replace(_pos, _nbRemoveElement, &_items[0], _items.size());
|
||||
}
|
||||
/**
|
||||
* @brief Replace specified data.
|
||||
* @brief Replace a part of the buffer with the specified data.
|
||||
* @param[in] _pos The first element to remove.
|
||||
* @param[in] _nbRemoveElement number of element to remove.
|
||||
* @param[in] _items Data that might be inserted.
|
||||
* @param[in] _nbElement Number of element that might be added.
|
||||
*/
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, int8_t* _items, int32_t _nbElement) {
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, const int8_t* _items, int32_t _nbElement) {
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
@ -363,8 +355,8 @@ namespace etk {
|
||||
}
|
||||
/**
|
||||
* @brief Remove specific data in the buffer.
|
||||
* @param[in] _pos The first element to remove
|
||||
* @param[in] _nbRemoveElement number of element to remove
|
||||
* @param[in] _pos The first element to remove.
|
||||
* @param[in] _nbRemoveElement Number of element to remove.
|
||||
*/
|
||||
void remove(int32_t _pos, int32_t _nbRemoveElement = 1) {
|
||||
if( _pos > size()
|
||||
@ -393,34 +385,36 @@ namespace etk {
|
||||
* @brief Remove the last element of the Buffer.
|
||||
*/
|
||||
void pop_back(void) {
|
||||
if (size()>0) {
|
||||
if (size() > 0) {
|
||||
remove( size() );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Clean all the data in the buffer.
|
||||
* @brief Remove all the data in the buffer.
|
||||
*/
|
||||
void clear(void) {
|
||||
remove(0, size() );
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* @brief Get a current element in the vector (iterator system)
|
||||
* @brief Get a current element in the Buffer (iterator system)
|
||||
* @param[in] _realElementPosition Real position in the buffer (only use in the ITERATOR)
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
int8_t& getDirect(int32_t _realElementPosition) {
|
||||
return m_data[_realElementPosition];
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Get the number of element in the vector
|
||||
* @return The number requested
|
||||
* @brief Get the number of element in the vector. This does not contain the gap size.
|
||||
* @return The size of the set data.
|
||||
*/
|
||||
int32_t size(void) const {
|
||||
return m_allocated - gapSize();
|
||||
};
|
||||
private:
|
||||
/**
|
||||
* @brief Change the current allocation to the corect one (depend on the current size)
|
||||
* @brief Change the current allocation to the new one (depend on the current size)
|
||||
* @param[in] _newSize Minimum number of element needed
|
||||
*/
|
||||
void changeAllocation(int32_t _newSize) {
|
||||
@ -432,6 +426,7 @@ namespace etk {
|
||||
if (_newSize == m_allocated) {
|
||||
return;
|
||||
}
|
||||
//TODO : use new and delete and multiple of power of 2.
|
||||
TK_DEBUG("Change Allocation : " << m_allocated << " ==> " << _newSize);
|
||||
// check if something is allocated :
|
||||
if (m_data == NULL) {
|
||||
@ -472,7 +467,7 @@ namespace etk {
|
||||
* @brief Change The gap position and size
|
||||
* @param[in] _pos Position of the new Gap.
|
||||
* @param[in] _newGapLen Size of the new gap (can be bigger than GAP_SIZE_MAX).
|
||||
* @return false The operation can not be proccesed.
|
||||
* @return false The operation can not be done.
|
||||
* @return true The operation done correctly.
|
||||
*/
|
||||
bool gapResize(int32_t _pos, int32_t _newGapLen) {
|
||||
@ -501,7 +496,6 @@ namespace etk {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// no else
|
||||
} else {
|
||||
if (false == gapMove(_pos) ) {
|
||||
return false;
|
||||
@ -520,13 +514,13 @@ namespace etk {
|
||||
}
|
||||
/**
|
||||
* @brief Get the current gap size.
|
||||
* @return The number of element in the gap
|
||||
* @return The number of element in the gap.
|
||||
*/
|
||||
int32_t gapSize(void) const {
|
||||
return m_gapEnd - m_gapStart;
|
||||
}
|
||||
/**
|
||||
* @brief Control if the writing gap is not too big (automatic resize the buffer).
|
||||
* @brief Control if the writing gap is not too big (automatic call when resize the buffer).
|
||||
*/
|
||||
void gapCheckMaxSize(void) {
|
||||
if(gapSize() > GAP_SIZE_MAX) {
|
||||
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
14
etk/Char.h
14
etk/Char.h
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_CHAR_H__
|
||||
#define __ETK_CHAR_H__
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -14,11 +14,13 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
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;
|
||||
while ('\0' != *input1 && '\0' != *input2 && iii < maxLen) {
|
||||
char in1 = *input1;
|
||||
char in2 = *input2;
|
||||
while ( '\0' != *_input1
|
||||
&& '\0' != *_input2
|
||||
&& iii < _maxLen) {
|
||||
char in1 = *_input1;
|
||||
char in2 = *_input2;
|
||||
if (in1 != in2) {
|
||||
if (in1 <= 'Z' && in1 >= 'A') {
|
||||
in1 = in1 - 'A' + 'a';
|
||||
@ -31,8 +33,8 @@ static bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxL
|
||||
}
|
||||
}
|
||||
iii++;
|
||||
input1++;
|
||||
input2++;
|
||||
_input1++;
|
||||
_input2++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -85,7 +87,7 @@ namespace etk {
|
||||
return Color<uint8_t>(*this).get();
|
||||
}
|
||||
|
||||
template<> Color<uint8_t>::Color(std::string _input) :
|
||||
template<> Color<uint8_t>::Color(const std::string& _input) :
|
||||
m_r(255),
|
||||
m_g(255),
|
||||
m_b(255),
|
||||
@ -189,15 +191,15 @@ namespace etk {
|
||||
TK_VERBOSE("Parse color : \"" << inputData << "\" ==> " << *this);
|
||||
}
|
||||
|
||||
template<> Color<float>::Color(std::string _input) {
|
||||
template<> Color<float>::Color(const std::string& _input) {
|
||||
etk::Color<uint8_t> tmpColor(_input);
|
||||
*this = tmpColor;
|
||||
}
|
||||
};
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<uint8_t>& _obj)
|
||||
{
|
||||
_os << _obj.getString();
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<uint8_t>& _obj) {
|
||||
_os << "#";
|
||||
_os << (std::to_string<uint32_t>(_obj.get(), std::hex)).c_str();
|
||||
return _os;
|
||||
}
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<float>& _obj)
|
||||
|
153
etk/Color.h
153
etk/Color.h
@ -9,43 +9,112 @@
|
||||
#ifndef __ETK_COLOR_H__
|
||||
#define __ETK_COLOR_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace etk {
|
||||
template<class MY_TYPE=uint8_t> class Color
|
||||
{
|
||||
/**
|
||||
* @brief The color class is a template to abstract the color implementation choice.
|
||||
*
|
||||
* It is important to note that the color choice denpznd on the level of developent.
|
||||
* For example :
|
||||
* :** Graphic application use:
|
||||
* ::** Image in 3/4 bytes for rgb(a)
|
||||
* ::** Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF
|
||||
* :** middleware will mainely use a the 4 separate value with 1 byte for each.
|
||||
* :** graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
|
||||
*
|
||||
* Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level.
|
||||
*
|
||||
* Some of the basic color is defined in the namespace: [namespace[etk::color]].
|
||||
*
|
||||
* @template-param MY_TYPE Type of the internal template value. The generic value is uint8_t and float
|
||||
*/
|
||||
template<class MY_TYPE=uint8_t> class Color {
|
||||
private:
|
||||
MY_TYPE m_r;
|
||||
MY_TYPE m_g;
|
||||
MY_TYPE m_b;
|
||||
MY_TYPE m_a;
|
||||
public :
|
||||
MY_TYPE m_r; //!< Red color value.
|
||||
MY_TYPE m_g; //!< Green color value.
|
||||
MY_TYPE m_b; //!< Blue color value
|
||||
MY_TYPE m_a; //!< Alpha blending value.
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor. It does not initialise element of class.
|
||||
*/
|
||||
Color(void) { };
|
||||
Color(double _r, double _g, double _b, double _a=255) { set((float)_r, (float)_g, (float)_b, (float)_a); };
|
||||
Color(float _r, float _g, float _b, float _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(int _r, int _g, int _b, int _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(uint32_t _input)
|
||||
{
|
||||
/**
|
||||
* @brief Contructor with request initialisation.
|
||||
* @param[in] _r Red color.
|
||||
* @param[in] _g Green color.
|
||||
* @param[in] _b Blue color.
|
||||
* @param[in] _a Alpha blending.
|
||||
*/
|
||||
Color(double _r, double _g, double _b, double _a=255) {
|
||||
set((float)_r, (float)_g, (float)_b, (float)_a);
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
Color(float _r, float _g, float _b, float _a=255) {
|
||||
set(_r, _g, _b, _a);
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
Color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255) {
|
||||
set(_r, _g, _b, _a);
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
Color(int _r, int _g, int _b, int _a=255) {
|
||||
set(_r, _g, _b, _a);
|
||||
};
|
||||
/**
|
||||
* @brief Constructor with the single integer input.
|
||||
* @note Not forger the alpha blending at the end
|
||||
* @param[in] _input rgba integer value : 0xrrggbbaa >> 0x99AF6DFF
|
||||
*/
|
||||
Color(uint32_t _input) {
|
||||
set((uint8_t)((_input&0xFF000000)>>24),
|
||||
(uint8_t)((_input&0x00FF0000)>>16),
|
||||
(uint8_t)((_input&0x0000FF00)>>8),
|
||||
(uint8_t)((_input&0x000000FF)));
|
||||
};
|
||||
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(std::string _input);
|
||||
~Color(void) { };
|
||||
Color<MY_TYPE>& operator=(const etk::Color<MY_TYPE>& _input)
|
||||
{
|
||||
/**
|
||||
* @brief Copy contructor or convert contructor
|
||||
* @param[in] _obj Element to copy in this new color class.
|
||||
*/
|
||||
Color(const etk::Color<float>& _obj) {
|
||||
set(_obj.r(), _obj.g(), _obj.b(), _obj.a());
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
Color(const etk::Color<uint8_t>& _obj) {
|
||||
set(_obj.r(), _obj.g(), _obj.b(), _obj.a());
|
||||
};
|
||||
/**
|
||||
* @brief String extractor constructor.
|
||||
* @param[in] _input Color string to parse. it can be : "#rrggbb", "rgb", "rrggbbaa", "rgba", "blueviolet" ...
|
||||
*/
|
||||
Color(const std::string& _input);
|
||||
/**
|
||||
* @brief Asignemement operator
|
||||
* @param[in] _input Color object to set in this class.
|
||||
* @return reference on this element.
|
||||
*/
|
||||
Color<MY_TYPE>& operator=(const etk::Color<MY_TYPE>& _input) {
|
||||
m_r = _input.m_r;
|
||||
m_g = _input.m_g;
|
||||
m_b = _input.m_b;
|
||||
m_a = _input.m_a;
|
||||
return *this;
|
||||
};
|
||||
bool operator!= (const etk::Color<MY_TYPE>& _obj) const
|
||||
{
|
||||
/**
|
||||
* @brief Different comparaison operator.
|
||||
* @param[in] _obj Color object to compare.
|
||||
* @return true This is not the same color, false otherwise.
|
||||
*/
|
||||
bool operator!= (const etk::Color<MY_TYPE>& _obj) const {
|
||||
if( m_r != _obj.m_r
|
||||
|| m_g != _obj.m_g
|
||||
|| m_b != _obj.m_b
|
||||
@ -54,8 +123,8 @@ namespace etk {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const etk::Color<MY_TYPE>& _obj) const
|
||||
{
|
||||
|
||||
bool operator== (const etk::Color<MY_TYPE>& _obj) const {
|
||||
if( m_r != _obj.m_r
|
||||
|| m_g != _obj.m_g
|
||||
|| m_b != _obj.m_b
|
||||
@ -74,32 +143,64 @@ namespace etk {
|
||||
(uint8_t)(etk_avg(0,_a,255)) );
|
||||
}
|
||||
std::string getHexString(void) const {
|
||||
return "0x" + to_string<uint32_t>(get(), std::hex);
|
||||
return "0x" + std::to_string<uint32_t>(get(), std::hex);
|
||||
};
|
||||
std::string getString(void) const {
|
||||
return "#" + to_string<uint32_t>(get(), std::hex);
|
||||
return "#" + std::to_string<uint32_t>(get(), std::hex);
|
||||
};
|
||||
/**
|
||||
* @brief Get red color.
|
||||
* @return The red color.
|
||||
*/
|
||||
MY_TYPE r(void) const {
|
||||
return m_r;
|
||||
};
|
||||
/**
|
||||
* @brief Get green color.
|
||||
* @return The green color.
|
||||
*/
|
||||
MY_TYPE g(void) const {
|
||||
return m_g;
|
||||
};
|
||||
/**
|
||||
* @brief Get blue color.
|
||||
* @return The blue color.
|
||||
*/
|
||||
MY_TYPE b(void) const {
|
||||
return m_b;
|
||||
};
|
||||
/**
|
||||
* @brief Get alpha blending.
|
||||
* @return The alpha blending.
|
||||
*/
|
||||
MY_TYPE a(void) const {
|
||||
return m_a;
|
||||
};
|
||||
/**
|
||||
* @brief Set red color.
|
||||
* @param[in] _r The red color to set.
|
||||
*/
|
||||
void setR(MY_TYPE _r) {
|
||||
m_r=_r;
|
||||
};
|
||||
/**
|
||||
* @brief Set green color.
|
||||
* @param[in] _g The green color to set.
|
||||
*/
|
||||
void setG(MY_TYPE _g) {
|
||||
m_g=_g;
|
||||
};
|
||||
/**
|
||||
* @brief Set blue color.
|
||||
* @param[in] _b The blue color to set.
|
||||
*/
|
||||
void setB(MY_TYPE _b) {
|
||||
m_b=_b;
|
||||
};
|
||||
/**
|
||||
* @brief Set alpha blending.
|
||||
* @param[in] _a The alpha blending to set.
|
||||
*/
|
||||
void setA(MY_TYPE _a) {
|
||||
m_a=_a;
|
||||
};
|
||||
|
95
etk/Hash.h
95
etk/Hash.h
@ -10,39 +10,79 @@
|
||||
#define __ETK_HACH_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <vector>
|
||||
#include <etk/UString.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "etk::Hash"
|
||||
|
||||
|
||||
namespace etk {
|
||||
/**
|
||||
* @brief internel data of the [class[etk::hash]] class, it contain
|
||||
* the name and the value of the hash vector.
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class MY_TYPE> class HashData {
|
||||
public:
|
||||
std::string m_key; //!< name of the current hash
|
||||
MY_TYPE m_value; //!< data of the current Hash
|
||||
/**
|
||||
* @brief Constructor of the data for hash table.
|
||||
* @param[in] _key name of the hash table.
|
||||
* @param[in] _val Value of the hash element.
|
||||
*/
|
||||
HashData(const std::string& _key, const MY_TYPE& _val) :
|
||||
m_key(_key),
|
||||
m_value(_val) {
|
||||
// nothing to do ...
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hash table tamplate is a simple classical hash interface.
|
||||
* A hash table is a equivalent of the dictionary in python, this is a
|
||||
* simple interfaace between a name and a value:
|
||||
* :** "name" : 19
|
||||
* :** "name 2" : 99
|
||||
*
|
||||
* [note]The name is unique and the value is what you want.[/note]
|
||||
*
|
||||
* A simple example of use:
|
||||
* [code style=c++]
|
||||
* // Create a integer hash table
|
||||
* Hash<int> myValue;
|
||||
* // add some element (note add and set is the same function)
|
||||
* myValue.add("example", 98837);
|
||||
* myValue.add("plop", 88);
|
||||
* // Display an element:
|
||||
* printf("my value is : %d", myValue["example"]);
|
||||
* // Change value of an element:
|
||||
* myValue.set("example", 99);
|
||||
* // Remove an element:
|
||||
* myValue.remove("plop");
|
||||
* //Clean all the table:
|
||||
* myValue.clear();
|
||||
* [/code]
|
||||
*/
|
||||
template<class MY_TYPE> class Hash {
|
||||
private:
|
||||
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:
|
||||
/**
|
||||
* @brief Contructor of the Hach table.
|
||||
* @param[in] _count Number ob basic elent in the vector.
|
||||
*/
|
||||
Hash(int32_t _count=0) :
|
||||
m_data(_count) {
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
/**
|
||||
* @brief Destructor of the Hash table(clear all element in the table)
|
||||
*/
|
||||
~Hash(void) {
|
||||
clear();
|
||||
}
|
||||
/**
|
||||
* @brief Remove all entry in the Hash table
|
||||
* @brief Remove all entry in the Hash table.
|
||||
* @note It does not delete pointer if your value is a pointer type...
|
||||
*/
|
||||
void clear(void) {
|
||||
for (size_t iii=0; iii<m_data.size(); iii++) {
|
||||
@ -71,7 +111,7 @@ namespace etk {
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
*@brief Check if an element exist or not
|
||||
* @brief Check if an element exist or not
|
||||
* @param[in] _key Name of the hash requested
|
||||
* @return true if the element exist
|
||||
*/
|
||||
@ -86,7 +126,7 @@ namespace etk {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @brief Get a current element in the vector
|
||||
* @brief Get a current element in the hash table, with his name.
|
||||
* @param[in] _key Name of the hash requested
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
@ -107,10 +147,18 @@ namespace etk {
|
||||
MY_TYPE& operator[] (const std::string& _key) {
|
||||
return get(_key);
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
const MY_TYPE& operator[] (const std::string& _key) const {
|
||||
return get(_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add an element OR set an element value
|
||||
* @note add and set is the same function.
|
||||
* @param[in] _key Name of the value to set in the hash table.
|
||||
* @param[in] _value Value to set in the hash table.
|
||||
*/
|
||||
void add(const std::string& _key, const MY_TYPE& _value) {
|
||||
int64_t elementId = getId(_key);
|
||||
if (elementId <0) {
|
||||
@ -124,9 +172,16 @@ namespace etk {
|
||||
}
|
||||
m_data[elementId]->m_value = _value;
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void set(const std::string& _key, const MY_TYPE& _value) {
|
||||
add(_key, _value);
|
||||
}
|
||||
/**
|
||||
* @brief Remove an element in the hash table.
|
||||
* @param[in] _key Name of the element to remove.
|
||||
*/
|
||||
void remove(const std::string& _key) {
|
||||
int64_t elementId = getId(_key);
|
||||
if (elementId <0) {
|
||||
@ -144,12 +199,26 @@ namespace etk {
|
||||
int32_t size(void) const {
|
||||
return m_data.size();
|
||||
}
|
||||
/**
|
||||
* @brief get an element with his id.
|
||||
* @param[in] _pos Position on the element in the hash table.
|
||||
* @return requested element at this position.
|
||||
* @note this is a dangerous use of the hash table. Maybe you will use a simple vector.
|
||||
*/
|
||||
MY_TYPE& operator[] (size_t _pos) {
|
||||
return getValue(_pos);
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
const MY_TYPE& operator[] (size_t _pos) const {
|
||||
return getValue(_pos);
|
||||
}
|
||||
/**
|
||||
* @brief Get the name of the element at a specific position.
|
||||
* @param[in] _pos Position of the element in the hash table.
|
||||
* @return name of the element (key).
|
||||
*/
|
||||
const std::string& getKey(size_t _pos) const {
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
@ -159,6 +228,11 @@ namespace etk {
|
||||
#endif
|
||||
return m_data[_pos]->m_key;
|
||||
}
|
||||
/**
|
||||
* @brief Get a value of the hash table at a specific position.
|
||||
* @param[in] _posPosition of the element in the hash table.
|
||||
* @return Value availlable at this position.
|
||||
*/
|
||||
const MY_TYPE& getValue(size_t _pos) const {
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
@ -168,6 +242,9 @@ namespace etk {
|
||||
#endif
|
||||
return m_data[_pos]->m_value;
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
MY_TYPE& getValue(size_t _pos) {
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
|
@ -1,104 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_MESSAGE_FIFO_H__
|
||||
#define __ETK_MESSAGE_FIFO_H__
|
||||
|
||||
#include <etk/os/Mutex.h>
|
||||
#include <etk/os/Semaphore.h>
|
||||
#include <vector>
|
||||
|
||||
namespace etk
|
||||
{
|
||||
template<class MY_TYPE=int32_t> class MessageFifo
|
||||
{
|
||||
private :
|
||||
etk::Mutex m_mutex;
|
||||
etk::Semaphore m_semaphore;
|
||||
std::vector<MY_TYPE> m_data;
|
||||
public :
|
||||
MessageFifo(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
};
|
||||
~MessageFifo(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
};
|
||||
|
||||
bool wait(MY_TYPE &_data)
|
||||
{
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
m_semaphore.wait();
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.erase(m_data.begin());
|
||||
// remove lock
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs)
|
||||
{
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
if (false == m_semaphore.wait(_timeOutInUs)) {
|
||||
return false;
|
||||
}
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.erase(0);
|
||||
// remove lock
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
int32_t count(void)
|
||||
{
|
||||
m_mutex.lock();
|
||||
int32_t nbElement = m_data.size();
|
||||
m_mutex.unLock();
|
||||
return nbElement;
|
||||
};
|
||||
void post(MY_TYPE &_data)
|
||||
{
|
||||
m_mutex.lock();
|
||||
m_data.push_back(_data);
|
||||
m_semaphore.post();
|
||||
m_mutex.unLock();
|
||||
};
|
||||
void clean(void)
|
||||
{
|
||||
m_mutex.lock();
|
||||
// remove data
|
||||
m_data.clear();
|
||||
m_mutex.unLock();
|
||||
// remove semaphore
|
||||
m_semaphore.wait(0);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -10,7 +10,6 @@
|
||||
#define __ETK_NOISE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
|
||||
namespace etk {
|
||||
@ -24,8 +23,7 @@ namespace etk {
|
||||
~BaseNoise(void);
|
||||
float get(int32_t _x, int32_t _y) const;
|
||||
};
|
||||
class Noise
|
||||
{
|
||||
class Noise {
|
||||
public:
|
||||
enum noise {
|
||||
NOISE_BASE,
|
||||
@ -38,7 +36,7 @@ namespace etk {
|
||||
};
|
||||
private:
|
||||
std::vector<float> m_data;
|
||||
ivec2 m_size;
|
||||
ivec2 m_size;
|
||||
enum noise m_type;
|
||||
float smoothNoise(float _x, float _y, const etk::BaseNoise& _noise);
|
||||
float turbulence(float _x, float _y, float _size, const etk::BaseNoise& _noise);
|
||||
|
236
etk/RegExp.cpp
236
etk/RegExp.cpp
@ -13,54 +13,54 @@
|
||||
|
||||
const struct etk::convertionTable etk::constConvertionTable[] = {
|
||||
// haveBackSlash, inputValue, newValue
|
||||
{ false , '(' , 0 , REGEXP_OPCODE_PTHESE_IN},
|
||||
{ true , '(' , '(' , REGEXP_OPCODE_ERROR},
|
||||
{ false , ')' , 0 , REGEXP_OPCODE_PTHESE_OUT},
|
||||
{ true , ')' , ')' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '[' , 0 , REGEXP_OPCODE_BRACKET_IN},
|
||||
{ true , '[' , '[' , REGEXP_OPCODE_ERROR},
|
||||
{ false , ']' , 0 , REGEXP_OPCODE_BRACKET_OUT},
|
||||
{ true , ']' , ']' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '{' , 0 , REGEXP_OPCODE_BRACE_IN},
|
||||
{ true , '{' , '{' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '}' , 0 , REGEXP_OPCODE_BRACE_OUT},
|
||||
{ true , '}' , '}' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '-' , 0 , REGEXP_OPCODE_TO},
|
||||
{ true , '-' , '-' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '*' , 0 , REGEXP_OPCODE_STAR},
|
||||
{ true , '*' , '*' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '.' , 0 , REGEXP_OPCODE_DOT},
|
||||
{ true , '.' , '.' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '?' , 0 , REGEXP_OPCODE_QUESTION},
|
||||
{ true , '?' , '?' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '+' , 0 , REGEXP_OPCODE_PLUS},
|
||||
{ true , '+' , '+' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '|' , 0 , REGEXP_OPCODE_PIPE},
|
||||
{ true , '|' , '|' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '^' , 0 , REGEXP_OPCODE_START_OF_LINE},
|
||||
{ true , '^' , '^' , REGEXP_OPCODE_ERROR},
|
||||
{ false , '$' , 0 , REGEXP_OPCODE_END_OF_LINE},
|
||||
{ true , '$' , '$' , REGEXP_OPCODE_ERROR},
|
||||
{ true , 'd' , 0 , REGEXP_OPCODE_DIGIT},
|
||||
{ true , 'D' , 0 , REGEXP_OPCODE_DIGIT_NOT},
|
||||
{ true , 'l' , 0 , REGEXP_OPCODE_LETTER},
|
||||
{ true , 'L' , 0 , REGEXP_OPCODE_LETTER_NOT},
|
||||
{ true , 's' , 0 , REGEXP_OPCODE_SPACE},
|
||||
{ true , 'S' , 0 , REGEXP_OPCODE_SPACE_NOT},
|
||||
{ true , 'w' , 0 , REGEXP_OPCODE_WORD},
|
||||
{ true , 'W' , 0 , REGEXP_OPCODE_WORD_NOT},
|
||||
{ true , 'a' , '\a', REGEXP_OPCODE_ERROR},
|
||||
{ true , 'b' , '\b', REGEXP_OPCODE_ERROR},
|
||||
{ true , 'e' , 0x1B, REGEXP_OPCODE_ERROR}, // Escape character <Esc>
|
||||
{ true , 'f' , '\f', REGEXP_OPCODE_ERROR},
|
||||
{ true , 'n' , '\n', REGEXP_OPCODE_ERROR},
|
||||
{ true , 'r' , '\r', REGEXP_OPCODE_ERROR},
|
||||
{ true , 't' , '\t', REGEXP_OPCODE_ERROR},
|
||||
{ true , 'v' , '\v', REGEXP_OPCODE_ERROR},
|
||||
{ true , '\\' , '\\', REGEXP_OPCODE_ERROR},
|
||||
{ true , '&' , '&' , REGEXP_OPCODE_ERROR},
|
||||
{ true , '0' , '\0', REGEXP_OPCODE_ERROR},
|
||||
{ true , '@' , 0 , REGEXP_OPCODE_NO_CHAR},
|
||||
{ false , '(' , 0 , regexpOpcodePTheseIn},
|
||||
{ true , '(' , '(' , regexpOpcodeError},
|
||||
{ false , ')' , 0 , regexpOpcodePTheseOut},
|
||||
{ true , ')' , ')' , regexpOpcodeError},
|
||||
{ false , '[' , 0 , regexpOpcodeBracketIn},
|
||||
{ true , '[' , '[' , regexpOpcodeError},
|
||||
{ false , ']' , 0 , regexpOpcodeBracketOut},
|
||||
{ true , ']' , ']' , regexpOpcodeError},
|
||||
{ false , '{' , 0 , regexpOpcodeBracetIn},
|
||||
{ true , '{' , '{' , regexpOpcodeError},
|
||||
{ false , '}' , 0 , regexpOpcodeBracetOut},
|
||||
{ true , '}' , '}' , regexpOpcodeError},
|
||||
{ false , '-' , 0 , regexpOpcodeTo},
|
||||
{ true , '-' , '-' , regexpOpcodeError},
|
||||
{ false , '*' , 0 , regexpOpcodeStar},
|
||||
{ true , '*' , '*' , regexpOpcodeError},
|
||||
{ false , '.' , 0 , regexpOpcodeDot},
|
||||
{ true , '.' , '.' , regexpOpcodeError},
|
||||
{ false , '?' , 0 , regexpOpcodeQuestion},
|
||||
{ true , '?' , '?' , regexpOpcodeError},
|
||||
{ false , '+' , 0 , regexpOpcodePlus},
|
||||
{ true , '+' , '+' , regexpOpcodeError},
|
||||
{ false , '|' , 0 , regexpOpcodePipe},
|
||||
{ true , '|' , '|' , regexpOpcodeError},
|
||||
{ false , '^' , 0 , regexpOpcodeStartOfLine},
|
||||
{ true , '^' , '^' , regexpOpcodeError},
|
||||
{ false , '$' , 0 , regexpOpcodeEndOfLine},
|
||||
{ true , '$' , '$' , regexpOpcodeError},
|
||||
{ true , 'd' , 0 , regexpOpcodeDigit},
|
||||
{ true , 'D' , 0 , regexpOpcodeDigitNot},
|
||||
{ true , 'l' , 0 , regexpOpcodeLetter},
|
||||
{ true , 'L' , 0 , regexpOpcodeLetterNot},
|
||||
{ true , 's' , 0 , regexpOpcodeSpace},
|
||||
{ true , 'S' , 0 , regexpOpcodeSpaceNot},
|
||||
{ true , 'w' , 0 , regexpOpcodeWord},
|
||||
{ true , 'W' , 0 , regexpOpcodeWordNot},
|
||||
{ true , 'a' , '\a', regexpOpcodeError},
|
||||
{ true , 'b' , '\b', regexpOpcodeError},
|
||||
{ true , 'e' , 0x1B, regexpOpcodeError}, // Escape character <Esc>
|
||||
{ true , 'f' , '\f', regexpOpcodeError},
|
||||
{ true , 'n' , '\n', regexpOpcodeError},
|
||||
{ true , 'r' , '\r', regexpOpcodeError},
|
||||
{ true , 't' , '\t', regexpOpcodeError},
|
||||
{ true , 'v' , '\v', regexpOpcodeError},
|
||||
{ true , '\\' , '\\', regexpOpcodeError},
|
||||
{ true , '&' , '&' , regexpOpcodeError},
|
||||
{ true , '0' , '\0', regexpOpcodeError},
|
||||
{ true , '@' , 0 , regexpOpcodeNoChar},
|
||||
};
|
||||
const int64_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(struct etk::convertionTable) ;
|
||||
|
||||
@ -68,32 +68,32 @@ void etk::displayElem(const std::vector<char32_t>& _data, int64_t _start, int64_
|
||||
etk::cout<< ETK_BASH_COLOR_NORMAL;
|
||||
for (int64_t iii=_start; iii<(int64_t)_data.size() && iii<_stop ; iii++) {
|
||||
switch(_data[iii]) {
|
||||
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_BRACKET_IN: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"[" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_BRACKET_OUT: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"]" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_TO: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"-" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_BRACE_IN: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"{" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_BRACE_OUT: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"}" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_STAR: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"*" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_DOT: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"." << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_QUESTION: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"?" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_PLUS: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"+" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_PIPE: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"|" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_NO_CHAR: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"@" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_START_OF_LINE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"^" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_END_OF_LINE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"$" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_DIGIT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\d" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_DIGIT_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\D" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_LETTER: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\l" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_LETTER_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\L" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_SPACE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\s" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_SPACE_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\S" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_WORD: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\w" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case REGEXP_OPCODE_WORD_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\W" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case '\n': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\n" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case '\t': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\t" << ETK_BASH_COLOR_NORMAL; break;
|
||||
default: etk::cout<< _data[iii]; break;
|
||||
case regexpOpcodePTheseIn: etk::cout<<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodePTheseOut: etk::cout<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeBracketIn: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"[" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeBracketOut: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"]" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeTo: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"-" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeBracetIn: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"{" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeBracetOut: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"}" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeStar: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"*" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeDot: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"." << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeQuestion: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"?" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodePlus: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"+" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodePipe: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"|" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeNoChar: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"@" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeStartOfLine: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"^" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeEndOfLine: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"$" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeDigit: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\d" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeDigitNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\D" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeLetter: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\l" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeLetterNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\L" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeSpace: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\s" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeSpaceNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\S" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeWord: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\w" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case regexpOpcodeWordNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\W" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case '\n': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\n" << ETK_BASH_COLOR_NORMAL; break;
|
||||
case '\t': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\t" << ETK_BASH_COLOR_NORMAL; break;
|
||||
default: etk::cout<< _data[iii]; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,25 +129,25 @@ int64_t etk::getLenOfPTheseElem(const std::vector<char32_t>& _data, int64_t _sta
|
||||
int64_t pos = _startPos;
|
||||
int32_t nbOpen = 0;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
if( _data[pos] == REGEXP_OPCODE_PTHESE_OUT
|
||||
|| _data[pos] == REGEXP_OPCODE_PIPE) {
|
||||
if( _data[pos] == regexpOpcodePTheseOut
|
||||
|| _data[pos] == regexpOpcodePipe) {
|
||||
return 0;
|
||||
}
|
||||
// find size ...
|
||||
while (pos < (int64_t)_data.size() ) {
|
||||
if(_data[pos] == REGEXP_OPCODE_PTHESE_IN) {
|
||||
if(_data[pos] == regexpOpcodePTheseIn) {
|
||||
// find a sub section :
|
||||
nbOpen++;
|
||||
} else if(0 < nbOpen) {
|
||||
if (_data[pos] == REGEXP_OPCODE_PTHESE_OUT) {
|
||||
if (_data[pos] == regexpOpcodePTheseOut) {
|
||||
nbOpen--;
|
||||
if (0 > nbOpen) {
|
||||
TK_ERROR("Error in the (...) find element at "<< pos);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else if( _data[pos] == REGEXP_OPCODE_PTHESE_OUT
|
||||
|| _data[pos] == REGEXP_OPCODE_PIPE) {
|
||||
} else if( _data[pos] == regexpOpcodePTheseOut
|
||||
|| _data[pos] == regexpOpcodePipe) {
|
||||
// Find the end of the (...)
|
||||
// just return the size inside
|
||||
int32_t sizeInside = pos - _startPos;
|
||||
@ -166,28 +166,28 @@ int64_t etk::getLenOfPThese(const std::vector<char32_t>& _data, int64_t _startPo
|
||||
int64_t pos = _startPos;
|
||||
int32_t nbOpen = 0;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) {
|
||||
if(_data[pos]==regexpOpcodePTheseOut) {
|
||||
return 0;
|
||||
}
|
||||
if(_data[pos]!=REGEXP_OPCODE_PTHESE_IN) {
|
||||
if(_data[pos]!=regexpOpcodePTheseIn) {
|
||||
TK_ERROR(" find error in PThese");
|
||||
return 0;
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < (int64_t)_data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) {
|
||||
if(_data[pos]==regexpOpcodePTheseIn) {
|
||||
// find a sub section :
|
||||
nbOpen++;
|
||||
} else if(0 < nbOpen) {
|
||||
if (_data[pos]==REGEXP_OPCODE_PTHESE_OUT) {
|
||||
if (_data[pos]==regexpOpcodePTheseOut) {
|
||||
nbOpen--;
|
||||
if (0 > nbOpen) {
|
||||
TK_ERROR("Error in the (...) find element at "<< pos);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) {
|
||||
} else if(_data[pos]==regexpOpcodePTheseOut) {
|
||||
// Find the end of the (...)
|
||||
// just return the size inside
|
||||
int32_t sizeInside = pos - _startPos-1;
|
||||
@ -206,17 +206,17 @@ int64_t etk::getLenOfPThese(const std::vector<char32_t>& _data, int64_t _startPo
|
||||
int64_t etk::getLenOfBracket(const std::vector<char32_t>& _data, int64_t _startPos) {
|
||||
int64_t pos = _startPos;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) {
|
||||
if(_data[pos]==regexpOpcodeBracketOut) {
|
||||
return 0;
|
||||
}
|
||||
if(_data[pos] != REGEXP_OPCODE_BRACKET_IN) {
|
||||
if(_data[pos] != regexpOpcodeBracketIn) {
|
||||
TK_ERROR("find no {...");
|
||||
return 0;
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < (int64_t)_data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) {
|
||||
if(_data[pos]==regexpOpcodeBracketOut) {
|
||||
// Find the end of the [...]
|
||||
// just return the size inside
|
||||
int32_t sizeInside = pos - _startPos -1 ;
|
||||
@ -225,7 +225,7 @@ int64_t etk::getLenOfBracket(const std::vector<char32_t>& _data, int64_t _startP
|
||||
return 0;
|
||||
}
|
||||
return sizeInside;
|
||||
} else if( _data[pos] != REGEXP_OPCODE_TO
|
||||
} else if( _data[pos] != regexpOpcodeTo
|
||||
&& _data[pos] > 0xFF ) {
|
||||
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos] << "'");
|
||||
return 0;
|
||||
@ -239,17 +239,17 @@ int64_t etk::getLenOfBracket(const std::vector<char32_t>& _data, int64_t _startP
|
||||
int64_t etk::getLenOfBrace(const std::vector<char32_t>& _data, int64_t _startPos) {
|
||||
int32_t pos = _startPos;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) {
|
||||
if(_data[pos]==regexpOpcodeBracetOut) {
|
||||
return 0;
|
||||
}
|
||||
if(_data[pos]!=REGEXP_OPCODE_BRACE_IN) {
|
||||
if(_data[pos]!=regexpOpcodeBracetIn) {
|
||||
TK_ERROR(" did not find brace IN { ");
|
||||
return 0;
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < (int64_t)_data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) {
|
||||
if(_data[pos]==regexpOpcodeBracetOut) {
|
||||
// Find the end of the [...]
|
||||
// just return the size inside
|
||||
int32_t sizeInside = pos - _startPos -1 ;
|
||||
@ -275,28 +275,28 @@ int64_t etk::getLenOfNormal(const std::vector<char32_t>& _data, int64_t _startPo
|
||||
// find size ...
|
||||
while (pos < (int64_t)_data.size() ) {
|
||||
switch(_data[pos]) {
|
||||
case REGEXP_OPCODE_PTHESE_IN:
|
||||
case REGEXP_OPCODE_PTHESE_OUT:
|
||||
case REGEXP_OPCODE_BRACKET_IN:
|
||||
case REGEXP_OPCODE_BRACKET_OUT:
|
||||
case REGEXP_OPCODE_BRACE_IN:
|
||||
case REGEXP_OPCODE_BRACE_OUT:
|
||||
case REGEXP_OPCODE_TO:
|
||||
case REGEXP_OPCODE_STAR:
|
||||
case REGEXP_OPCODE_DOT:
|
||||
case REGEXP_OPCODE_QUESTION:
|
||||
case REGEXP_OPCODE_PLUS:
|
||||
case REGEXP_OPCODE_PIPE:
|
||||
case REGEXP_OPCODE_START_OF_LINE:
|
||||
case REGEXP_OPCODE_END_OF_LINE:
|
||||
case REGEXP_OPCODE_DIGIT:
|
||||
case REGEXP_OPCODE_DIGIT_NOT:
|
||||
case REGEXP_OPCODE_LETTER:
|
||||
case REGEXP_OPCODE_LETTER_NOT:
|
||||
case REGEXP_OPCODE_SPACE:
|
||||
case REGEXP_OPCODE_SPACE_NOT:
|
||||
case REGEXP_OPCODE_WORD:
|
||||
case REGEXP_OPCODE_WORD_NOT:
|
||||
case regexpOpcodePTheseIn:
|
||||
case regexpOpcodePTheseOut:
|
||||
case regexpOpcodeBracketIn:
|
||||
case regexpOpcodeBracketOut:
|
||||
case regexpOpcodeBracetIn:
|
||||
case regexpOpcodeBracetOut:
|
||||
case regexpOpcodeTo:
|
||||
case regexpOpcodeStar:
|
||||
case regexpOpcodeDot:
|
||||
case regexpOpcodeQuestion:
|
||||
case regexpOpcodePlus:
|
||||
case regexpOpcodePipe:
|
||||
case regexpOpcodeStartOfLine:
|
||||
case regexpOpcodeEndOfLine:
|
||||
case regexpOpcodeDigit:
|
||||
case regexpOpcodeDigitNot:
|
||||
case regexpOpcodeLetter:
|
||||
case regexpOpcodeLetterNot:
|
||||
case regexpOpcodeSpace:
|
||||
case regexpOpcodeSpaceNot:
|
||||
case regexpOpcodeWord:
|
||||
case regexpOpcodeWordNot:
|
||||
{
|
||||
// just return the size inside
|
||||
int32_t sizeInside = pos - _startPos;
|
||||
@ -334,9 +334,9 @@ bool etk::parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_
|
||||
} if (_data[k] == '}' ) {
|
||||
SecondElement = firstElement;
|
||||
goto allIsSet;
|
||||
} else if(etk::isInteger(_data[k]) == true) {
|
||||
} else if(u32char::isInteger(_data[k]) == true) {
|
||||
firstElement *= 10;
|
||||
firstElement += etk::toInt32(_data[k]);
|
||||
firstElement += u32char::toInt(_data[k]);
|
||||
} else {
|
||||
TK_ERROR("Can not parse this element " << (char)_data[k] << " at pos " << k);
|
||||
return false;
|
||||
@ -352,9 +352,9 @@ bool etk::parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_
|
||||
return false;
|
||||
} if (_data[k] == '}') {
|
||||
goto allIsSet;
|
||||
} else if (true == etk::isInteger(_data[k])) {
|
||||
} else if (true == u32char::isInteger(_data[k])) {
|
||||
SecondElement *= 10;
|
||||
SecondElement += etk::toInt32(_data[k]);
|
||||
SecondElement += u32char::toInt(_data[k]);
|
||||
} else {
|
||||
TK_ERROR("Can not parse this element " << _data[k] << " at pos " << k);
|
||||
return false;
|
||||
|
357
etk/RegExp.h
357
etk/RegExp.h
@ -11,15 +11,43 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/UString.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#define TK_REG_EXP_DBG_MODE TK_VERBOSE
|
||||
//#define TK_REG_EXP_DBG_MODE TK_DEBUG
|
||||
|
||||
namespace etk {
|
||||
|
||||
namespace etk {
|
||||
//in the unicode section we have : [E000..F8FF] private area ==> we will store element in this area:
|
||||
// internal define to permit to have all needed system
|
||||
enum regExpPrivateSection {
|
||||
regexpOpcodePTheseIn=0xE000, /* ( */
|
||||
regexpOpcodePTheseOut,/* ) */
|
||||
regexpOpcodeBracketIn,/* [ */
|
||||
regexpOpcodeBracketOut,/* ] */
|
||||
regexpOpcodeBracetIn,/* { */
|
||||
regexpOpcodeBracetOut,/* } */
|
||||
regexpOpcodeTo,/* - */
|
||||
regexpOpcodeStar,/* * */
|
||||
regexpOpcodeDot,/* . */
|
||||
regexpOpcodeQuestion,/* ? */
|
||||
regexpOpcodePlus,/* + */
|
||||
regexpOpcodePipe,/* | */
|
||||
regexpOpcodeStartOfLine,/* ^ this is also NOT, but not manage */
|
||||
regexpOpcodeEndOfLine,/* $ */
|
||||
regexpOpcodeDigit,/* \d */
|
||||
regexpOpcodeDigitNot,/* \D */
|
||||
regexpOpcodeLetter,/* \l */
|
||||
regexpOpcodeLetterNot,/* \L */
|
||||
regexpOpcodeSpace,/* \s */
|
||||
regexpOpcodeSpaceNot,/* \S */
|
||||
regexpOpcodeWord,/* \w */
|
||||
regexpOpcodeWordNot,/* \W */
|
||||
regexpOpcodeNoChar,/* \@ */
|
||||
regexpOpcodeError, // not used
|
||||
};
|
||||
/*
|
||||
normal mode :
|
||||
(...) sub element is separate with |
|
||||
@ -45,7 +73,10 @@ multiplicity :
|
||||
{x} ==> {x, x}
|
||||
{x,y} ==> {x, y}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief convertion table of every element in a regular expression.
|
||||
* @not-in-doc
|
||||
*/
|
||||
struct convertionTable {
|
||||
bool haveBackSlash;
|
||||
char inputValue;
|
||||
@ -53,16 +84,25 @@ struct convertionTable {
|
||||
enum etk::regExpPrivateSection specialChar;
|
||||
};
|
||||
|
||||
//! @not-in-doc
|
||||
extern const struct convertionTable constConvertionTable[];
|
||||
//! @not-in-doc
|
||||
extern const int64_t constConvertionTableSize;
|
||||
|
||||
//! @not-in-doc
|
||||
void displayElem(const std::vector<char32_t>& _data, int64_t _start=0, int64_t _stop=0x7FFFFFFF);
|
||||
//! @not-in-doc
|
||||
char * levelSpace(uint32_t _level);
|
||||
//! @not-in-doc
|
||||
int64_t getLenOfPTheseElem(const std::vector<char32_t>& _data, int64_t _startPos);
|
||||
//! @not-in-doc
|
||||
int64_t getLenOfPThese(const std::vector<char32_t>& _data, int64_t _startPos);
|
||||
//! @not-in-doc
|
||||
int64_t getLenOfBracket(const std::vector<char32_t>& _data, int64_t _startPos);
|
||||
//! @not-in-doc
|
||||
int64_t getLenOfBrace(const std::vector<char32_t>& _data, int64_t _startPos);
|
||||
//! @not-in-doc
|
||||
int64_t getLenOfNormal(const std::vector<char32_t>& _data, int64_t _startPos);
|
||||
//! @not-in-doc
|
||||
bool parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _max);
|
||||
|
||||
|
||||
@ -70,7 +110,8 @@ bool parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _m
|
||||
#define __class__ "etk::RegExpNode"
|
||||
|
||||
/**
|
||||
* @brief Node Elements for every-one
|
||||
* @brief Node Elements for every-one
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNode {
|
||||
protected :
|
||||
@ -87,12 +128,10 @@ template<class CLASS_TYPE> class RegExpNode {
|
||||
m_multipleMax(1) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~RegExpNode(void) { };
|
||||
|
||||
/**
|
||||
* @brief Generate the regular expression with the current "converted string"
|
||||
* @param[in] _data Property of the regexp
|
||||
@ -101,7 +140,6 @@ template<class CLASS_TYPE> class RegExpNode {
|
||||
virtual int32_t generate(const std::vector<char32_t>& _data) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Parse the current node
|
||||
* @param[in] _data Data to parse (start pointer / or class that have access with operator[] )
|
||||
@ -133,18 +171,22 @@ template<class CLASS_TYPE> class RegExpNode {
|
||||
* @brief Get the minimum multiplicity.
|
||||
* @return The minimum appear availlable.
|
||||
*/
|
||||
uint32_t getMultMin(void) const { return m_multipleMin; };
|
||||
uint32_t getMultMin(void) const {
|
||||
return m_multipleMin;
|
||||
};
|
||||
/**
|
||||
* @brief Get the maximum multiplicity.
|
||||
* @return The maximum appear availlable.
|
||||
*/
|
||||
uint32_t getMultMax(void) const { return m_multipleMax; };
|
||||
uint32_t getMultMax(void) const {
|
||||
return m_multipleMax;
|
||||
};
|
||||
};
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeValue"
|
||||
|
||||
template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE> {
|
||||
template<class CLASS_TYPE> class RegExpNodeValue : public etk::RegExpNode<CLASS_TYPE> {
|
||||
protected :
|
||||
// SubNodes :
|
||||
std::vector<char32_t> m_data;
|
||||
@ -223,22 +265,22 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeBracket"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYPE> {
|
||||
protected :
|
||||
// SubNodes :
|
||||
std::vector<char32_t> m_data;
|
||||
public :
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodeBracket(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeBracket(void) { };
|
||||
|
||||
int32_t generate(const std::vector<char32_t>& _data) {
|
||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||
TK_REG_EXP_DBG_MODE("Request Parse [...] data="; displayElem(_data););
|
||||
@ -248,7 +290,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
|
||||
bool multipleElement = false;
|
||||
//
|
||||
for (int32_t kkk=0; kkk<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); kkk++) {
|
||||
if (RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == REGEXP_OPCODE_TO && multipleElement == true) {
|
||||
if (RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == regexpOpcodeTo && multipleElement == true) {
|
||||
TK_ERROR("Can not have 2 consecutive - in [...]");
|
||||
return 0;
|
||||
} else if (multipleElement == true) {
|
||||
@ -257,7 +299,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
|
||||
m_data.push_back(jjj);
|
||||
}
|
||||
multipleElement = false;
|
||||
} else if(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == REGEXP_OPCODE_TO) {
|
||||
} else if(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk] == regexpOpcodeTo) {
|
||||
multipleElement = true;
|
||||
} else {
|
||||
lastElement = RegExpNode<CLASS_TYPE>::m_RegExpData[kkk];
|
||||
@ -271,7 +313,6 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
|
||||
}
|
||||
return _data.size();
|
||||
};
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : [...]{" << RegExpNode<CLASS_TYPE>::m_multipleMin
|
||||
@ -305,7 +346,6 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@[...]@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin
|
||||
<< "," << RegExpNode<CLASS_TYPE>::m_multipleMax
|
||||
@ -316,18 +356,19 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeDigit"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodeDigit(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeDigit(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : Digit{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "} : "<< _data[_currentPos] << " lenMax=" << _lenMax);
|
||||
@ -357,7 +398,6 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE>
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Digit@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -368,18 +408,19 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE>
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeDigitNot"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeDigitNot : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodeDigitNot(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeDigitNot(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : DigitNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -405,27 +446,26 @@ template<class CLASS_TYPE> class RegExpNodeDigitNot : public RegExpNode<CLASS_TY
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@DigitNot@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
||||
};
|
||||
};
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeLetter"
|
||||
#define __class__ "etk::RegExpNodeLetter"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodeLetter(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeLetter(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : Letter{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -453,7 +493,6 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Letter@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -464,6 +503,9 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeLetterNot"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -474,7 +516,6 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeLetterNot(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : LetterNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -502,7 +543,6 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@LetterNot@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -511,8 +551,11 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
|
||||
};
|
||||
};
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeWhiteSpace"
|
||||
#define __class__ "etk::RegExpNodeWhiteSpace"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -523,7 +566,6 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeWhiteSpace(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : Space{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -553,7 +595,6 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Space@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -564,6 +605,9 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeWhiteSpaceNot"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -574,7 +618,6 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeWhiteSpaceNot(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : SpaceNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -604,7 +647,6 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@SpaceNot@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -615,6 +657,9 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeWordChar"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -625,7 +670,6 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TY
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeWordChar(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : Word{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -655,7 +699,6 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TY
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Word@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -676,7 +719,6 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeWordCharNot(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : WordNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -706,7 +748,6 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@WordNot@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -717,6 +758,9 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeDot"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -727,7 +771,6 @@ template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE> {
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeDot(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : '.'{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -769,6 +812,9 @@ template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE> {
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeSOL"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeSOL : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -779,14 +825,12 @@ template<class CLASS_TYPE> class RegExpNodeSOL : public RegExpNode<CLASS_TYPE> {
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeSOL(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
// TODO : ...
|
||||
TK_INFO("Parse node : SOL{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@SOL@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -798,6 +842,9 @@ template<class CLASS_TYPE> class RegExpNodeSOL : public RegExpNode<CLASS_TYPE> {
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodeEOL"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodeEOL : public RegExpNode<CLASS_TYPE> {
|
||||
public :
|
||||
/**
|
||||
@ -808,14 +855,12 @@ template<class CLASS_TYPE> class RegExpNodeEOL : public RegExpNode<CLASS_TYPE> {
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodeEOL(void) { };
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
// TODO : ...
|
||||
TK_INFO("Parse node : EOL{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
return false;
|
||||
};
|
||||
|
||||
void display(uint32_t _level) {
|
||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@EOL@ {"
|
||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||
@ -835,6 +880,9 @@ class elementPos_ts {
|
||||
|
||||
template<class CLASS_TYPE> class RegExpNodePThese;
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_TYPE> {
|
||||
protected :
|
||||
// SubNodes :
|
||||
@ -844,12 +892,10 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodePTheseElem(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodePTheseElem(void) { };
|
||||
|
||||
int32_t generate(const std::vector<char32_t>& _data) {
|
||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||
TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
||||
@ -859,8 +905,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
while (pos < RegExpNode<CLASS_TYPE>::m_RegExpData.size()) {
|
||||
tmpData.clear();
|
||||
switch (RegExpNode<CLASS_TYPE>::m_RegExpData[pos]) {
|
||||
case REGEXP_OPCODE_PTHESE_IN:
|
||||
{
|
||||
case regexpOpcodePTheseIn:{
|
||||
elementSize=getLenOfPThese(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||
for (int64_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
|
||||
tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
|
||||
@ -873,11 +918,10 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
pos += elementSize+1;
|
||||
}
|
||||
break;
|
||||
case REGEXP_OPCODE_PTHESE_OUT:
|
||||
case regexpOpcodePTheseOut:
|
||||
TK_ERROR("Impossible case : ')' " << pos);
|
||||
return false;
|
||||
case REGEXP_OPCODE_BRACKET_IN:
|
||||
{
|
||||
case regexpOpcodeBracketIn: {
|
||||
elementSize=getLenOfBracket(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||
for (int64_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
|
||||
tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
|
||||
@ -890,11 +934,10 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
pos += elementSize+1;
|
||||
}
|
||||
break;
|
||||
case REGEXP_OPCODE_BRACKET_OUT:
|
||||
case regexpOpcodeBracketOut:
|
||||
TK_ERROR("Impossible case : ']' " << pos);
|
||||
return false;
|
||||
case REGEXP_OPCODE_BRACE_IN:
|
||||
{
|
||||
case regexpOpcodeBracetIn: {
|
||||
elementSize=getLenOfBrace(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||
for (int64_t kkk=pos+1; kkk<pos+elementSize+1; kkk++) {
|
||||
tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
|
||||
@ -908,60 +951,59 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
pos += elementSize+1;
|
||||
}
|
||||
break;
|
||||
case REGEXP_OPCODE_BRACE_OUT:
|
||||
case regexpOpcodeBracetOut:
|
||||
TK_ERROR("Impossible case : '}' " << pos);
|
||||
return false;
|
||||
case REGEXP_OPCODE_TO:
|
||||
case regexpOpcodeTo:
|
||||
TK_ERROR("Impossible case : '-' " << pos);
|
||||
return false;
|
||||
case REGEXP_OPCODE_STAR:
|
||||
case regexpOpcodeStar:
|
||||
setMultiplicityOnLastNode(0, 0x7FFFFFFF);
|
||||
break;
|
||||
case REGEXP_OPCODE_QUESTION:
|
||||
case regexpOpcodeQuestion:
|
||||
setMultiplicityOnLastNode(0, 1);
|
||||
break;
|
||||
case REGEXP_OPCODE_PLUS:
|
||||
case regexpOpcodePlus:
|
||||
setMultiplicityOnLastNode(1, 0x7FFFFFFF);
|
||||
break;
|
||||
case REGEXP_OPCODE_PIPE:
|
||||
case regexpOpcodePipe:
|
||||
TK_ERROR("Impossible case : '|' " << pos);
|
||||
return false;
|
||||
case REGEXP_OPCODE_DOT:
|
||||
case regexpOpcodeDot:
|
||||
m_subNode.push_back(new RegExpNodeDot<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_START_OF_LINE:
|
||||
case regexpOpcodeStartOfLine:
|
||||
m_subNode.push_back(new RegExpNodeSOL<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_END_OF_LINE:
|
||||
case regexpOpcodeEndOfLine:
|
||||
m_subNode.push_back(new RegExpNodeEOL<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_DIGIT:
|
||||
case regexpOpcodeDigit:
|
||||
m_subNode.push_back(new RegExpNodeDigit<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_DIGIT_NOT:
|
||||
case regexpOpcodeDigitNot:
|
||||
m_subNode.push_back(new RegExpNodeDigitNot<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_LETTER:
|
||||
case regexpOpcodeLetter:
|
||||
m_subNode.push_back(new RegExpNodeLetter<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_LETTER_NOT:
|
||||
case regexpOpcodeLetterNot:
|
||||
m_subNode.push_back(new RegExpNodeLetterNot<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_SPACE:
|
||||
case regexpOpcodeSpace:
|
||||
m_subNode.push_back(new RegExpNodeWhiteSpace<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_SPACE_NOT:
|
||||
case regexpOpcodeSpaceNot:
|
||||
m_subNode.push_back(new RegExpNodeWhiteSpaceNot<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_WORD:
|
||||
case regexpOpcodeWord:
|
||||
m_subNode.push_back(new RegExpNodeWordChar<CLASS_TYPE>());
|
||||
break;
|
||||
case REGEXP_OPCODE_WORD_NOT:
|
||||
case regexpOpcodeWordNot:
|
||||
m_subNode.push_back(new RegExpNodeWordCharNot<CLASS_TYPE>());
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
elementSize = getLenOfNormal(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||
for (int64_t kkk=pos; kkk<pos+elementSize; kkk++) {
|
||||
tmpData.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
|
||||
@ -1040,6 +1082,9 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExpNodePThese"
|
||||
|
||||
/**
|
||||
* @not-in-doc
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE> {
|
||||
protected :
|
||||
std::vector<RegExpNode<CLASS_TYPE>*> m_subNode; //!< Subnode list
|
||||
@ -1048,12 +1093,10 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
|
||||
* @brief Constructor
|
||||
*/
|
||||
RegExpNodePThese(void) { };
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~RegExpNodePThese(void) { };
|
||||
|
||||
~RegExpNodePThese(void) { }
|
||||
int32_t generate(const std::vector<char32_t>& _data) {
|
||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||
TK_REG_EXP_DBG_MODE("Request Parse (...) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
||||
@ -1083,7 +1126,6 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
|
||||
}
|
||||
return _data.size();
|
||||
};
|
||||
|
||||
virtual bool parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, int64_t& _findLen) {
|
||||
_findLen = 0;
|
||||
TK_REG_EXP_DBG_MODE("Parse node : (...){" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
|
||||
@ -1138,7 +1180,12 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
|
||||
#undef __class__
|
||||
#define __class__ "etk::RegExp"
|
||||
|
||||
// Regular expression manager
|
||||
/**
|
||||
* @brief Regular expression interface template.
|
||||
* @param[in] CLASS_TYPE Type of theclass that might be parsed. This class might have a interface : operator[] that return a char or a char32_t.
|
||||
*
|
||||
* Regular is easy to use:
|
||||
*/
|
||||
template<class CLASS_TYPE> class RegExp {
|
||||
private:
|
||||
std::u32string m_expressionRequested; //!< Regular expression parsed ...
|
||||
@ -1162,9 +1209,12 @@ template<class CLASS_TYPE> class RegExp {
|
||||
m_areaFind.start=0;
|
||||
m_areaFind.stop=0;
|
||||
if (_exp.size() != 0) {
|
||||
setRegExp(_exp);
|
||||
compile(_exp);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
RegExp(const std::string &_exp) :
|
||||
m_expressionRequested(U""),
|
||||
m_isOk(false),
|
||||
@ -1173,7 +1223,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
m_areaFind.start=0;
|
||||
m_areaFind.stop=0;
|
||||
if (_exp.size() != 0) {
|
||||
setRegExp(to_u32string(_exp));
|
||||
compile(std::to_u32string(_exp));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1188,13 +1238,16 @@ template<class CLASS_TYPE> class RegExp {
|
||||
* @brief Set a new regular expression matching
|
||||
* @param[in] _exp the new expression to search
|
||||
*/
|
||||
void setRegExp(const std::string &_exp) {
|
||||
void compile(const std::string &_exp) {
|
||||
if (_exp.size() != 0) {
|
||||
TK_REG_EXP_DBG_MODE("normal string parse : '" << _exp << "'");
|
||||
setRegExp(to_u32string(_exp));
|
||||
compile(std::to_u32string(_exp));
|
||||
}
|
||||
}
|
||||
void setRegExp(const std::u32string &_regexp) {
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void compile(const std::u32string &_regexp) {
|
||||
m_expressionRequested = _regexp;
|
||||
std::vector<char32_t> tmpExp;
|
||||
|
||||
@ -1300,7 +1353,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
|
||||
TK_REG_EXP_DBG_MODE("Main element :"; displayElem(tmpExp); );
|
||||
if ( tmpExp.size()>0
|
||||
&& tmpExp[0] == REGEXP_OPCODE_NO_CHAR)
|
||||
&& tmpExp[0] == regexpOpcodeNoChar)
|
||||
{
|
||||
//TK_DEBUG("=> must not begin with char");
|
||||
m_notBeginWithChar = true;
|
||||
@ -1308,7 +1361,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
tmpExp.erase(tmpExp.begin());
|
||||
}
|
||||
if ( tmpExp.size()>0
|
||||
&& tmpExp[tmpExp.size()-1] == REGEXP_OPCODE_NO_CHAR)
|
||||
&& tmpExp[tmpExp.size()-1] == regexpOpcodeNoChar)
|
||||
{
|
||||
//TK_DEBUG("=> must not end with char");
|
||||
m_notEndWithChar = true;
|
||||
@ -1334,6 +1387,9 @@ template<class CLASS_TYPE> class RegExp {
|
||||
std::string getRegExp(void) const {
|
||||
return to_u8string(m_expressionRequested);
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
const std::u32string& getURegExp(void) const {
|
||||
return m_expressionRequested;
|
||||
};
|
||||
@ -1349,17 +1405,17 @@ template<class CLASS_TYPE> class RegExp {
|
||||
// process the regular expression
|
||||
|
||||
/**
|
||||
* @brief process the seach of the regular expression in a defined class type
|
||||
* @param[in] _SearchIn table of element to seach in
|
||||
* @brief Parse the defined data with the compiled regular expression.
|
||||
* @param[in] _SearchIn Data where to search the regular expression.
|
||||
* @param[in] _startPos start position to search
|
||||
* @param[in] _endPos end position to search
|
||||
* @param[in] _escapeChar special char that remove other char real type
|
||||
* @return true : find something, false otherwise
|
||||
*/
|
||||
bool process(const CLASS_TYPE& _SearchIn,
|
||||
int64_t _startPos,
|
||||
int64_t _endPos,
|
||||
char32_t _escapeChar=0) {
|
||||
bool parse(const CLASS_TYPE& _SearchIn,
|
||||
int64_t _startPos,
|
||||
int64_t _endPos,
|
||||
char32_t _escapeChar=0) {
|
||||
if (false == m_isOk) {
|
||||
return false;
|
||||
}
|
||||
@ -1525,21 +1581,30 @@ template<class CLASS_TYPE> class RegExp {
|
||||
void drawColoredRegEx(void) {
|
||||
m_exprRootNode.drawColoredRegEx();
|
||||
}
|
||||
/**
|
||||
* @brief Get decorated regular expression. This generate a [class[ewol::compositing::Text]] decoration text. Note that can be use in [class[ewol::widget::Label]].
|
||||
* @return The decorated string
|
||||
*/
|
||||
std::string getRegExDecorated(void) {
|
||||
// TODO : do it...
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in,out]
|
||||
* @return
|
||||
* @brief Check forbidden element in a regular expression element.
|
||||
* @param[in] _tmpExp The regular expression to check.
|
||||
* @param[in] _pos Position to start the check.
|
||||
* @return true The current node is correct.
|
||||
* @return false An error in parsing has appeared.
|
||||
*/
|
||||
bool checkGoodPosition(const std::vector<char32_t>& _tmpExp, int64_t& _pos) {
|
||||
char32_t curentCode = _tmpExp[_pos];
|
||||
char32_t endCode = REGEXP_OPCODE_PTHESE_OUT;
|
||||
char32_t endCode = regexpOpcodePTheseOut;
|
||||
const char *input = "(...)";
|
||||
if (curentCode == REGEXP_OPCODE_BRACKET_IN) {
|
||||
endCode = REGEXP_OPCODE_BRACKET_OUT;
|
||||
if (curentCode == regexpOpcodeBracketIn) {
|
||||
endCode = regexpOpcodeBracketOut;
|
||||
input = "[...]";
|
||||
} else if (curentCode == REGEXP_OPCODE_BRACE_IN){
|
||||
endCode = REGEXP_OPCODE_BRACE_OUT;
|
||||
} else if (curentCode == regexpOpcodeBracetIn){
|
||||
endCode = regexpOpcodeBracetOut;
|
||||
input = "{x,x}";
|
||||
}
|
||||
_pos++;
|
||||
@ -1549,8 +1614,8 @@ template<class CLASS_TYPE> class RegExp {
|
||||
}
|
||||
//TK_DEBUG(" ==> Find ELEMENT : ([{");
|
||||
// case dependent :
|
||||
if( curentCode == REGEXP_OPCODE_BRACKET_IN
|
||||
|| curentCode == REGEXP_OPCODE_BRACE_IN) {
|
||||
if ( curentCode == regexpOpcodeBracketIn
|
||||
|| curentCode == regexpOpcodeBracetIn) {
|
||||
while(_pos<_tmpExp.size()) {
|
||||
//TK_DEBUG("check : " << tmpExp[pos]);
|
||||
// if we find the end :
|
||||
@ -1559,30 +1624,29 @@ template<class CLASS_TYPE> class RegExp {
|
||||
} else {
|
||||
// otherwise, we check the error in the element ...
|
||||
char *find = NULL;
|
||||
switch (_tmpExp[_pos])
|
||||
{
|
||||
case REGEXP_OPCODE_PTHESE_IN: find = (char*)"("; break;
|
||||
case REGEXP_OPCODE_BRACKET_IN: find = (char*)"["; break;
|
||||
case REGEXP_OPCODE_BRACE_IN: find = (char*)"{"; break;
|
||||
case REGEXP_OPCODE_PTHESE_OUT: find = (char*)")"; break;
|
||||
case REGEXP_OPCODE_BRACKET_OUT: find = (char*)"]"; break;
|
||||
case REGEXP_OPCODE_BRACE_OUT: find = (char*)"}"; break;
|
||||
case REGEXP_OPCODE_STAR: find = (char*)"*"; break;
|
||||
case REGEXP_OPCODE_DOT: find = (char*)"."; break;
|
||||
case REGEXP_OPCODE_QUESTION: find = (char*)"?"; break;
|
||||
case REGEXP_OPCODE_PLUS: find = (char*)"+"; break;
|
||||
case REGEXP_OPCODE_PIPE: find = (char*)"|"; break;
|
||||
case REGEXP_OPCODE_START_OF_LINE: find = (char*)"^"; break;
|
||||
case REGEXP_OPCODE_END_OF_LINE: find = (char*)"$"; break;
|
||||
case REGEXP_OPCODE_DIGIT: find = (char*)"\\d"; break;
|
||||
case REGEXP_OPCODE_DIGIT_NOT: find = (char*)"\\D"; break;
|
||||
case REGEXP_OPCODE_LETTER: find = (char*)"\\l"; break;
|
||||
case REGEXP_OPCODE_LETTER_NOT: find = (char*)"\\L"; break;
|
||||
case REGEXP_OPCODE_SPACE: find = (char*)"\\s"; break;
|
||||
case REGEXP_OPCODE_SPACE_NOT: find = (char*)"\\S"; break;
|
||||
case REGEXP_OPCODE_WORD: find = (char*)"\\w"; break;
|
||||
case REGEXP_OPCODE_WORD_NOT: find = (char*)"\\W"; break;
|
||||
case REGEXP_OPCODE_NO_CHAR: find = (char*)"\\@"; break;
|
||||
switch (_tmpExp[_pos]) {
|
||||
case regexpOpcodePTheseIn: find = (char*)"("; break;
|
||||
case regexpOpcodeBracketIn: find = (char*)"["; break;
|
||||
case regexpOpcodeBracetIn: find = (char*)"{"; break;
|
||||
case regexpOpcodePTheseOut: find = (char*)")"; break;
|
||||
case regexpOpcodeBracketOut: find = (char*)"]"; break;
|
||||
case regexpOpcodeBracetOut: find = (char*)"}"; break;
|
||||
case regexpOpcodeStar: find = (char*)"*"; break;
|
||||
case regexpOpcodeDot: find = (char*)"."; break;
|
||||
case regexpOpcodeQuestion: find = (char*)"?"; break;
|
||||
case regexpOpcodePlus: find = (char*)"+"; break;
|
||||
case regexpOpcodePipe: find = (char*)"|"; break;
|
||||
case regexpOpcodeStartOfLine: find = (char*)"^"; break;
|
||||
case regexpOpcodeEndOfLine: find = (char*)"$"; break;
|
||||
case regexpOpcodeDigit: find = (char*)"\\d"; break;
|
||||
case regexpOpcodeDigitNot: find = (char*)"\\D"; break;
|
||||
case regexpOpcodeLetter: find = (char*)"\\l"; break;
|
||||
case regexpOpcodeLetterNot: find = (char*)"\\L"; break;
|
||||
case regexpOpcodeSpace: find = (char*)"\\s"; break;
|
||||
case regexpOpcodeSpaceNot: find = (char*)"\\S"; break;
|
||||
case regexpOpcodeWord: find = (char*)"\\w"; break;
|
||||
case regexpOpcodeWordNot: find = (char*)"\\W"; break;
|
||||
case regexpOpcodeNoChar: find = (char*)"\\@"; break;
|
||||
default: break;
|
||||
}
|
||||
if (NULL != find) {
|
||||
@ -1598,16 +1662,16 @@ template<class CLASS_TYPE> class RegExp {
|
||||
if (endCode == _tmpExp[_pos]) {
|
||||
// find the last element
|
||||
return true;
|
||||
} else if ( _tmpExp[_pos] == REGEXP_OPCODE_BRACE_OUT) {
|
||||
} else if ( _tmpExp[_pos] == regexpOpcodeBracetOut) {
|
||||
TK_ERROR("find } inside a (...) without start {");
|
||||
return false;
|
||||
} else if ( _tmpExp[_pos] == REGEXP_OPCODE_BRACKET_OUT) {
|
||||
} else if ( _tmpExp[_pos] == regexpOpcodeBracketOut) {
|
||||
TK_ERROR("find ] inside a (...) without start [");
|
||||
return false;
|
||||
} else {
|
||||
if( _tmpExp[_pos] == REGEXP_OPCODE_PTHESE_IN
|
||||
|| _tmpExp[_pos] == REGEXP_OPCODE_BRACKET_IN
|
||||
|| _tmpExp[_pos] == REGEXP_OPCODE_BRACE_IN ) {
|
||||
if( _tmpExp[_pos] == regexpOpcodePTheseIn
|
||||
|| _tmpExp[_pos] == regexpOpcodeBracketIn
|
||||
|| _tmpExp[_pos] == regexpOpcodeBracetIn ) {
|
||||
if (false==checkGoodPosition(_tmpExp, _pos) ) {
|
||||
return false;
|
||||
}
|
||||
@ -1618,30 +1682,31 @@ template<class CLASS_TYPE> class RegExp {
|
||||
}
|
||||
|
||||
// we did not find the cloder . ...
|
||||
if (endCode == REGEXP_OPCODE_BRACKET_OUT) {
|
||||
if (endCode == regexpOpcodeBracketOut) {
|
||||
TK_ERROR("Missing ']' at the end");
|
||||
}
|
||||
if (endCode == REGEXP_OPCODE_BRACE_OUT) {
|
||||
if (endCode == regexpOpcodeBracetOut) {
|
||||
TK_ERROR("Missing '}' at the end");
|
||||
}
|
||||
if (endCode == REGEXP_OPCODE_PTHESE_OUT) {
|
||||
if (endCode == regexpOpcodePTheseOut) {
|
||||
TK_ERROR("Missing ')' at the end");
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param[in,out]
|
||||
* @return
|
||||
* @brief Check all the element in a regular expression ( count [],{},(),...)
|
||||
* @param[in] _tmpExp Regular expression to check.
|
||||
* @return true The regular expression is correct.
|
||||
* @return false an error occured in the regular expression.
|
||||
*/
|
||||
bool checkGoodPosition(const std::vector<char32_t>& _tmpExp) {
|
||||
int64_t pos = 0;
|
||||
while (pos < _tmpExp.size()) {
|
||||
//TK_DEBUG("check : " << tmpExp[pos]);
|
||||
if( _tmpExp[pos] == REGEXP_OPCODE_PTHESE_IN
|
||||
|| _tmpExp[pos] == REGEXP_OPCODE_BRACKET_IN
|
||||
|| _tmpExp[pos] == REGEXP_OPCODE_BRACE_IN)
|
||||
if( _tmpExp[pos] == regexpOpcodePTheseIn
|
||||
|| _tmpExp[pos] == regexpOpcodeBracketIn
|
||||
|| _tmpExp[pos] == regexpOpcodeBracetIn)
|
||||
{
|
||||
// attention the i position change inside the finction...
|
||||
if (false==checkGoodPosition(_tmpExp, pos) ) {
|
||||
@ -1650,13 +1715,13 @@ template<class CLASS_TYPE> class RegExp {
|
||||
} else {
|
||||
//TK_DEBUG(" <== Find ELEMENT : ]})");
|
||||
}
|
||||
} else if(_tmpExp[pos] == REGEXP_OPCODE_PTHESE_OUT) {
|
||||
} else if(_tmpExp[pos] == regexpOpcodePTheseOut) {
|
||||
TK_ERROR("can find ')' with no start : ')'");
|
||||
return false;
|
||||
} else if(_tmpExp[pos] == REGEXP_OPCODE_BRACKET_OUT) {
|
||||
} else if(_tmpExp[pos] == regexpOpcodeBracketOut) {
|
||||
TK_ERROR("can find ']' with no start : '['");
|
||||
return false;
|
||||
} else if(_tmpExp[pos] == REGEXP_OPCODE_BRACE_OUT) {
|
||||
} else if(_tmpExp[pos] == regexpOpcodeBracetOut) {
|
||||
TK_ERROR("can find '}' with no start : '{'");
|
||||
return false;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ etk::CCout::~CCout()
|
||||
etk::CCout& etk::CCout::operator << (char32_t _t)
|
||||
{
|
||||
char output[5];
|
||||
getUtf8(_t, output);
|
||||
u32char::convertUtf8(_t, output);
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
|
30
etk/Stream.h
30
etk/Stream.h
@ -15,10 +15,13 @@
|
||||
namespace etk {
|
||||
#define MAX_LOG_SIZE (16000)
|
||||
#define MAX_LOG_SIZE_TMP (512)
|
||||
|
||||
//! @not-in-doc
|
||||
class CEndl {};
|
||||
//! @not-in-doc
|
||||
class CStart {};
|
||||
|
||||
/**
|
||||
* @brief Generic log output system. it change automaticly from generic console to Android console.
|
||||
*/
|
||||
class CCout {
|
||||
private:
|
||||
char m_tmpChar[MAX_LOG_SIZE+1];
|
||||
@ -55,22 +58,27 @@ namespace etk {
|
||||
extern etk::CCout cout;
|
||||
extern etk::CEndl endl;
|
||||
extern etk::CStart cstart;
|
||||
|
||||
/**
|
||||
* @brief Log level is a simple list of all log availlable. This enum is used when setting a log and when user chose the level of log displayed.
|
||||
*/
|
||||
enum logLevel {
|
||||
logLevelNone,
|
||||
logLevelCritical,
|
||||
logLevelError,
|
||||
logLevelWarning,
|
||||
logLevelInfo,
|
||||
logLevelDebug,
|
||||
logLevelVerbose
|
||||
logLevelNone, //!< no display requested
|
||||
logLevelCritical, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
||||
logLevelError, //!< Display Error and critical logs
|
||||
logLevelWarning, //!< Display log critical to warning
|
||||
logLevelInfo, //!< Display log critical to information (removed in release mode)
|
||||
logLevelDebug, //!< Display log critical to debug (removed in release mode)
|
||||
logLevelVerbose //!< Display all logs (removed in release and debug mode)
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::logLevel _obj);
|
||||
|
||||
/**
|
||||
* @brief Display the current backtrace (only implemented in linux debug mode)
|
||||
* @param[in] _breakAtEnd Request an assert after displaying the backtrace.
|
||||
*/
|
||||
void displayBacktrace(bool _breakAtEnd=true);
|
||||
};
|
||||
|
||||
|
389
etk/UChar.cpp
389
etk/UChar.cpp
@ -1,389 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UChar.h>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <etk/Stream.h>
|
||||
#include <vector>
|
||||
#include <etk/Char.h>
|
||||
|
||||
const char32_t etk::UChar::Null('\0');
|
||||
const char32_t etk::UChar::Return('\n');
|
||||
const char32_t etk::UChar::CarrierReturn('\r');
|
||||
const char32_t etk::UChar::Tabulation('\t');
|
||||
const char32_t etk::UChar::Suppress((const char)127);
|
||||
const char32_t etk::UChar::Delete((const char)8);
|
||||
const char32_t etk::UChar::Space(' ');
|
||||
const char32_t etk::UChar::Escape((const char)27);
|
||||
|
||||
bool etk::isWhiteChar(char32_t _val) {
|
||||
if( _val == ' '
|
||||
|| _val == '\t'
|
||||
|| _val == '\n'
|
||||
|| _val == '\r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::isSpecialChar(char32_t _val) {
|
||||
if( _val < '0'
|
||||
|| (_val > '9' && _val < 'A')
|
||||
|| (_val > 'Z' && _val < 'a')
|
||||
|| (_val > 'z' && _val < 0xFF) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::isInteger(char32_t _val) {
|
||||
if( _val >= (uint32_t)'0'
|
||||
&& _val <= (uint32_t)'9') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t etk::toInt32(char32_t _val) {
|
||||
return _val - (uint32_t)'0';
|
||||
}
|
||||
|
||||
char32_t etk::toLower(char32_t _val) {
|
||||
if( _val>=(uint32_t)'A'
|
||||
&& _val<=(uint32_t)'Z') {
|
||||
return _val + (uint32_t)'a' - (uint32_t)'A';
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
if (_val <= 127) {
|
||||
output = _val;
|
||||
} else if (_val <= 2047) {
|
||||
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
|
||||
// input ==> -------- -------- -----222 22111111
|
||||
output = 0x0000C080;
|
||||
output+= (_val & 0x000007C0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else if (_val <= 65535) {
|
||||
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- -------- 33332222 22111111
|
||||
output = 0x00E08080;
|
||||
output+= (_val & 0x0000F000)<<4;
|
||||
output+= (_val & 0x00000FC0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else if (_val <= 1114111) {
|
||||
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- ---44433 33332222 22111111
|
||||
output = 0xF0808080;
|
||||
output+= (_val & 0x001C0000)<<6;
|
||||
output+= (_val & 0x0003F000)<<4;
|
||||
output+= (_val & 0x00000FC0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else {
|
||||
TK_ERROR("NON UTF8 caracter input...");
|
||||
return 0;
|
||||
}
|
||||
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
int8_t etk::getUtf8(char32_t _val, char _output[5]) {
|
||||
uint32_t value = getUtf8Val(_val);
|
||||
if (0xFF >= value) {
|
||||
_output[0] = (char)value;
|
||||
_output[1] = '\0';
|
||||
return 1;
|
||||
} else if (0xFFFF >= value) {
|
||||
_output[0] = (char)((value>>8) & 0x000000FF);
|
||||
_output[1] = (char)value;
|
||||
_output[2] = '\0';
|
||||
return 2;
|
||||
} else if (0xFFFFFF >= value) {
|
||||
_output[0] = (char)((value>>16) & 0x000000FF);
|
||||
_output[1] = (char)((value>>8) & 0x000000FF);
|
||||
_output[2] = (char)value;
|
||||
_output[3] = '\0';
|
||||
return 3;
|
||||
} else {
|
||||
_output[0] = (char)((value>>24) & 0x000000FF);
|
||||
_output[1] = (char)((value>>16) & 0x000000FF);
|
||||
_output[2] = (char)((value>>8) & 0x000000FF);
|
||||
_output[3] = (char)value;
|
||||
_output[4] = '\0';
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t sizeElement(const char* _data, int32_t _lenMax)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t etk::UChar::theoricUTF8Len(const char _input) {
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
return 1;
|
||||
}
|
||||
if((_input&0xE0) == 0xC0) {
|
||||
return 2;
|
||||
}
|
||||
if((_input&0xF0) == 0xE0) {
|
||||
return 3;
|
||||
}
|
||||
if((_input&0xF8) == 0xF0) {
|
||||
return 4;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool etk::UChar::theoricUTF8First(const char _input) {
|
||||
// When started with the bit 0 then the size is signle element.
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
return true;
|
||||
}
|
||||
// for multiple element size, we just need to check the second element (might be != 1)
|
||||
if((_input&0x40) == 0x40 ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
|
||||
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();
|
||||
if (0xFF >= value) {
|
||||
ret.PushBack((char)value);
|
||||
} else if (0xFFFF >= value) {
|
||||
ret.PushBack((char)((value>>8) & 0x000000FF));
|
||||
ret.PushBack((char)value);
|
||||
} else if (0xFFFFFF >= value) {
|
||||
ret.PushBack((char)((value>>16) & 0x000000FF));
|
||||
ret.PushBack((char)((value>>8) & 0x000000FF));
|
||||
ret.PushBack((char)value);
|
||||
} else {
|
||||
ret.PushBack((char)((value>>24) & 0x000000FF));
|
||||
ret.PushBack((char)((value>>16) & 0x000000FF));
|
||||
ret.PushBack((char)((value>>8) & 0x000000FF));
|
||||
ret.PushBack((char)value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
uint8_t sizeElement(const char* _data, int32_t _lenMax)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int8_t char32_t::setUtf8(const char* _input)
|
||||
{
|
||||
m_value = 0;
|
||||
if (NULL == _input) {
|
||||
return 0;
|
||||
}
|
||||
int32_t len = strlen(_input);
|
||||
len = sizeElement(_input, len);
|
||||
switch (len) {
|
||||
default:
|
||||
// case 0 : An error occured...
|
||||
m_value = _input[0];
|
||||
return 0;
|
||||
case 1:
|
||||
m_value = (uint8_t)(_input[0]) & 0x7F;
|
||||
return 1;
|
||||
case 2:
|
||||
m_value = (((uint8_t)_input[0]) & 0x1F)<< 6;
|
||||
m_value += ((uint8_t)_input[1]) & 0x3F;
|
||||
return 2;
|
||||
case 3:
|
||||
m_value = (((uint8_t)_input[0]) & 0x0F)<< 12;
|
||||
m_value += (((uint8_t)_input[1]) & 0x3F)<< 6;
|
||||
m_value += ((uint8_t)_input[2]) & 0x3F;
|
||||
return 3;
|
||||
case 4:
|
||||
m_value = (((uint8_t)_input[0]) & 0x07)<< 18;
|
||||
m_value += (((uint8_t)_input[1]) & 0x3F)<< 12;
|
||||
m_value += (((uint8_t)_input[2]) & 0x3F)<< 6;
|
||||
m_value += ((uint8_t)_input[3]) & 0x3F;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
112
etk/UChar.h
112
etk/UChar.h
@ -1,112 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_UNI_CHAR_H__
|
||||
#define __ETK_UNI_CHAR_H__
|
||||
|
||||
namespace etk {
|
||||
//in the unicode section we have : [E000..F8FF] private area ==> we will store element in this area:
|
||||
// internal define to permit to have all needed system
|
||||
enum regExpPrivateSection {
|
||||
REGEXP_OPCODE_PTHESE_IN=0xE000, /* ( */
|
||||
REGEXP_OPCODE_PTHESE_OUT,/* ) */
|
||||
REGEXP_OPCODE_BRACKET_IN,/* [ */
|
||||
REGEXP_OPCODE_BRACKET_OUT,/* ] */
|
||||
REGEXP_OPCODE_BRACE_IN,/* { */
|
||||
REGEXP_OPCODE_BRACE_OUT,/* } */
|
||||
REGEXP_OPCODE_TO,/* - */
|
||||
REGEXP_OPCODE_STAR,/* * */
|
||||
REGEXP_OPCODE_DOT,/* . */
|
||||
REGEXP_OPCODE_QUESTION,/* ? */
|
||||
REGEXP_OPCODE_PLUS,/* + */
|
||||
REGEXP_OPCODE_PIPE,/* | */
|
||||
REGEXP_OPCODE_START_OF_LINE,/* ^ this is also NOT, but not manage */
|
||||
REGEXP_OPCODE_END_OF_LINE,/* $ */
|
||||
REGEXP_OPCODE_DIGIT,/* \d */
|
||||
REGEXP_OPCODE_DIGIT_NOT,/* \D */
|
||||
REGEXP_OPCODE_LETTER,/* \l */
|
||||
REGEXP_OPCODE_LETTER_NOT,/* \L */
|
||||
REGEXP_OPCODE_SPACE,/* \s */
|
||||
REGEXP_OPCODE_SPACE_NOT,/* \S */
|
||||
REGEXP_OPCODE_WORD,/* \w */
|
||||
REGEXP_OPCODE_WORD_NOT,/* \W */
|
||||
REGEXP_OPCODE_NO_CHAR,/* \@ */
|
||||
REGEXP_OPCODE_ERROR, // not used
|
||||
};
|
||||
namespace UChar {
|
||||
extern const char32_t Null; //!< '\0'
|
||||
extern const char32_t Return; //!< '\n'
|
||||
extern const char32_t CarrierReturn; //!< '\r' CR
|
||||
extern const char32_t Tabulation; //!< '\t' TAB
|
||||
extern const char32_t Suppress; //!< BS (SUPPRESS)
|
||||
extern const char32_t Delete; //!< DEL
|
||||
extern const char32_t Space; //!< ' ' SPACE
|
||||
extern const char32_t Escape; //!< ESC Escape
|
||||
/**
|
||||
* @brief Get the size of an utf8 char with his first char.
|
||||
* @param[in] _input Char to parse
|
||||
* @return number of char needed
|
||||
*/
|
||||
int8_t theoricUTF8Len(const char _input);
|
||||
/**
|
||||
* @brief When parsing a string in a reverse mode, we need to know if we get the first char
|
||||
* @param[in] _input Char to parse.
|
||||
* @return true if it was the first char.
|
||||
*/
|
||||
bool theoricUTF8First(const char _input);
|
||||
};
|
||||
#if 0
|
||||
class UChar : public char32_t{
|
||||
public: // classic unicar code :
|
||||
static const UChar Null; //!< '\0'
|
||||
static const UChar Return; //!< '\n'
|
||||
static const UChar CarrierReturn; //!< '\r' CR
|
||||
static const UChar Tabulation; //!< '\t' TAB
|
||||
static const UChar Suppress; //!< BS (SUPPRESS)
|
||||
static const UChar Delete; //!< DEL
|
||||
static const UChar Space; //!< ' ' SPACE
|
||||
static const UChar Escape; //!< ESC Escape
|
||||
};
|
||||
|
||||
uint32_t get(void) const { return m_value; };
|
||||
void set(uint32_t _val) { m_value = _val; };
|
||||
|
||||
uint32_t getUtf8(void) const;
|
||||
int8_t getUtf8(char _output[5]) const;
|
||||
//std::vector<int8_t> GetUtf8(void) const;
|
||||
int8_t setUtf8(const char* _input);
|
||||
public:
|
||||
};
|
||||
#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
|
||||
|
581
etk/UString.cpp
581
etk/UString.cpp
@ -1,581 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <etk/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "std::u32string"
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::string& _obj) {
|
||||
_os << _obj.c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::u32string& _obj) {
|
||||
_os << to_u8string(_obj).c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::string to_u8string(const std::u32string& _input) {
|
||||
std::string out;
|
||||
for (size_t iii=0; iii<_input.size(); ++iii) {
|
||||
char output[10];
|
||||
etk::getUtf8(_input[iii], output);
|
||||
out += output;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::u32string to_u32string(const std::string& _input) {
|
||||
return to_u32string(_input.c_str());
|
||||
}
|
||||
std::u32string to_u32string(const char* _input) {
|
||||
if (_input == NULL) {
|
||||
return U"";
|
||||
}
|
||||
std::u32string out;
|
||||
char tmpData[20];
|
||||
int64_t pos = 0;
|
||||
int64_t inputLen = strlen(_input);
|
||||
while (pos < inputLen) {
|
||||
int32_t lenMax = inputLen - pos;
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (_input[pos+0] & 0x80) ) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if ( 2<=lenMax
|
||||
&& 0xC0 == (_input[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if ( 3<=lenMax
|
||||
&& 0xE0 == (_input[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = _input[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if ( 4<=lenMax
|
||||
&& 0xF0 == (_input[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = _input[pos+2];
|
||||
tmpData[3] = _input[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
tmpData[0] = '\0';
|
||||
pos += 1;
|
||||
}
|
||||
out += etk::setUtf8(tmpData);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// TODO : Might remove this when it will be port on STL ...
|
||||
std::u32string to_u32string(int _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(long _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(long long _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(unsigned _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(unsigned long _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(unsigned long long _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(float _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(double _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
std::u32string to_u32string(long double _val) {
|
||||
return to_u32string(std::to_string(_val));
|
||||
}
|
||||
|
||||
double stod(const std::u32string& _str, size_t* _idx) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stod(tmp, _idx);
|
||||
}
|
||||
|
||||
float stof(const std::u32string& _str, size_t* _idx) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stof(tmp, _idx);
|
||||
}
|
||||
|
||||
int stoi(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stoi(tmp, _idx, _base);
|
||||
}
|
||||
|
||||
long stol(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stol(tmp, _idx, _base);
|
||||
}
|
||||
|
||||
long double stold(const std::u32string& _str, size_t* _idx) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stold(tmp, _idx);
|
||||
}
|
||||
|
||||
long long stoll(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stoll(tmp, _idx, _base);
|
||||
}
|
||||
|
||||
unsigned long stoul(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stoul(tmp, _idx, _base);
|
||||
}
|
||||
|
||||
unsigned long long stoull(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
std::string tmp = to_u8string(_str);
|
||||
return std::stoull(tmp, _idx, _base);
|
||||
}
|
||||
|
||||
bool stobool(const std::u32string& _str) {
|
||||
if( true == compare_no_case(_str, U"true")
|
||||
|| true == compare_no_case(_str, U"enable")
|
||||
|| true == compare_no_case(_str, U"yes")
|
||||
|| _str == U"1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool stobool(const std::string& _str) {
|
||||
if( true == compare_no_case(_str, "true")
|
||||
|| true == compare_no_case(_str, "enable")
|
||||
|| true == compare_no_case(_str, "yes")
|
||||
|| _str == u8"1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string std::to_string(bool _val) {
|
||||
if (_val == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
std::string std::to_string(int _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%ld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned long long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%llu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(float _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(double _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long double _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lf", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::u32string to_u32string(bool _val) {
|
||||
if (_val == true) {
|
||||
return U"true";
|
||||
}
|
||||
return U"false";
|
||||
}
|
||||
|
||||
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val) {
|
||||
if (_val.size() != _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool compare_no_case(const std::string& _obj, const std::string& _val) {
|
||||
if (_val.size() != _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string to_lower(const std::string& _obj) {
|
||||
std::string out;
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
out.push_back(tolower(_obj[iii]));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
std::u32string to_lower(const std::u32string& _obj) {
|
||||
std::u32string out;
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
out.push_back(tolower(_obj[iii]));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string to_upper(const std::string& _obj) {
|
||||
std::string out;
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
out.push_back(toupper(_obj[iii]));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::u32string to_upper(const std::u32string& _obj) {
|
||||
std::u32string out;
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
out.push_back(toupper(_obj[iii]));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (_obj[jjj] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (_obj[jjj] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (_obj[iii] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (_obj[iii] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace) {
|
||||
std::u32string copy(_obj);
|
||||
for( size_t iii = 0;
|
||||
iii < copy.size();
|
||||
iii++) {
|
||||
if (copy[iii] == _val) {
|
||||
copy[iii] = _replace;
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::string replace(const std::string& _obj, char _val, char _replace) {
|
||||
std::string copy(_obj);
|
||||
for( size_t iii = 0;
|
||||
iii < copy.size();
|
||||
iii++) {
|
||||
if (copy[iii] == _val) {
|
||||
copy[iii] = _replace;
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::string extract_line(const std::string& _obj, int32_t _pos) {
|
||||
// search back : '\n'
|
||||
size_t startPos = _obj.rfind('\n', _pos);
|
||||
if ((int64_t)startPos == (int64_t)_pos) {
|
||||
startPos = 0;
|
||||
} else {
|
||||
startPos++;
|
||||
}
|
||||
// search forward : '\n'
|
||||
size_t stopPos = _pos;
|
||||
if (_obj[_pos] != '\n') {
|
||||
stopPos = _obj.find('\n', _pos);
|
||||
if ((int64_t)stopPos == _pos) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
}
|
||||
if (startPos == std::string::npos) {
|
||||
startPos = 0;
|
||||
} else if (startPos >= _obj.size() ) {
|
||||
return "";
|
||||
}
|
||||
if (stopPos == std::string::npos) {
|
||||
return "";
|
||||
} else if (stopPos >= _obj.size() ) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
return std::string(_obj, startPos, stopPos - startPos);
|
||||
}
|
||||
|
||||
std::u32string extract_line(const std::u32string& _obj, int32_t _pos) {
|
||||
// search back : '\n'
|
||||
size_t startPos = _obj.rfind('\n', _pos);
|
||||
if ((int64_t)startPos == _pos) {
|
||||
startPos = 0;
|
||||
} else {
|
||||
startPos++;
|
||||
}
|
||||
// search forward : '\n'
|
||||
size_t stopPos = _pos;
|
||||
if (_obj[_pos] != '\n') {
|
||||
stopPos = _obj.find('\n', _pos);
|
||||
if ((int64_t)stopPos == _pos) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
}
|
||||
if (startPos == std::string::npos) {
|
||||
startPos = 0;
|
||||
} else if (startPos >= _obj.size() ) {
|
||||
return U"";
|
||||
}
|
||||
if (stopPos == std::string::npos) {
|
||||
return U"";
|
||||
} else if (stopPos >= _obj.size() ) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
return std::u32string(_obj, startPos, stopPos - startPos);
|
||||
}
|
||||
|
||||
std::vector<std::string> string_split(const std::string& _input, char _val) {
|
||||
std::vector<std::string> list;
|
||||
size_t lastStartPos = 0;
|
||||
for(size_t iii=0; iii<_input.size(); iii++) {
|
||||
if (_input[iii]==_val) {
|
||||
list.push_back(std::string(_input, lastStartPos, iii - lastStartPos));
|
||||
lastStartPos = iii+1;
|
||||
}
|
||||
}
|
||||
if (lastStartPos<_input.size()) {
|
||||
list.push_back(std::string(_input, lastStartPos));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
double std::stod(const std::string& _str, size_t* _idx) {
|
||||
double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float std::stof(const std::string& _str, size_t* _idx) {
|
||||
float ret = 0;
|
||||
sscanf(_str.c_str(), "%f", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int std::stoi(const std::string& _str, size_t* _idx, int _base) {
|
||||
int ret = 0;
|
||||
sscanf(_str.c_str(), "%d", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long std::stol(const std::string& _str, size_t* _idx, int _base) {
|
||||
long ret = 0;
|
||||
sscanf(_str.c_str(), "%ld", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long double std::stold(const std::string& _str, size_t* _idx) {
|
||||
long double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long long std::stoll(const std::string& _str, size_t* _idx, int _base) {
|
||||
long long ret = 0;
|
||||
sscanf(_str.c_str(), "%lld", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long std::stoul(const std::string& _str, size_t* _idx, int _base) {
|
||||
unsigned long ret = 0;
|
||||
sscanf(_str.c_str(), "%lu", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long long std::stoull(const std::string& _str, size_t* _idx, int _base) {
|
||||
unsigned long long ret = 0;
|
||||
sscanf(_str.c_str(), "%llu", &ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
116
etk/UString.h
116
etk/UString.h
@ -1,116 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_USTRING_H__
|
||||
#define __ETK_USTRING_H__
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace etk {
|
||||
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::string& _obj);
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::string>& _obj);
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::u32string& _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();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
namespace std {
|
||||
std::string to_string(bool _val);
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
std::string to_string(int _val);
|
||||
std::string to_string(long _val);
|
||||
std::string to_string(long long _val);
|
||||
std::string to_string(unsigned _val);
|
||||
std::string to_string(unsigned long _val);
|
||||
std::string to_string(unsigned long long _val);
|
||||
std::string to_string(float _val);
|
||||
std::string to_string(double _val);
|
||||
std::string to_string(long double _val);
|
||||
#endif
|
||||
}
|
||||
std::u32string to_u32string(bool _val);
|
||||
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);
|
||||
|
||||
namespace std {
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
double stod(const std::string& _str, size_t* _idx = 0);
|
||||
float stof(const std::string& _str, size_t* _idx = 0);
|
||||
int stoi(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
long stol(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
long double stold(const std::string& _str, size_t* _idx = 0);
|
||||
long long stoll(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
unsigned long stoul(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
unsigned long long stoull(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
#endif
|
||||
}
|
||||
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);
|
||||
|
||||
std::string to_lower(const std::string& _obj);
|
||||
std::string to_upper(const std::string& _obj);
|
||||
|
||||
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||
|
||||
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::string extract_line(const std::string& _obj, int32_t _pos);
|
||||
std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
|
||||
|
||||
std::vector<std::string> string_split(const std::string& _input, char _val);
|
||||
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ void etk::Archive::display(void)
|
||||
|
||||
etk::Archive* etk::Archive::load(const std::string& _fileName) {
|
||||
etk::Archive* output=NULL;
|
||||
std::string tmpName = to_lower(_fileName);
|
||||
std::string tmpName = std::tolower(_fileName);
|
||||
// select the corect Loader :
|
||||
if( true == end_with(tmpName, ".zip")
|
||||
|| true == end_with(tmpName, ".apk") ) {
|
||||
|
@ -9,8 +9,7 @@
|
||||
#ifndef __ETK_ARCHIVE_H__
|
||||
#define __ETK_ARCHIVE_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <vector>
|
||||
#include <etk/types.h>
|
||||
#include <etk/Hash.h>
|
||||
|
||||
namespace etk {
|
||||
@ -20,20 +19,36 @@ namespace etk {
|
||||
private:
|
||||
int32_t m_link; //!< number of element open on this file
|
||||
public:
|
||||
void increaseRef(void) { m_link++; };
|
||||
void decreaseRef(void) { m_link--; };
|
||||
int32_t getNumberOfRef(void) const { return m_link; };
|
||||
void increaseRef(void) {
|
||||
m_link++;
|
||||
};
|
||||
void decreaseRef(void) {
|
||||
m_link--;
|
||||
};
|
||||
int32_t getNumberOfRef(void) const {
|
||||
return m_link;
|
||||
};
|
||||
private:
|
||||
int32_t m_theoricSize; //!< number of element open on this file
|
||||
public:
|
||||
int32_t getTheoricSize(void) const { return m_theoricSize; };
|
||||
int32_t getTheoricSize(void) const {
|
||||
return m_theoricSize;
|
||||
};
|
||||
private:
|
||||
std::vector<char> m_data;
|
||||
public:
|
||||
Content(int32_t _basicSize=0) : m_link(-1), m_theoricSize(_basicSize) { };
|
||||
int32_t size(void) const { return m_data.size(); };
|
||||
void* data(void) const { return (void*)&m_data[0]; };
|
||||
std::vector<char>& getDataVector(void) { return m_data; };
|
||||
Content(int32_t _basicSize=0) :
|
||||
m_link(-1),
|
||||
m_theoricSize(_basicSize) { };
|
||||
int32_t size(void) const {
|
||||
return m_data.size();
|
||||
};
|
||||
void* data(void) const {
|
||||
return (void*)&m_data[0];
|
||||
};
|
||||
std::vector<char>& getDataVector(void) {
|
||||
return m_data;
|
||||
};
|
||||
};
|
||||
public:
|
||||
Archive(const std::string& _fileName) :
|
||||
|
@ -7,13 +7,11 @@
|
||||
*/
|
||||
|
||||
#include <etk/archive/Zip.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/UString.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
etk::archive::Zip::Zip(const std::string& _fileName) :
|
||||
etk::Archive(_fileName),
|
||||
m_ctx(NULL)
|
||||
{
|
||||
etk::Archive(_fileName),
|
||||
m_ctx(NULL) {
|
||||
/* Open the zip file */
|
||||
m_ctx = unzOpen(m_fileName.c_str());
|
||||
if(!m_ctx) {
|
||||
@ -50,16 +48,14 @@ etk::archive::Zip::Zip(const std::string& _fileName) :
|
||||
}
|
||||
}
|
||||
|
||||
etk::archive::Zip::~Zip(void)
|
||||
{
|
||||
etk::archive::Zip::~Zip(void) {
|
||||
if (m_ctx!= NULL) {
|
||||
unzClose(m_ctx);
|
||||
m_ctx = NULL;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
void etk::archive::Zip::loadFile(int32_t _id)
|
||||
{
|
||||
void etk::archive::Zip::loadFile(int32_t _id) {
|
||||
std::string fileNameRequested = m_content.getKey(_id);
|
||||
TK_VERBOSE("Real load file : " << _id << " = '" << fileNameRequested << "'");
|
||||
|
||||
|
@ -6,6 +6,6 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
const char * etkLibName = "etk ";
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef __ETK_DEBUG_H__
|
||||
#define __ETK_DEBUG_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debugGeneric.h>
|
||||
|
||||
extern const char * etkLibName;
|
||||
|
@ -6,6 +6,7 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debugGeneric.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -62,9 +62,9 @@ namespace etk {
|
||||
template<> Vector2D<bool>::operator std::u32string(void) const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += to_u32string(x());
|
||||
str += std::to_u32string(x());
|
||||
str += U",";
|
||||
str += to_u32string(y());
|
||||
str += std::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -84,12 +84,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stobool(tmpStr);
|
||||
m_floats[0] = std::stob(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stobool(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stob(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0, posComa+1);
|
||||
m_floats[1] = stobool(tmpStr);
|
||||
m_floats[1] = std::stob(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -108,12 +108,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stobool(tmpStr);
|
||||
m_floats[0] = std::stob(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stobool(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stob(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0, posComa+1);
|
||||
m_floats[1] = stobool(tmpStr);
|
||||
m_floats[1] = std::stob(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -130,9 +130,9 @@ namespace etk {
|
||||
template<> Vector2D<int32_t>::operator std::u32string(void) const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += to_u32string(x());
|
||||
str += std::to_u32string(x());
|
||||
str += U",";
|
||||
str += to_u32string(y());
|
||||
str += std::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -153,12 +153,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stoi(tmpStr);
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stoi(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stoi(tmpStr);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -178,12 +178,12 @@ namespace etk {
|
||||
if (posComa == 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stoi(tmpStr);
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stoi(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stoi(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stoi(tmpStr);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -201,9 +201,9 @@ namespace etk {
|
||||
template<> Vector2D<uint32_t>::operator std::u32string(void) const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += to_u32string(x());
|
||||
str += std::to_u32string(x());
|
||||
str += U",";
|
||||
str += to_u32string(y());
|
||||
str += std::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -224,12 +224,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stoi(tmpStr);
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stoi(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stoi(tmpStr);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -249,12 +249,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stoi(tmpStr);
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stoi(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stoi(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stoi(tmpStr);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -271,9 +271,9 @@ namespace etk {
|
||||
template<> Vector2D<float>::operator std::u32string(void) const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += to_u32string(x());
|
||||
str += std::to_u32string(x());
|
||||
str += U",";
|
||||
str += to_u32string(y());
|
||||
str += std::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -293,12 +293,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stof(tmpStr);
|
||||
m_floats[0] = std::stof(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stof(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stof(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stof(tmpStr);
|
||||
m_floats[1] = std::stof(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -317,12 +317,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = stof(tmpStr);
|
||||
m_floats[0] = std::stof(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = stof(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = std::stof(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = stof(tmpStr);
|
||||
m_floats[1] = std::stof(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <etk/types.h>
|
||||
#include <etk/Stream.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/UString.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace etk {
|
||||
|
@ -8,12 +8,10 @@
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <etk/tool.h>
|
||||
#include <vector>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include "windows.h"
|
||||
#endif
|
||||
@ -645,7 +643,7 @@ void etk::FSNode::privateSetName(const std::string& _newName) {
|
||||
TK_DBG_MODE("6 : type : [" << m_typeNode << "] right :" << m_rights);
|
||||
}
|
||||
void etk::FSNode::privateSetName(const std::u32string& _newName) {
|
||||
privateSetName(to_u8string(_newName));
|
||||
privateSetName(std::to_string(_newName));
|
||||
}
|
||||
|
||||
bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||
@ -666,7 +664,7 @@ bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded =
|
||||
return true;
|
||||
}
|
||||
bool directCheckFile(std::u32string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||
return directCheckFile(to_u8string(_tmpFileNameDirect));
|
||||
return directCheckFile(std::to_string(_tmpFileNameDirect));
|
||||
}
|
||||
// Now we generate the real FS path:
|
||||
void etk::FSNode::generateFileSystemPath(void) {
|
||||
@ -974,7 +972,7 @@ bool etk::FSNode::move(const std::string& _path) {
|
||||
}
|
||||
}
|
||||
bool etk::FSNode::move(const std::u32string& _path) {
|
||||
return move(to_u8string(_path));
|
||||
return move(std::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNode::remove(void) {
|
||||
@ -1653,7 +1651,7 @@ void etk::theme::setName(const std::string& _refName, const std::string& _folder
|
||||
g_listTheme.push_back(tmpp);
|
||||
}
|
||||
void etk::theme::setName(const std::u32string& _refName, const std::u32string& _folderName) {
|
||||
setName(to_u8string(_refName), to_u8string(_folderName));
|
||||
setName(std::to_string(_refName), std::to_string(_folderName));
|
||||
}
|
||||
|
||||
// get the folder from a Reference theme
|
||||
@ -1669,7 +1667,7 @@ std::string etk::theme::getName(const std::string& _refName) {
|
||||
return _refName;
|
||||
}
|
||||
std::u32string etk::theme::getName(const std::u32string& _refName) {
|
||||
return to_u32string(getName(to_u8string(_refName)));
|
||||
return to_u32string(getName(std::to_string(_refName)));
|
||||
}
|
||||
|
||||
// get the list of all the theme folder availlable in the user Home/appl
|
||||
@ -1698,7 +1696,7 @@ bool etk::FSNodeRemove(const std::string& _path) {
|
||||
return tmpNode.remove();
|
||||
}
|
||||
bool etk::FSNodeRemove(const std::u32string& _path) {
|
||||
return FSNodeRemove(to_u8string(_path));
|
||||
return FSNodeRemove(std::to_string(_path));
|
||||
}
|
||||
|
||||
int64_t etk::FSNodeGetCount(const std::string& _path) {
|
||||
@ -1709,7 +1707,7 @@ int64_t etk::FSNodeGetCount(const std::string& _path) {
|
||||
return tmpNode.folderCount();
|
||||
}
|
||||
int64_t etk::FSNodeGetCount(const std::u32string& _path) {
|
||||
return FSNodeGetCount(to_u8string(_path));
|
||||
return FSNodeGetCount(std::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||
@ -1717,7 +1715,7 @@ bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum e
|
||||
return false;
|
||||
}
|
||||
bool etk::FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||
return FSNodeCreate(to_u8string(_path), _right, _type);
|
||||
return FSNodeCreate(std::to_string(_path), _right, _type);
|
||||
}
|
||||
|
||||
bool etk::FSNodeExist(const std::string& _path) {
|
||||
@ -1725,7 +1723,7 @@ bool etk::FSNodeExist(const std::string& _path) {
|
||||
return tmpNode.exist();
|
||||
}
|
||||
bool etk::FSNodeExist(const std::u32string& _path) {
|
||||
return FSNodeExist(to_u8string(_path));
|
||||
return FSNodeExist(std::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
||||
@ -1740,7 +1738,7 @@ bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
||||
return tmpNode.move(_path2);
|
||||
}
|
||||
bool etk::FSNodeMove(const std::u32string& _path1, const std::u32string& _path2) {
|
||||
return FSNodeMove(to_u8string(_path1), to_u8string(_path2));
|
||||
return FSNodeMove(std::to_string(_path1), std::to_string(_path2));
|
||||
}
|
||||
|
||||
etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
||||
@ -1748,7 +1746,7 @@ etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
||||
return tmpNode.getRight();
|
||||
}
|
||||
etk::FSNodeRight etk::FSNodeGetRight(const std::u32string& _path) {
|
||||
return FSNodeGetRight(to_u8string(_path));
|
||||
return FSNodeGetRight(std::to_string(_path));
|
||||
}
|
||||
|
||||
enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
||||
@ -1756,7 +1754,7 @@ enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
||||
return tmpNode.getNodeType();
|
||||
}
|
||||
enum etk::typeNode etk::FSNodeGetType(const std::u32string& _path) {
|
||||
return FSNodeGetType(to_u8string(_path));
|
||||
return FSNodeGetType(std::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
||||
@ -1764,7 +1762,7 @@ uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
||||
return tmpNode.timeCreated();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeCreated(const std::u32string& _path) {
|
||||
return FSNodeGetTimeCreated(to_u8string(_path));
|
||||
return FSNodeGetTimeCreated(std::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
||||
@ -1772,7 +1770,7 @@ uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
||||
return tmpNode.timeModified();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeModified(const std::u32string& _path) {
|
||||
return FSNodeGetTimeModified(to_u8string(_path));
|
||||
return FSNodeGetTimeModified(std::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
||||
@ -1780,7 +1778,7 @@ uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
||||
return tmpNode.timeAccessed();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeAccessed(const std::u32string& _path) {
|
||||
return FSNodeGetTimeAccessed(to_u8string(_path));
|
||||
return FSNodeGetTimeAccessed(std::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeTouch(const std::string& _path) {
|
||||
@ -1788,7 +1786,7 @@ bool etk::FSNodeTouch(const std::string& _path) {
|
||||
return tmpNode.touch();
|
||||
}
|
||||
bool etk::FSNodeTouch(const std::u32string& _path) {
|
||||
return FSNodeTouch(to_u8string(_path));
|
||||
return FSNodeTouch(std::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite) {
|
||||
@ -1810,7 +1808,7 @@ bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite)
|
||||
return tmpNode.fileClose();
|
||||
}
|
||||
bool etk::FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||
return FSNodeEcho(to_u8string(_path), to_u8string(_dataTowrite));
|
||||
return FSNodeEcho(std::to_string(_path), std::to_string(_dataTowrite));
|
||||
}
|
||||
|
||||
bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite) {
|
||||
@ -1832,7 +1830,7 @@ bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrit
|
||||
return tmpNode.fileClose();
|
||||
}
|
||||
bool etk::FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||
return FSNodeEchoAdd(to_u8string(_path), to_u8string(_dataTowrite));
|
||||
return FSNodeEchoAdd(std::to_string(_path), std::to_string(_dataTowrite));
|
||||
}
|
||||
|
||||
void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
||||
@ -1848,5 +1846,5 @@ void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
||||
}
|
||||
}
|
||||
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
||||
return FSNodeHistory(to_u8string(_path), _historyCount);
|
||||
return FSNodeHistory(std::to_string(_path), _historyCount);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef __ETK_FILE_SYSTEM_NODE_H__
|
||||
#define __ETK_FILE_SYSTEM_NODE_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
#ifdef __TARGET_OS__Android
|
||||
|
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
// Right Flags :
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
#define __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace etk
|
||||
{
|
||||
|
127
etk/os/Fifo.h
Normal file
127
etk/os/Fifo.h
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_MESSAGE_FIFO_H__
|
||||
#define __ETK_MESSAGE_FIFO_H__
|
||||
|
||||
#include <etk/os/Mutex.h>
|
||||
#include <etk/os/Semaphore.h>
|
||||
#include <vector>
|
||||
|
||||
namespace etk {
|
||||
/**
|
||||
* @brief Fifo tamplate is a simple messaged fifo element to
|
||||
* transfer data message from a thead to an other.
|
||||
* @param[in] MY_TYPE Type of the fifo message are tranfered.
|
||||
*/
|
||||
template<class MY_TYPE=int32_t> class Fifo {
|
||||
private :
|
||||
etk::Mutex m_mutex; //!< protection of the internal data.
|
||||
etk::Semaphore m_semaphore; //!< Message system to send event on an other thread.
|
||||
std::vector<MY_TYPE> m_data; //!< List of all message to send
|
||||
public :
|
||||
/**
|
||||
* @brief Create a fifo with no message.
|
||||
*/
|
||||
Fifo(void) {
|
||||
// nothing to do ...
|
||||
};
|
||||
/**
|
||||
* @brief Remove the fifo and all message inside.
|
||||
~Fifo(void) {
|
||||
// nothing to do ...
|
||||
};
|
||||
/**
|
||||
* @brief Wait a message from the other thread. (no timeout set)
|
||||
* @param[out] _data Data find in the fifo.
|
||||
* @return true A data has been find.
|
||||
* @return false No data found or closed fifo
|
||||
*/
|
||||
bool wait(MY_TYPE &_data) {
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
m_semaphore.wait();
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.erase(m_data.begin());
|
||||
// remove lock
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* @brief Wait a message from the other thread, with a specified timeout.
|
||||
* @param[out] _data keeped data from the fifo.
|
||||
* @param[in] _timeOutInUs Time-out to wait a message in the fifo. It mightbespecify in micro-second.
|
||||
* @return true We keep a massage.
|
||||
* @return false No message found while time-out appear.
|
||||
*/
|
||||
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs) {
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
if (false == m_semaphore.wait(_timeOutInUs)) {
|
||||
return false;
|
||||
}
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.erase(0);
|
||||
// remove lock
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* @brief Get the number of message in the fifo.
|
||||
* @return Number of message in the fifo.
|
||||
int32_t count(void) {
|
||||
m_mutex.lock();
|
||||
int32_t nbElement = m_data.size();
|
||||
m_mutex.unLock();
|
||||
return nbElement;
|
||||
};
|
||||
/**
|
||||
* @brief Send a message at the other thread by setting a new message in the fifo.
|
||||
* @param[in] _data New data to add at the fifo.
|
||||
*/
|
||||
void post(MY_TYPE &_data) {
|
||||
m_mutex.lock();
|
||||
m_data.push_back(_data);
|
||||
m_semaphore.post();
|
||||
m_mutex.unLock();
|
||||
};
|
||||
/**
|
||||
* @brief Remove all the message in the fifo.
|
||||
*/
|
||||
void clean(void) {
|
||||
m_mutex.lock();
|
||||
// remove data
|
||||
m_data.clear();
|
||||
m_mutex.unLock();
|
||||
// remove semaphore
|
||||
m_semaphore.wait(0);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/Mutex.h>
|
||||
#include <etk/debug.h>
|
||||
|
||||
|
@ -17,10 +17,11 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace etk
|
||||
{
|
||||
class Mutex
|
||||
{
|
||||
namespace etk {
|
||||
/**
|
||||
* @brief Generic mutex interface (OS independent)
|
||||
*/
|
||||
class Mutex {
|
||||
private:
|
||||
#ifdef __TARGET_OS__Windows
|
||||
CRITICAL_SECTION m_mutex;
|
||||
@ -28,10 +29,27 @@ namespace etk
|
||||
pthread_mutex_t m_mutex;
|
||||
#endif
|
||||
public:
|
||||
/**
|
||||
* @brief Create a new mutex
|
||||
*/
|
||||
Mutex(void);
|
||||
/**
|
||||
* @brief Destroy the mutex.
|
||||
*/
|
||||
~Mutex(void);
|
||||
/**
|
||||
* @brief Lock the mutex (Wait while the mutex is not lock)
|
||||
*/
|
||||
void lock(void);
|
||||
/**
|
||||
* @brief Try to lock the mutex (exit if mutex is already locked)
|
||||
* @return true The mutex is locked
|
||||
* @return false The mutex is already locked.
|
||||
*/
|
||||
bool tryLock(void);
|
||||
/**
|
||||
* @brief Unloc the mutex
|
||||
*/
|
||||
void unLock(void);
|
||||
};
|
||||
|
||||
|
@ -5,14 +5,12 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/Semaphore.h>
|
||||
#include <etk/debug.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax)
|
||||
{
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax) {
|
||||
// create interface mutex :
|
||||
int ret = pthread_mutex_init(&m_mutex, NULL);
|
||||
TK_ASSERT(ret == 0, "Error creating Mutex ...");
|
||||
@ -28,8 +26,7 @@ etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax)
|
||||
}
|
||||
|
||||
|
||||
etk::Semaphore::~Semaphore(void)
|
||||
{
|
||||
etk::Semaphore::~Semaphore(void) {
|
||||
// Remove condition
|
||||
int ret = pthread_cond_destroy(&m_condition);
|
||||
TK_ASSERT(ret == 0, "Error destroying Condition ...");
|
||||
@ -38,8 +35,7 @@ etk::Semaphore::~Semaphore(void)
|
||||
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
|
||||
}
|
||||
|
||||
uint32_t etk::Semaphore::getCount(void)
|
||||
{
|
||||
uint32_t etk::Semaphore::getCount(void) {
|
||||
int32_t tmpData = 0;
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
tmpData = m_data;
|
||||
@ -47,8 +43,7 @@ uint32_t etk::Semaphore::getCount(void)
|
||||
return tmpData;
|
||||
}
|
||||
|
||||
void etk::Semaphore::post(void)
|
||||
{
|
||||
void etk::Semaphore::post(void) {
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
if (m_data>=m_maximum) {
|
||||
m_data = m_maximum;
|
||||
@ -61,8 +56,7 @@ void etk::Semaphore::post(void)
|
||||
}
|
||||
|
||||
|
||||
void etk::Semaphore::wait(void)
|
||||
{
|
||||
void etk::Semaphore::wait(void) {
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
while(m_data == 0) {
|
||||
pthread_cond_wait(&m_condition, &m_mutex);
|
||||
@ -72,8 +66,7 @@ void etk::Semaphore::wait(void)
|
||||
}
|
||||
|
||||
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs)
|
||||
{
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs) {
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
if(m_data == 0) {
|
||||
struct timeval tp;
|
||||
|
@ -5,44 +5,38 @@
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/Semaphore.h>
|
||||
#include <etk/debug.h>
|
||||
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax)
|
||||
{
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax) {
|
||||
// create interface mutex :
|
||||
m_semaphore = createSemaphore(NULL, _nbBasicElement, _nbMessageMax, NULL);
|
||||
TK_ASSERT(m_semaphore != 0, "Error creating SEMAPHORE ...");
|
||||
}
|
||||
|
||||
|
||||
etk::Semaphore::~Semaphore(void)
|
||||
{
|
||||
etk::Semaphore::~Semaphore(void) {
|
||||
CloseHandle(m_semaphore);
|
||||
}
|
||||
|
||||
uint32_t etk::Semaphore::getCount(void)
|
||||
{
|
||||
uint32_t etk::Semaphore::getCount(void) {
|
||||
LONG tmpData = 0;
|
||||
releaseSemaphore(m_semaphore, 0, &tmpData);
|
||||
return tmpData;
|
||||
}
|
||||
|
||||
void etk::Semaphore::post(void)
|
||||
{
|
||||
void etk::Semaphore::post(void) {
|
||||
releaseSemaphore(m_semaphore, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
void etk::Semaphore::wait(void)
|
||||
{
|
||||
void etk::Semaphore::wait(void) {
|
||||
waitForSingleObject(m_semaphore, INFINITE);
|
||||
}
|
||||
|
||||
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs)
|
||||
{
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs) {
|
||||
DWORD result = waitForSingleObject(m_semaphore, _timeOutInUs);
|
||||
if (result == WAIT_FAILED) {
|
||||
TK_ERROR("Failed to wait for semaphore ");
|
||||
|
@ -17,10 +17,11 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace etk
|
||||
{
|
||||
class Semaphore
|
||||
{
|
||||
namespace etk {
|
||||
/**
|
||||
* @brief Generic semaphore wrapper ( it is os independent)
|
||||
*/
|
||||
class Semaphore {
|
||||
private:
|
||||
#ifdef __TARGET_OS__Windows
|
||||
HANDLE m_semaphore;
|
||||
@ -31,15 +32,38 @@ namespace etk
|
||||
uint32_t m_maximum;
|
||||
#endif
|
||||
public:
|
||||
/**
|
||||
* @brief Contruct the inithialized semaphore.
|
||||
* @param[in] _nbBasicElement Number of element basicly set in the semaphore list
|
||||
* @param[in] _nbMessageMax Nunber of maximun message that can be set.
|
||||
*/
|
||||
Semaphore(uint32_t _nbBasicElement=0, uint32_t _nbMessageMax=1);
|
||||
/**
|
||||
* @brief Generic destructor.
|
||||
*/
|
||||
~Semaphore(void);
|
||||
/**
|
||||
* @brief Get the number of element in the semaphore.
|
||||
* @return Number of stored elements.
|
||||
*/
|
||||
uint32_t getCount(void);
|
||||
/**
|
||||
* @brief Post a new semaphore
|
||||
*/
|
||||
void post(void);
|
||||
/**
|
||||
* @brief Wait for a new semaphore post by an other thread.
|
||||
*/
|
||||
void wait(void);
|
||||
// wait with a timeout in us; return true if get the semaphore
|
||||
/**
|
||||
* @brief Wait for a new semaphore post by an other thread,
|
||||
* with a timeout in micro-second.
|
||||
* @param[in] _timeOutInUs Number of micro-second to wait a semaphore.
|
||||
* @return true The function get a semaphore.
|
||||
* @return false The time-out appear or an error occured.
|
||||
*/
|
||||
bool wait(uint64_t _timeOutInUs);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
829
etk/stdTools.cpp
Normal file
829
etk/stdTools.cpp
Normal file
@ -0,0 +1,829 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "u32char"
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::string& _obj) {
|
||||
_os << _obj.c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::u32string& _obj) {
|
||||
_os << std::to_string(_obj).c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
const char32_t u32char::Null('\0');
|
||||
const char32_t u32char::Return('\n');
|
||||
const char32_t u32char::CarrierReturn('\r');
|
||||
const char32_t u32char::Tabulation('\t');
|
||||
const char32_t u32char::Suppress((const char)127);
|
||||
const char32_t u32char::Delete((const char)8);
|
||||
const char32_t u32char::Space(' ');
|
||||
const char32_t u32char::Escape((const char)27);
|
||||
|
||||
bool u32char::isWhiteChar(char32_t _val) {
|
||||
if( _val == ' '
|
||||
|| _val == '\t'
|
||||
|| _val == '\n'
|
||||
|| _val == '\r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool u32char::isSpecialChar(char32_t _val) {
|
||||
if( _val < '0'
|
||||
|| (_val > '9' && _val < 'A')
|
||||
|| (_val > 'Z' && _val < 'a')
|
||||
|| (_val > 'z' && _val < 0xFF) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool u32char::isInteger(char32_t _val) {
|
||||
if( _val >= (uint32_t)'0'
|
||||
&& _val <= (uint32_t)'9') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t u32char::toInt(char32_t _val) {
|
||||
return _val - (uint32_t)'0';
|
||||
}
|
||||
|
||||
|
||||
char32_t u32char::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;
|
||||
if (_val <= 127) {
|
||||
output = _val;
|
||||
} else if (_val <= 2047) {
|
||||
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
|
||||
// input ==> -------- -------- -----222 22111111
|
||||
output = 0x0000C080;
|
||||
output+= (_val & 0x000007C0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else if (_val <= 65535) {
|
||||
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- -------- 33332222 22111111
|
||||
output = 0x00E08080;
|
||||
output+= (_val & 0x0000F000)<<4;
|
||||
output+= (_val & 0x00000FC0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else if (_val <= 1114111) {
|
||||
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- ---44433 33332222 22111111
|
||||
output = 0xF0808080;
|
||||
output+= (_val & 0x001C0000)<<6;
|
||||
output+= (_val & 0x0003F000)<<4;
|
||||
output+= (_val & 0x00000FC0)<<2;
|
||||
output+= _val & 0x0000003F;
|
||||
} else {
|
||||
TK_ERROR("NON UTF8 caracter input...");
|
||||
return 0;
|
||||
}
|
||||
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
int8_t u32char::convertUtf8(char32_t _val, char _output[5]) {
|
||||
uint32_t value = getUtf8Val(_val);
|
||||
if (0xFF >= value) {
|
||||
_output[0] = (char)value;
|
||||
_output[1] = '\0';
|
||||
return 1;
|
||||
} else if (0xFFFF >= value) {
|
||||
_output[0] = (char)((value>>8) & 0x000000FF);
|
||||
_output[1] = (char)value;
|
||||
_output[2] = '\0';
|
||||
return 2;
|
||||
} else if (0xFFFFFF >= value) {
|
||||
_output[0] = (char)((value>>16) & 0x000000FF);
|
||||
_output[1] = (char)((value>>8) & 0x000000FF);
|
||||
_output[2] = (char)value;
|
||||
_output[3] = '\0';
|
||||
return 3;
|
||||
} else {
|
||||
_output[0] = (char)((value>>24) & 0x000000FF);
|
||||
_output[1] = (char)((value>>16) & 0x000000FF);
|
||||
_output[2] = (char)((value>>8) & 0x000000FF);
|
||||
_output[3] = (char)value;
|
||||
_output[4] = '\0';
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "utf8"
|
||||
|
||||
|
||||
static uint8_t sizeElement(const char* _data, int32_t _lenMax) {
|
||||
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 utf8::convertChar32(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;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t utf8::theoricLen(const char _input) {
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
return 1;
|
||||
}
|
||||
if((_input&0xE0) == 0xC0) {
|
||||
return 2;
|
||||
}
|
||||
if((_input&0xF0) == 0xE0) {
|
||||
return 3;
|
||||
}
|
||||
if((_input&0xF8) == 0xF0) {
|
||||
return 4;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool utf8::theoricFirst(const char _input) {
|
||||
// When started with the bit 0 then the size is signle element.
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
return true;
|
||||
}
|
||||
// for multiple element size, we just need to check the second element (might be != 1)
|
||||
if((_input&0x40) == 0x40 ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "std"
|
||||
|
||||
std::string std::to_string(const std::u32string& _input) {
|
||||
std::string out;
|
||||
for (size_t iii=0; iii<_input.size(); ++iii) {
|
||||
char output[10];
|
||||
u32char::convertUtf8(_input[iii], output);
|
||||
out += output;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::u32string std::to_u32string(const std::string& _input) {
|
||||
return std::to_u32string(_input.c_str());
|
||||
}
|
||||
std::u32string std::to_u32string(const char* _input) {
|
||||
if (_input == NULL) {
|
||||
return U"";
|
||||
}
|
||||
std::u32string out;
|
||||
char tmpData[20];
|
||||
int64_t pos = 0;
|
||||
int64_t inputLen = strlen(_input);
|
||||
while (pos < inputLen) {
|
||||
int32_t lenMax = inputLen - pos;
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (_input[pos+0] & 0x80) ) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if ( 2<=lenMax
|
||||
&& 0xC0 == (_input[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if ( 3<=lenMax
|
||||
&& 0xE0 == (_input[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = _input[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if ( 4<=lenMax
|
||||
&& 0xF0 == (_input[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input[pos+0];
|
||||
tmpData[1] = _input[pos+1];
|
||||
tmpData[2] = _input[pos+2];
|
||||
tmpData[3] = _input[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
tmpData[0] = '\0';
|
||||
pos += 1;
|
||||
}
|
||||
out += utf8::convertChar32(tmpData);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::u32string std::to_u32string(int _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(long _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(long long _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(unsigned _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(unsigned long _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(unsigned long long _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(float _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(double _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
std::u32string std::to_u32string(long double _val) {
|
||||
return std::to_u32string(std::to_string(_val));
|
||||
};
|
||||
|
||||
bool std::stob(const std::u32string& _str) {
|
||||
if( true == compare_no_case(_str, U"true")
|
||||
|| true == compare_no_case(_str, U"enable")
|
||||
|| true == compare_no_case(_str, U"yes")
|
||||
|| _str == U"1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
double std::stod(const std::u32string& _str, size_t* _idx) {
|
||||
return std::stod(std::to_string(_str), _idx);
|
||||
}
|
||||
|
||||
float std::stof(const std::u32string& _str, size_t* _idx) {
|
||||
return std::stof(std::to_string(_str), _idx);
|
||||
}
|
||||
|
||||
int std::stoi(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
return std::stoi(std::to_string(_str), _idx, _base);
|
||||
}
|
||||
|
||||
long std::stol(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
return std::stol(std::to_string(_str), _idx, _base);
|
||||
}
|
||||
|
||||
long double std::stold(const std::u32string& _str, size_t* _idx) {
|
||||
return std::stold(std::to_string(_str), _idx);
|
||||
}
|
||||
|
||||
long long std::stoll(const std::u32string& _str, size_t* _idx, int _base) {
|
||||
return std::stoll(std::to_string(_str), _idx, _base);
|
||||
}
|
||||
|
||||
unsigned long std::stoul(const std::u32string& _str, size_t* _idx, int _base ) {
|
||||
return std::stoul(std::to_string(_str), _idx, _base);
|
||||
}
|
||||
|
||||
unsigned long long std::stoull(const std::u32string& _str, size_t* _idx, int _base ) {
|
||||
return std::stoull(std::to_string(_str), _idx, _base);
|
||||
}
|
||||
|
||||
bool std::stob(const std::string& _str) {
|
||||
if( true == compare_no_case(_str, "true")
|
||||
|| true == compare_no_case(_str, "enable")
|
||||
|| true == compare_no_case(_str, "yes")
|
||||
|| _str == u8"1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string std::to_string(bool _val) {
|
||||
if (_val == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
std::string std::to_string(int _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%ld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(unsigned long long _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%llu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(float _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(double _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
std::string std::to_string(long double _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lf", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::u32string std::to_u32string(bool _val) {
|
||||
if (_val == true) {
|
||||
return U"true";
|
||||
}
|
||||
return U"false";
|
||||
}
|
||||
|
||||
bool std::compare_no_case(const std::u32string& _obj, const std::u32string& _val) {
|
||||
if (_val.size() != _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool std::compare_no_case(const std::string& _obj, const std::string& _val) {
|
||||
if (_val.size() != _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string std::tolower(std::string _obj) {
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
_obj[iii] = tolower(_obj[iii]);
|
||||
}
|
||||
return _obj;
|
||||
}
|
||||
std::u32string std::tolower(std::u32string _obj) {
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
_obj[iii] = tolower(_obj[iii]);
|
||||
}
|
||||
return _obj;
|
||||
}
|
||||
|
||||
std::string std::toupper(std::string _obj) {
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
_obj[iii] = toupper(_obj[iii]);
|
||||
}
|
||||
return _obj;
|
||||
}
|
||||
|
||||
std::u32string std::toupper(std::u32string _obj) {
|
||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||
_obj[iii] = toupper(_obj[iii]);
|
||||
}
|
||||
return _obj;
|
||||
}
|
||||
|
||||
bool std::end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (_obj[jjj] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool std::end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (_obj[jjj] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool std::start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (_obj[iii] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool std::start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||
if (_val.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (_val.size() > _obj.size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == _caseSensitive) {
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (_obj[iii] != _val[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::u32string std::replace(const std::u32string& _obj, char32_t _val, char32_t _replace) {
|
||||
std::u32string copy(_obj);
|
||||
for( size_t iii = 0;
|
||||
iii < copy.size();
|
||||
iii++) {
|
||||
if (copy[iii] == _val) {
|
||||
copy[iii] = _replace;
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::string std::replace(const std::string& _obj, char _val, char _replace) {
|
||||
std::string copy(_obj);
|
||||
for( size_t iii = 0;
|
||||
iii < copy.size();
|
||||
iii++) {
|
||||
if (copy[iii] == _val) {
|
||||
copy[iii] = _replace;
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::string std::extract_line(const std::string& _obj, int32_t _pos) {
|
||||
// search back : '\n'
|
||||
size_t startPos = _obj.rfind('\n', _pos);
|
||||
if ((int64_t)startPos == (int64_t)_pos) {
|
||||
startPos = 0;
|
||||
} else {
|
||||
startPos++;
|
||||
}
|
||||
// search forward : '\n'
|
||||
size_t stopPos = _pos;
|
||||
if (_obj[_pos] != '\n') {
|
||||
stopPos = _obj.find('\n', _pos);
|
||||
if ((int64_t)stopPos == _pos) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
}
|
||||
if (startPos == std::string::npos) {
|
||||
startPos = 0;
|
||||
} else if (startPos >= _obj.size() ) {
|
||||
return "";
|
||||
}
|
||||
if (stopPos == std::string::npos) {
|
||||
return "";
|
||||
} else if (stopPos >= _obj.size() ) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
return std::string(_obj, startPos, stopPos - startPos);
|
||||
}
|
||||
|
||||
std::u32string std::extract_line(const std::u32string& _obj, int32_t _pos) {
|
||||
// search back : '\n'
|
||||
size_t startPos = _obj.rfind('\n', _pos);
|
||||
if ((int64_t)startPos == _pos) {
|
||||
startPos = 0;
|
||||
} else {
|
||||
startPos++;
|
||||
}
|
||||
// search forward : '\n'
|
||||
size_t stopPos = _pos;
|
||||
if (_obj[_pos] != '\n') {
|
||||
stopPos = _obj.find('\n', _pos);
|
||||
if ((int64_t)stopPos == _pos) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
}
|
||||
if (startPos == std::string::npos) {
|
||||
startPos = 0;
|
||||
} else if (startPos >= _obj.size() ) {
|
||||
return U"";
|
||||
}
|
||||
if (stopPos == std::string::npos) {
|
||||
return U"";
|
||||
} else if (stopPos >= _obj.size() ) {
|
||||
stopPos = _obj.size();
|
||||
}
|
||||
return std::u32string(_obj, startPos, stopPos - startPos);
|
||||
}
|
||||
|
||||
std::vector<std::string> std::split(const std::string& _input, char _val) {
|
||||
std::vector<std::string> list;
|
||||
size_t lastStartPos = 0;
|
||||
for(size_t iii=0; iii<_input.size(); iii++) {
|
||||
if (_input[iii]==_val) {
|
||||
list.push_back(std::string(_input, lastStartPos, iii - lastStartPos));
|
||||
lastStartPos = iii+1;
|
||||
}
|
||||
}
|
||||
if (lastStartPos<_input.size()) {
|
||||
list.push_back(std::string(_input, lastStartPos));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
std::vector<std::u32string> std::split(const std::u32string& _input, char32_t _val) {
|
||||
std::vector<std::u32string> list;
|
||||
size_t lastStartPos = 0;
|
||||
for(size_t iii=0; iii<_input.size(); iii++) {
|
||||
if (_input[iii]==_val) {
|
||||
list.push_back(std::u32string(_input, lastStartPos, iii - lastStartPos));
|
||||
lastStartPos = iii+1;
|
||||
}
|
||||
}
|
||||
if (lastStartPos<_input.size()) {
|
||||
list.push_back(std::u32string(_input, lastStartPos));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
double std::stod(const std::string& _str, size_t* _idx) {
|
||||
double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float std::stof(const std::string& _str, size_t* _idx) {
|
||||
float ret = 0;
|
||||
sscanf(_str.c_str(), "%f", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int std::stoi(const std::string& _str, size_t* _idx, int _base) {
|
||||
int ret = 0;
|
||||
sscanf(_str.c_str(), "%d", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long std::stol(const std::string& _str, size_t* _idx, int _base) {
|
||||
long ret = 0;
|
||||
sscanf(_str.c_str(), "%ld", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long double std::stold(const std::string& _str, size_t* _idx) {
|
||||
long double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long long std::stoll(const std::string& _str, size_t* _idx, int _base) {
|
||||
long long ret = 0;
|
||||
sscanf(_str.c_str(), "%lld", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long std::stoul(const std::string& _str, size_t* _idx, int _base) {
|
||||
unsigned long ret = 0;
|
||||
sscanf(_str.c_str(), "%lu", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long long std::stoull(const std::string& _str, size_t* _idx, int _base) {
|
||||
unsigned long long ret = 0;
|
||||
sscanf(_str.c_str(), "%llu", &ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void std::sort(std::vector<std::string *> &_list) {
|
||||
std::vector<std::string *> tmpList(_list);
|
||||
_list.clear();
|
||||
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
||||
size_t findPos = 0;
|
||||
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (*tmpList[iii] > *_list[jjj]) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
void std::sort(std::vector<std::u32string *> &_list) {
|
||||
std::vector<std::u32string *> tmpList(_list);
|
||||
_list.clear();
|
||||
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
||||
size_t findPos = 0;
|
||||
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (*tmpList[iii] > *_list[jjj]) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
|
163
etk/stdTools.h
Normal file
163
etk/stdTools.h
Normal file
@ -0,0 +1,163 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_STD_TOOLS_H__
|
||||
#define __ETK_STD_TOOLS_H__
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace u32char {
|
||||
extern const char32_t Null; //!< '\0'
|
||||
extern const char32_t Return; //!< '\n'
|
||||
extern const char32_t CarrierReturn; //!< '\r' CR
|
||||
extern const char32_t Tabulation; //!< '\t' TAB
|
||||
extern const char32_t Suppress; //!< BS (SUPPRESS)
|
||||
extern const char32_t Delete; //!< DEL
|
||||
extern const char32_t Space; //!< ' ' SPACE
|
||||
extern const char32_t Escape; //!< ESC Escape
|
||||
/**
|
||||
* @brief check if the current 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 toInt(char32_t _val);
|
||||
|
||||
char32_t changeOrder(char32_t _val);
|
||||
int8_t convertUtf8(char32_t _val, char _output[5]);
|
||||
};
|
||||
|
||||
namespace utf8 {
|
||||
/**
|
||||
* @brief Get the size of an utf8 char with his first char.
|
||||
* @param[in] _input Char to parse
|
||||
* @return number of char needed
|
||||
*/
|
||||
int8_t theoricLen(const char _input);
|
||||
/**
|
||||
* @brief When parsing a string in a reverse mode, we need to know if we get the first char
|
||||
* @param[in] _input Char to parse.
|
||||
* @return true if it was the first char.
|
||||
*/
|
||||
bool theoricFirst(const char _input);
|
||||
|
||||
char32_t convertChar32(const char* _input);
|
||||
};
|
||||
|
||||
namespace std {
|
||||
#ifdef __TARGET_OS__MacOs
|
||||
typedef std::basic_string<char32_t> u32string;
|
||||
#endif
|
||||
std::string to_string(const std::u32string& _obj);
|
||||
std::string to_string(bool _val);
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
std::string to_string(int _val);
|
||||
std::string to_string(long _val);
|
||||
std::string to_string(long long _val);
|
||||
std::string to_string(unsigned _val);
|
||||
std::string to_string(unsigned long _val);
|
||||
std::string to_string(unsigned long long _val);
|
||||
std::string to_string(float _val);
|
||||
std::string to_string(double _val);
|
||||
std::string to_string(long double _val);
|
||||
#endif
|
||||
std::u32string to_u32string(const char* _obj);
|
||||
std::u32string to_u32string(const std::string& _obj);
|
||||
std::u32string to_u32string(bool _val);
|
||||
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);
|
||||
|
||||
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();
|
||||
}
|
||||
template<class T> std::u32string to_u32string(T t, std::ios_base & (*f)(std::ios_base&)) {
|
||||
std::ostringstream oss;
|
||||
oss << f << t;
|
||||
return std::to_u32string(oss.str());
|
||||
}
|
||||
|
||||
|
||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs))
|
||||
double stod(const std::string& _str, size_t* _idx = 0);
|
||||
float stof(const std::string& _str, size_t* _idx = 0);
|
||||
int stoi(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
long stol(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
long double stold(const std::string& _str, size_t* _idx = 0);
|
||||
long long stoll(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
unsigned long stoul(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
unsigned long long stoull(const std::string& _str, size_t* _idx = 0, int _base = 10);
|
||||
#endif
|
||||
bool stob(const std::string& _str);
|
||||
|
||||
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 stob(const std::u32string& _str);
|
||||
|
||||
|
||||
std::string tolower(std::string _obj);
|
||||
std::u32string tolower(std::u32string _obj);
|
||||
std::string toupper(std::string _obj);
|
||||
std::u32string toupper(std::u32string _obj);
|
||||
|
||||
bool compare_no_case(const std::string& _obj, const std::string& _val);
|
||||
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val);
|
||||
|
||||
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||
|
||||
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||
|
||||
std::string replace(const std::string& _obj, char _val, char _replace);
|
||||
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
|
||||
|
||||
std::string extract_line(const std::string& _obj, int32_t _pos);
|
||||
std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
|
||||
|
||||
std::vector<std::string> split(const std::string& _input, char _val);
|
||||
std::vector<std::u32string> split(const std::u32string& _input, char32_t _val);
|
||||
|
||||
void sort(std::vector<std::u32string *>& _list);
|
||||
void sort(std::vector<std::string *>& _list);
|
||||
};
|
||||
namespace etk {
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::string& _obj);
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::string>& _obj);
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::u32string& _obj);
|
||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj);
|
||||
};
|
||||
|
||||
int32_t strlen(const char32_t * _data);
|
||||
|
||||
|
||||
#endif
|
||||
|
45
etk/tool.cpp
45
etk/tool.cpp
@ -24,48 +24,3 @@ int32_t etk::tool::irand(int32_t _a, int32_t _b)
|
||||
{
|
||||
return (int32_t)(( rand()/(float)RAND_MAX ) * ((float)_b-(float)_a) + (float)_a);
|
||||
}
|
||||
|
||||
void etk::tool::sortList(std::vector<std::u32string *> &_list)
|
||||
{
|
||||
std::vector<std::u32string *> tmpList = _list;
|
||||
_list.clear();
|
||||
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
||||
|
||||
size_t findPos = 0;
|
||||
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (*tmpList[iii] > *_list[jjj]) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool etk::tool::strnCmpNoCase(const char * _input1, const char * _input2, int32_t _maxLen)
|
||||
{
|
||||
int32_t iii=0;
|
||||
while ('\0' != *_input1 && '\0' != *_input2 && iii < _maxLen) {
|
||||
char in1 = *_input1;
|
||||
char in2 = *_input2;
|
||||
if (in1 != in2) {
|
||||
if (in1 <= 'Z' && in1 >= 'A') {
|
||||
in1 = in1 - 'A' + 'a';
|
||||
}
|
||||
if (in2 <= 'Z' && in2 >= 'A') {
|
||||
in2 = in2 - 'A' + 'a';
|
||||
}
|
||||
if (in1 != in2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
iii++;
|
||||
_input1++;
|
||||
_input2++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,17 +10,11 @@
|
||||
#define __ETK_TOOL_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <vector>
|
||||
|
||||
namespace etk {
|
||||
namespace tool {
|
||||
float frand(float _a, float _b);
|
||||
int32_t irand(int32_t _a, int32_t _b);
|
||||
|
||||
void sortList(std::vector<std::u32string *>& _list);
|
||||
bool strnCmpNoCase(const char* _input1, const char* _input2, int32_t _maxLen);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -45,14 +45,7 @@
|
||||
#define etk_max(elemA,elemB) (((elemA)<(elemB)) ? (elemB) : (elemA))
|
||||
#define etk_avg(minimim,elem,maximum) (((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem))
|
||||
|
||||
#include <etk/UChar.h>
|
||||
|
||||
#include <string>
|
||||
#ifdef __TARGET_OS__MacOs
|
||||
namespace std {
|
||||
typedef std::basic_string<char32_t> u32string;
|
||||
};
|
||||
#endif
|
||||
#include <etk/stdTools.h>
|
||||
|
||||
typedef float float_t;
|
||||
#endif
|
||||
|
678
etk/unicode.cpp
678
etk/unicode.cpp
@ -1,678 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
// see : http://unicode.org/fr/charts/symbols.html#CombiningDiacriticalMarks
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/unicodeTable.h>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
|
||||
|
||||
void unicode::convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, char32_t & _output_Unicode)
|
||||
{
|
||||
switch(_inputCharset)
|
||||
{
|
||||
case charsetIso8859_1: _output_Unicode = tableIso8859_1[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_2: _output_Unicode = tableIso8859_2[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_3: _output_Unicode = tableIso8859_3[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_4: _output_Unicode = tableIso8859_4[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_5: _output_Unicode = tableIso8859_5[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_6: _output_Unicode = tableIso8859_6[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_7: _output_Unicode = tableIso8859_7[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_8: _output_Unicode = tableIso8859_8[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_9: _output_Unicode = tableIso8859_9[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_10: _output_Unicode = tableIso8859_10[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_11: _output_Unicode = tableIso8859_11[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_13: _output_Unicode = tableIso8859_13[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_14: _output_Unicode = tableIso8859_14[(uint32_t)_input_ISO&0xFF]; break;
|
||||
case charsetIso8859_15: _output_Unicode = tableIso8859_15[(uint32_t)_input_ISO&0xFF]; break;
|
||||
default :
|
||||
TK_WARNING("Unknow charset ... " << _inputCharset);
|
||||
_output_Unicode = '?';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unicode::convertUnicodeToIso(enum charset _inputCharset, const char32_t _input_Unicode, char & _output_ISO)
|
||||
{
|
||||
const uint32_t *tmpTable = NULL;
|
||||
switch(_inputCharset)
|
||||
{
|
||||
case charsetIso8859_1: tmpTable = tableIso8859_1; break;
|
||||
case charsetIso8859_2: tmpTable = tableIso8859_2; break;
|
||||
case charsetIso8859_3: tmpTable = tableIso8859_3; break;
|
||||
case charsetIso8859_4: tmpTable = tableIso8859_4; break;
|
||||
case charsetIso8859_5: tmpTable = tableIso8859_5; break;
|
||||
case charsetIso8859_6: tmpTable = tableIso8859_6; break;
|
||||
case charsetIso8859_7: tmpTable = tableIso8859_7; break;
|
||||
case charsetIso8859_8: tmpTable = tableIso8859_8; break;
|
||||
case charsetIso8859_9: tmpTable = tableIso8859_9; break;
|
||||
case charsetIso8859_10: tmpTable = tableIso8859_10; break;
|
||||
case charsetIso8859_11: tmpTable = tableIso8859_11; break;
|
||||
case charsetIso8859_13: tmpTable = tableIso8859_13; break;
|
||||
case charsetIso8859_14: tmpTable = tableIso8859_14; break;
|
||||
case charsetIso8859_15: tmpTable = tableIso8859_15; break;
|
||||
default :
|
||||
TK_WARNING("Unknow charset ... " << _inputCharset);
|
||||
_output_ISO = '?';
|
||||
return;
|
||||
}
|
||||
int32_t i;
|
||||
for (i=0; i<256; i++) {
|
||||
if (tmpTable[i] == _input_Unicode) {
|
||||
_output_ISO = (char)i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char32_t>& _output_Unicode)
|
||||
{
|
||||
_output_Unicode.clear();
|
||||
char32_t output;
|
||||
for(size_t iii=0; iii<_input_ISO.size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.push_back(output);
|
||||
}
|
||||
if (_output_Unicode.size() == 0) {
|
||||
_output_Unicode.push_back(0);
|
||||
} else if (_output_Unicode[_output_Unicode.size()-1] != 0) {
|
||||
_output_Unicode.push_back(0);
|
||||
}
|
||||
return _output_Unicode.size();
|
||||
}
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(enum charset _inputCharset, const std::vector<int8_t>& _input_ISO, std::vector<char32_t>& _output_Unicode)
|
||||
{
|
||||
_output_Unicode.clear();
|
||||
char32_t output;
|
||||
for(size_t iii=0; iii<_input_ISO.size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.push_back(output);
|
||||
}
|
||||
if (_output_Unicode.size() == 0) {
|
||||
_output_Unicode.push_back(0);
|
||||
} else if (_output_Unicode[_output_Unicode.size()-1] != 0) {
|
||||
_output_Unicode.push_back(0);
|
||||
}
|
||||
return _output_Unicode.size();
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_ISO)
|
||||
{
|
||||
/*
|
||||
_output_ISO.clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
_output_ISO.push_back(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_ISO.push_back(0);
|
||||
return _output_ISO.size();
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(enum charset _inputCharset, const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_ISO)
|
||||
{
|
||||
/*
|
||||
_output_ISO.clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
_output_ISO.push_back(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_ISO.push_back(0);
|
||||
return _output_ISO.size();
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t unicode::convertUnicodeToUtf8(const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_UTF8)
|
||||
{
|
||||
char output[10];
|
||||
|
||||
for (size_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
etk::getUtf8(_input_Unicode[iii], output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
_output_UTF8.push_back(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_UTF8.push_back('\0');
|
||||
return _output_UTF8.size()-1;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUnicodeToUtf8(const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_UTF8)
|
||||
{
|
||||
char output[10];
|
||||
|
||||
for (size_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
etk::getUtf8(_input_Unicode[iii], output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
_output_UTF8.push_back((int8_t)*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_UTF8.push_back('\0');
|
||||
return _output_UTF8.size()-1;
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(const std::vector<char>& _input_UTF8, std::vector<char32_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
size_t pos = 0;
|
||||
while (pos < _input_UTF8.size()) {
|
||||
int32_t lenMax = _input_UTF8.size() - pos;
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if ( 2<=lenMax
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if ( 3<=lenMax
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if ( 4<=lenMax
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
tmpData[0] = '\0';
|
||||
pos += 1;
|
||||
}
|
||||
_output_Unicode.push_back(etk::setUtf8(tmpData));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(const std::vector<int8_t>& _input_UTF8, std::vector<char32_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
size_t pos = 0;
|
||||
while (pos < _input_UTF8.size()) {
|
||||
int32_t lenMax = _input_UTF8.size() - pos;
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if ( 2<=lenMax
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if ( 3<=lenMax
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if ( 4<=lenMax
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
tmpData[0] = '\0';
|
||||
pos += 1;
|
||||
}
|
||||
_output_Unicode.push_back(etk::setUtf8(tmpData));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, std::vector<char32_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
if (NULL == _input_UTF8) {
|
||||
return 0;
|
||||
}
|
||||
int32_t len = strlen(_input_UTF8);
|
||||
while (pos < len) {
|
||||
int32_t lenMax = len - pos;
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if ( 2<=lenMax
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if ( 3<=lenMax
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if ( 4<=lenMax
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
tmpData[0] = '\0';
|
||||
pos += 1;
|
||||
}
|
||||
_output_Unicode.push_back(etk::setUtf8(tmpData));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Transform ISO <==> UTF-8
|
||||
void unicode::convertIsoToUtf8(enum charset _inputCharset, const char _input_ISO, char * _output_UTF8)
|
||||
{
|
||||
/*
|
||||
char32_t tmpUnicode;
|
||||
// concert Iso in UniCode
|
||||
convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode );
|
||||
// convert UniCode in Utf-8
|
||||
tmpUnicode.getUtf8(_output_UTF8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void unicode::convertUtf8ToIso(enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO)
|
||||
{
|
||||
/*
|
||||
char32_t tmpUnicode;
|
||||
// convert Utf-8 in UniCode
|
||||
tmpUnicode.setUtf8(_input_UTF8);
|
||||
// concert UniCode in Iso
|
||||
convertUnicodeToIso(_inputCharset, tmpUnicode, _output_ISO);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertIsoToUtf8(enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char>& _output_UTF8)
|
||||
{
|
||||
TK_WARNING("TODO : not coded...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUtf8ToIso(enum charset _inputCharset, const std::vector<char>& _input_UTF8, std::vector<char>& _output_ISO)
|
||||
{
|
||||
TK_WARNING("TODO : not coded...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unicode::utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid)
|
||||
{
|
||||
TK_ASSERT(0 <= _lenMax, "size can not be < 0 ...");
|
||||
if (0 > _lenMax) {
|
||||
_size = 0;
|
||||
_baseValid = false;
|
||||
return;
|
||||
}
|
||||
//4 case
|
||||
if ( 1<=_lenMax
|
||||
&& 0x00 == (_data[0] & 0x80) ) {
|
||||
// One Char Element
|
||||
_size = 1;
|
||||
_baseValid = true;
|
||||
} else if( 2<=_lenMax
|
||||
&& 0xC0 == (_data[0] & 0xE0)
|
||||
&& 0x80 == (_data[1] & 0xC0) ) {
|
||||
_size = 2;
|
||||
_baseValid = true;
|
||||
} else if( 3<=_lenMax
|
||||
&& 0xE0 == (_data[0] & 0xF0)
|
||||
&& 0x80 == (_data[1] & 0xC0)
|
||||
&& 0x80 == (_data[2] & 0xC0)) {
|
||||
_size = 3;
|
||||
_baseValid = true;
|
||||
} else if( 4<=_lenMax
|
||||
&& 0xF0 == (_data[0] & 0xF8)
|
||||
&& 0x80 == (_data[1] & 0xC0)
|
||||
&& 0x80 == (_data[2] & 0xC0)
|
||||
&& 0x80 == (_data[3] & 0xC0)) {
|
||||
_size = 4;
|
||||
_baseValid = true;
|
||||
} else {
|
||||
// return only one error Caracter ...
|
||||
_baseValid = false;
|
||||
_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 // Remove for the moment ...
|
||||
/**
|
||||
* @brief Get the number of element of the previous UTF8 char (in the curent Buffer)
|
||||
*
|
||||
* @param[in] data pointer on the curent CHAR string (pointer on the allocated buffer) (the curent char is not check)
|
||||
* @param[out] size Nb of char use in this UTF8 [0..4]
|
||||
* @param[out] baseValid true : the ase format of the UTF8 is CORRECT
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
static void Utf8_SizePreviousElement(const char * data, int32_t lenMax, uint8_t &size, bool &baseValid)
|
||||
{
|
||||
EDN_ASSERT(0 <= lenMax, "size can not be < 0 ...");
|
||||
if (0 > lenMax) {
|
||||
size = 0;
|
||||
baseValid = false;
|
||||
return;
|
||||
}
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (data[-1] & 0x80) ) {
|
||||
// One Char Element
|
||||
size = 1;
|
||||
baseValid = true;
|
||||
} else if( 2<=lenMax
|
||||
&& 0xC0 == (data[-2] & 0xE0)
|
||||
&& 0x80 == (data[-1] & 0xC0) ) {
|
||||
size = 2;
|
||||
baseValid = true;
|
||||
} else if( 3<=lenMax
|
||||
&& 0xE0 == (data[-3] & 0xF0)
|
||||
&& 0x80 == (data[-2] & 0xC0)
|
||||
&& 0x80 == (data[-1] & 0xC0)) {
|
||||
size = 3;
|
||||
baseValid = true;
|
||||
} else if( 4<=lenMax
|
||||
&& 0xF0 == (data[-4] & 0xF8)
|
||||
&& 0x80 == (data[-3] & 0xC0)
|
||||
&& 0x80 == (data[-2] & 0xC0)
|
||||
&& 0x80 == (data[-1] & 0xC0)) {
|
||||
size = 4;
|
||||
baseValid = true;
|
||||
} else {
|
||||
// return only one error Caracter ...
|
||||
baseValid = false;
|
||||
size = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out]
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
/*
|
||||
static uint32_t Utf8_GetValue(UTF8Element_ts &Element)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
const char * data = m_data + Element.CharPosition;
|
||||
//4 case
|
||||
switch(Element.CharSize)
|
||||
{
|
||||
case 1:
|
||||
value = data[0] & 0x7F;
|
||||
break;
|
||||
case 2:
|
||||
value = (data[0] & 0x1F)<< 6;
|
||||
value += data[1] & 0x3F;
|
||||
break;
|
||||
case 3:
|
||||
value = (data[0] & 0x0F)<< 12;
|
||||
value += (data[1] & 0x3F)<< 6;
|
||||
value += data[2] & 0x3F;
|
||||
break;
|
||||
case 4:
|
||||
value = (data[0] & 0x07)<< 18;
|
||||
value += (data[1] & 0x3F)<< 12;
|
||||
value += (data[2] & 0x3F)<< 6;
|
||||
value += data[3] & 0x3F;
|
||||
break;
|
||||
default:
|
||||
// return only one error Caracter ...
|
||||
EDN_ASSERT(false, "impossible case....");
|
||||
break;
|
||||
}
|
||||
// check the validity of the UTF8 ...
|
||||
if( ( 0xD800 <= value
|
||||
&& 0xDFFF >= value )
|
||||
|| ( 0xFDD0 <= value
|
||||
&& 0xFDEF >= value )
|
||||
|| ( 0xFFFE <= value
|
||||
&& 0xFFFF >= value )
|
||||
|| ( 0x1FFFE <= value
|
||||
&& 0x1FFFF >= value )
|
||||
|| ( 0x2FFFE <= value
|
||||
&& 0xDFFFF >= value )
|
||||
|| ( 0xEFFFE <= value
|
||||
&& 0xEFFFF >= value )
|
||||
|| ( 0xFFFFE <= value
|
||||
&& 0xFFFFF >= value )
|
||||
|| ( 0x10FFFE <= value
|
||||
&& 0x10FFFF >= value ) )
|
||||
{
|
||||
// overwrite the UTF8 validity ==> this is not a diaplayable element
|
||||
Element.ValidUTF8 = false;
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int32_t unicode::strUtf8Len(const char *input_UTF8)
|
||||
{
|
||||
int32_t count = 0;
|
||||
int32_t size = strlen(input_UTF8);
|
||||
uint8_t tmpSize;
|
||||
bool baseValid;
|
||||
while (size > 0) {
|
||||
utf8_SizeElement(input_UTF8, size , tmpSize, baseValid);
|
||||
input_UTF8 += tmpSize;
|
||||
size -= tmpSize;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// **************************************************************************************************************
|
||||
// simple convertion optention
|
||||
// **************************************************************************************************************
|
||||
|
||||
#if 0
|
||||
|
||||
Procedure de recuperation des charset sans ce casser les ...
|
||||
|
||||
// generate the basic file
|
||||
FILE * mfile = NULL;
|
||||
mfile = fopen("fichierIsoBase", "wb");
|
||||
if (NULL == mfile) {
|
||||
EDN_ERROR("Error to create file");
|
||||
return false;
|
||||
}
|
||||
char newline = '\n';
|
||||
for(int32_t i=0x20; i<0x100; i++) {
|
||||
char plop = i;
|
||||
fwrite(&plop, sizeof(char), 1, mfile);
|
||||
fwrite(&newline, sizeof(char), 1, mfile);
|
||||
}
|
||||
fclose(mfile);
|
||||
// console script to convert files :
|
||||
iconv -c --from-code=ISO-8859-1 --to-code=UTF-8 -o fichierUTF8_iso-1 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-2 --to-code=UTF-8 -o fichierUTF8_iso-2 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-3 --to-code=UTF-8 -o fichierUTF8_iso-3 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-4 --to-code=UTF-8 -o fichierUTF8_iso-4 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-5 --to-code=UTF-8 -o fichierUTF8_iso-5 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-6 --to-code=UTF-8 -o fichierUTF8_iso-6 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-7 --to-code=UTF-8 -o fichierUTF8_iso-7 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-8 --to-code=UTF-8 -o fichierUTF8_iso-8 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-9 --to-code=UTF-8 -o fichierUTF8_iso-9 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-10 --to-code=UTF-8 -o fichierUTF8_iso-10 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-11 --to-code=UTF-8 -o fichierUTF8_iso-11 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-12 --to-code=UTF-8 -o fichierUTF8_iso-12 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-13 --to-code=UTF-8 -o fichierUTF8_iso-13 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-14 --to-code=UTF-8 -o fichierUTF8_iso-14 fichierIsoBase
|
||||
iconv -c --from-code=ISO-8859-15 --to-code=UTF-8 -o fichierUTF8_iso-15 fichierIsoBase
|
||||
|
||||
// NOTE : Le format 12 n'existe pas ...
|
||||
FILE * mfileout = NULL;
|
||||
mfileout = fopen("outputGeneration.c", "wb");
|
||||
if (NULL == mfileout) {
|
||||
EDN_ERROR("Error to create file");
|
||||
return false;
|
||||
}
|
||||
|
||||
char * inputFileData[] = {
|
||||
"fichierUTF8_iso-1",
|
||||
"fichierUTF8_iso-2",
|
||||
// "fichierUTF8_iso-3",
|
||||
"fichierUTF8_iso-4",
|
||||
"fichierUTF8_iso-5",
|
||||
/* "fichierUTF8_iso-6",
|
||||
"fichierUTF8_iso-7",
|
||||
"fichierUTF8_iso-8",
|
||||
"fichierUTF8_iso-9",
|
||||
"fichierUTF8_iso-10",
|
||||
"fichierUTF8_iso-11",
|
||||
"fichierUTF8_iso-13",
|
||||
"fichierUTF8_iso-14",
|
||||
*/
|
||||
"fichierUTF8_iso-15"
|
||||
};
|
||||
|
||||
for (int32_t k=0; k<5; k++) {
|
||||
FILE * mfile = NULL;
|
||||
mfile = fopen(inputFileData[k], "rb");
|
||||
if (NULL == mfile) {
|
||||
EDN_ERROR("Error to open file");
|
||||
return false;
|
||||
}
|
||||
char data[255] ;
|
||||
fprintf(mfileout, "\tTYPESTRUCT_TS %s[] = {\n\t\t", inputFileData[k]);
|
||||
for(int32_t i=0x0; i<0x10; i++) {
|
||||
fprintf(mfileout, "0x%08X, ", i);
|
||||
}
|
||||
fprintf(mfileout, "\n\t\t");
|
||||
for(int32_t i=0x10; i<0x20; i++) {
|
||||
fprintf(mfileout, "0x%08X, ", i);
|
||||
}
|
||||
for(int32_t i=0x20; i<0x100; i++) {
|
||||
if (0==i%16) {
|
||||
fprintf(mfileout, "\n\t\t");
|
||||
}
|
||||
fgets(data, 25, mfile );
|
||||
data[strlen(data)-1] = '\0';
|
||||
EDN_INFO("sizeofLine=" << strlen(data) << " data=\"" << data << "\"");
|
||||
// convert in int :
|
||||
int32_t valUTF8 = 0;
|
||||
int32_t valUnicode = 0;
|
||||
switch (strlen(data)) {
|
||||
case 1:
|
||||
valUTF8 = (uint8_t) (data[0]);
|
||||
valUnicode = (uint8_t)(data[0]) & 0x7F;
|
||||
break;
|
||||
case 2:
|
||||
valUTF8 = (uint8_t) (data[0]) << 8;
|
||||
valUTF8 += (uint8_t) (data[1]);
|
||||
valUnicode = (((uint8_t)data[0]) & 0x1F)<< 6;
|
||||
valUnicode += ((uint8_t)data[1]) & 0x3F;
|
||||
break;
|
||||
case 3:
|
||||
valUTF8 = (uint8_t) (data[0]) << 16;
|
||||
valUTF8 += (uint8_t) (data[1]) << 8;
|
||||
valUTF8 += (uint8_t) (data[2]);
|
||||
valUnicode = (((uint8_t)data[0]) & 0x0F)<< 12;
|
||||
valUnicode += (((uint8_t)data[1]) & 0x3F)<< 6;
|
||||
valUnicode += ((uint8_t)data[2]) & 0x3F;
|
||||
break;
|
||||
default:
|
||||
valUTF8 = (uint8_t) (data[0]) <<24;
|
||||
valUTF8 += (uint8_t) (data[1]) << 16;
|
||||
valUTF8 += (uint8_t) (data[2]) << 8;
|
||||
valUTF8 += (uint8_t) (data[3]);
|
||||
valUnicode = (((uint8_t)data[0]) & 0x07)<< 18;
|
||||
valUnicode += (((uint8_t)data[1]) & 0x3F)<< 12;
|
||||
valUnicode += (((uint8_t)data[2]) & 0x3F)<< 6;
|
||||
valUnicode += ((uint8_t)data[3]) & 0x3F;
|
||||
break;
|
||||
}
|
||||
fprintf(mfileout, "0x%08X, ", valUnicode);
|
||||
}
|
||||
fprintf(mfileout, "\n\t};\n\n");
|
||||
fclose(mfile);
|
||||
}
|
||||
fclose(mfileout);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __UNICODE_H__
|
||||
#define __UNICODE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <vector>
|
||||
|
||||
namespace unicode {
|
||||
enum charset {
|
||||
charsetUTF8,
|
||||
charsetIso8859_1,
|
||||
charsetIso8859_2,
|
||||
charsetIso8859_3,
|
||||
charsetIso8859_4,
|
||||
charsetIso8859_5,
|
||||
charsetIso8859_6,
|
||||
charsetIso8859_7,
|
||||
charsetIso8859_8,
|
||||
charsetIso8859_9,
|
||||
charsetIso8859_10,
|
||||
charsetIso8859_11,
|
||||
charsetIso8859_13,
|
||||
charsetIso8859_14,
|
||||
charsetIso8859_15
|
||||
};
|
||||
|
||||
// transform ISO <==> Unicode
|
||||
void convertIsoToUnicode(enum charset _inputCharset, const char _input_ISO, char32_t & _output_Unicode);
|
||||
void convertUnicodeToIso(enum charset _inputCharset, const char32_t _input_Unicode, char & _output_ISO);
|
||||
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 std::vector<int8_t>& _input_ISO, std::vector<char32_t>& _output_Unicode);
|
||||
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 std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_ISO);
|
||||
// Transform UTF-8 <==> Unicode
|
||||
int32_t convertUnicodeToUtf8( const std::vector<char32_t>& _input_Unicode, std::vector<char>& _output_UTF8);
|
||||
int32_t convertUnicodeToUtf8( const std::vector<char32_t>& _input_Unicode, std::vector<int8_t>& _output_UTF8);
|
||||
int32_t convertUtf8ToUnicode( const std::vector<char>& _input_UTF8, std::vector<char32_t>& _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, std::vector<char32_t>& _output_Unicode);
|
||||
// Transform ISO <==> UTF-8
|
||||
void convertIsoToUtf8( enum charset _inputCharset, const char _input_ISO, char * _output_UTF8);
|
||||
void convertUtf8ToIso( enum charset _inputCharset, const char * _input_UTF8, char & _output_ISO);
|
||||
int32_t convertIsoToUtf8( enum charset _inputCharset, const std::vector<char>& _input_ISO, std::vector<char>& _output_UTF8);
|
||||
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);
|
||||
int32_t strUtf8Len(const char *_input_UTF8);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,282 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/debug.h>
|
||||
#include <etk/unicodeTable.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
const uint32_t tableIso8859_1[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000BA, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000BF,
|
||||
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x000000D0, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
|
||||
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_2[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000104, 0x000002D8, 0x00000141, 0x000000A4, 0x0000013D, 0x0000015A, 0x000000A7, 0x000000A8, 0x00000160, 0x0000015E, 0x00000164, 0x00000179, 0x000000AD, 0x0000017D, 0x0000017B,
|
||||
0x000000B0, 0x00000105, 0x000002DB, 0x00000142, 0x000000B4, 0x0000013E, 0x0000015B, 0x000002C7, 0x000000B8, 0x00000161, 0x0000015F, 0x00000165, 0x0000017A, 0x000002DD, 0x0000017E, 0x0000017C,
|
||||
0x00000154, 0x000000C1, 0x000000C2, 0x00000102, 0x000000C4, 0x00000139, 0x00000106, 0x000000C7, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x0000011A, 0x000000CD, 0x000000CE, 0x0000010E,
|
||||
0x00000110, 0x00000143, 0x00000147, 0x000000D3, 0x000000D4, 0x00000150, 0x000000D6, 0x000000D7, 0x00000158, 0x0000016E, 0x000000DA, 0x00000170, 0x000000DC, 0x000000DD, 0x00000162, 0x000000DF,
|
||||
0x00000155, 0x000000E1, 0x000000E2, 0x00000103, 0x000000E4, 0x0000013A, 0x00000107, 0x000000E7, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x0000011B, 0x000000ED, 0x000000EE, 0x0000010F,
|
||||
0x00000111, 0x00000144, 0x00000148, 0x000000F3, 0x000000F4, 0x00000151, 0x000000F6, 0x000000F7, 0x00000159, 0x0000016F, 0x000000FA, 0x00000171, 0x000000FC, 0x000000FD, 0x00000163, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_3[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000126, 0x000002D8, 0x000000A3, 0x000000A4, 0x00000000, 0x00000124, 0x000000A7, 0x000000A8, 0x00000130, 0x0000015E, 0x0000011E, 0x00000134, 0x000000AD, 0x00000000, 0x0000017B,
|
||||
0x000000B0, 0x00000127, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x00000125, 0x000000B7, 0x000000B8, 0x00000131, 0x0000015F, 0x0000011F, 0x00000135, 0x000000BD, 0x00000000, 0x0000017C,
|
||||
0x000000C0, 0x000000C1, 0x000000C2, 0x00000000, 0x000000C4, 0x0000010A, 0x00000108, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x00000000, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x00000120, 0x000000D6, 0x000000D7, 0x0000011C, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x0000016C, 0x0000015C, 0x000000DF,
|
||||
0x000000E0, 0x000000E1, 0x000000E2, 0x00000000, 0x000000E4, 0x0000010B, 0x00000109, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x00000000, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x00000121, 0x000000F6, 0x000000F7, 0x0000011D, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x0000016D, 0x0000015D, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_4[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000104, 0x00000138, 0x00000156, 0x000000A4, 0x00000128, 0x0000013B, 0x000000A7, 0x000000A8, 0x00000160, 0x00000112, 0x00000122, 0x00000166, 0x000000AD, 0x0000017D, 0x000000AF,
|
||||
0x000000B0, 0x00000105, 0x000002DB, 0x00000157, 0x000000B4, 0x00000129, 0x0000013C, 0x000002C7, 0x000000B8, 0x00000161, 0x00000113, 0x00000123, 0x00000167, 0x0000014A, 0x0000017E, 0x0000014B,
|
||||
0x00000100, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x0000012E, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x00000116, 0x000000CD, 0x000000CE, 0x0000012A,
|
||||
0x00000110, 0x00000145, 0x0000014C, 0x00000136, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x00000172, 0x000000DA, 0x000000DB, 0x000000DC, 0x00000168, 0x0000016A, 0x000000DF,
|
||||
0x00000101, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x0000012F, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x00000117, 0x000000ED, 0x000000EE, 0x0000012B,
|
||||
0x00000111, 0x00000146, 0x0000014D, 0x00000137, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000169, 0x0000016B, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_5[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000401, 0x00000402, 0x00000403, 0x00000404, 0x00000405, 0x00000406, 0x00000407, 0x00000408, 0x00000409, 0x0000040A, 0x0000040B, 0x0000040C, 0x000000AD, 0x0000040E, 0x0000040F,
|
||||
0x00000410, 0x00000411, 0x00000412, 0x00000413, 0x00000414, 0x00000415, 0x00000416, 0x00000417, 0x00000418, 0x00000419, 0x0000041A, 0x0000041B, 0x0000041C, 0x0000041D, 0x0000041E, 0x0000041F,
|
||||
0x00000420, 0x00000421, 0x00000422, 0x00000423, 0x00000424, 0x00000425, 0x00000426, 0x00000427, 0x00000428, 0x00000429, 0x0000042A, 0x0000042B, 0x0000042C, 0x0000042D, 0x0000042E, 0x0000042F,
|
||||
0x00000430, 0x00000431, 0x00000432, 0x00000433, 0x00000434, 0x00000435, 0x00000436, 0x00000437, 0x00000438, 0x00000439, 0x0000043A, 0x0000043B, 0x0000043C, 0x0000043D, 0x0000043E, 0x0000043F,
|
||||
0x00000440, 0x00000441, 0x00000442, 0x00000443, 0x00000444, 0x00000445, 0x00000446, 0x00000447, 0x00000448, 0x00000449, 0x0000044A, 0x0000044B, 0x0000044C, 0x0000044D, 0x0000044E, 0x0000044F,
|
||||
0x00002116, 0x00000451, 0x00000452, 0x00000453, 0x00000454, 0x00000455, 0x00000456, 0x00000457, 0x00000458, 0x00000459, 0x0000045A, 0x0000045B, 0x0000045C, 0x000000A7, 0x0000045E, 0x0000045F
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_6[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000000, 0x00000000, 0x00000000, 0x000000A4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000060C, 0x000000AD, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000061B, 0x00000000, 0x00000000, 0x00000000, 0x0000061F,
|
||||
0x00000000, 0x00000621, 0x00000622, 0x00000623, 0x00000624, 0x00000625, 0x00000626, 0x00000627, 0x00000628, 0x00000629, 0x0000062A, 0x0000062B, 0x0000062C, 0x0000062D, 0x0000062E, 0x0000062F,
|
||||
0x00000630, 0x00000631, 0x00000632, 0x00000633, 0x00000634, 0x00000635, 0x00000636, 0x00000637, 0x00000638, 0x00000639, 0x0000063A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000640, 0x00000641, 0x00000642, 0x00000643, 0x00000644, 0x00000645, 0x00000646, 0x00000647, 0x00000648, 0x00000649, 0x0000064A, 0x0000064B, 0x0000064C, 0x0000064D, 0x0000064E, 0x0000064F,
|
||||
0x00000650, 0x00000651, 0x00000652, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_7[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00002018, 0x00002019, 0x000000A3, 0x000020AC, 0x000020AF, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x0000037A, 0x000000AB, 0x000000AC, 0x000000AD, 0x00000000, 0x00002015,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x00000384, 0x00000385, 0x00000386, 0x000000B7, 0x00000388, 0x00000389, 0x0000038A, 0x000000BB, 0x0000038C, 0x000000BD, 0x0000038E, 0x0000038F,
|
||||
0x00000390, 0x00000391, 0x00000392, 0x00000393, 0x00000394, 0x00000395, 0x00000396, 0x00000397, 0x00000398, 0x00000399, 0x0000039A, 0x0000039B, 0x0000039C, 0x0000039D, 0x0000039E, 0x0000039F,
|
||||
0x000003A0, 0x000003A1, 0x00000000, 0x000003A3, 0x000003A4, 0x000003A5, 0x000003A6, 0x000003A7, 0x000003A8, 0x000003A9, 0x000003AA, 0x000003AB, 0x000003AC, 0x000003AD, 0x000003AE, 0x000003AF,
|
||||
0x000003B0, 0x000003B1, 0x000003B2, 0x000003B3, 0x000003B4, 0x000003B5, 0x000003B6, 0x000003B7, 0x000003B8, 0x000003B9, 0x000003BA, 0x000003BB, 0x000003BC, 0x000003BD, 0x000003BE, 0x000003BF,
|
||||
0x000003C0, 0x000003C1, 0x000003C2, 0x000003C3, 0x000003C4, 0x000003C5, 0x000003C6, 0x000003C7, 0x000003C8, 0x000003C9, 0x000003CA, 0x000003CB, 0x000003CC, 0x000003CD, 0x000003CE, 0x00000000
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_8[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000000, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000D7, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000F7, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00002017,
|
||||
0x000005D0, 0x000005D1, 0x000005D2, 0x000005D3, 0x000005D4, 0x000005D5, 0x000005D6, 0x000005D7, 0x000005D8, 0x000005D9, 0x000005DA, 0x000005DB, 0x000005DC, 0x000005DD, 0x000005DE, 0x000005DF,
|
||||
0x000005E0, 0x000005E1, 0x000005E2, 0x000005E3, 0x000005E4, 0x000005E5, 0x000005E6, 0x000005E7, 0x000005E8, 0x000005E9, 0x000005EA, 0x00000000, 0x00000000, 0x0000200E, 0x0000200F, 0x000003C0
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_9[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000BA, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000BF,
|
||||
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x0000011E, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x00000130, 0x0000015E, 0x000000DF,
|
||||
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x0000011F, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000131, 0x0000015F, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_10[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000104, 0x00000112, 0x00000122, 0x0000012A, 0x00000128, 0x00000136, 0x000000A7, 0x0000013B, 0x00000110, 0x00000160, 0x00000166, 0x0000017D, 0x000000AD, 0x0000016A, 0x0000014A,
|
||||
0x000000B0, 0x00000105, 0x00000113, 0x00000123, 0x0000012B, 0x00000129, 0x00000137, 0x000000B7, 0x0000013C, 0x00000111, 0x00000161, 0x00000167, 0x0000017E, 0x00002015, 0x0000016B, 0x0000014B,
|
||||
0x00000100, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x0000012E, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x00000116, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x000000D0, 0x00000145, 0x0000014C, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x00000168, 0x000000D8, 0x00000172, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
|
||||
0x00000101, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x0000012F, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x00000117, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x000000F0, 0x00000146, 0x0000014D, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00000169, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x00000138
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_11[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00000E01, 0x00000E02, 0x00000E03, 0x00000E04, 0x00000E05, 0x00000E06, 0x00000E07, 0x00000E08, 0x00000E09, 0x00000E0A, 0x00000E0B, 0x00000E0C, 0x00000E0D, 0x00000E0E, 0x00000E0F,
|
||||
0x00000E10, 0x00000E11, 0x00000E12, 0x00000E13, 0x00000E14, 0x00000E15, 0x00000E16, 0x00000E17, 0x00000E18, 0x00000E19, 0x00000E1A, 0x00000E1B, 0x00000E1C, 0x00000E1D, 0x00000E1E, 0x00000E1F,
|
||||
0x00000E20, 0x00000E21, 0x00000E22, 0x00000E23, 0x00000E24, 0x00000E25, 0x00000E26, 0x00000E27, 0x00000E28, 0x00000E29, 0x00000E2A, 0x00000E2B, 0x00000E2C, 0x00000E2D, 0x00000E2E, 0x00000E2F,
|
||||
0x00000E30, 0x00000E31, 0x00000E32, 0x00000E33, 0x00000E34, 0x00000E35, 0x00000E36, 0x00000E37, 0x00000E38, 0x00000E39, 0x00000E3A, 0x00000E80, 0x00000E80, 0x00000E80, 0x00000E80, 0x00000E3F,
|
||||
0x00000E40, 0x00000E41, 0x00000E42, 0x00000E43, 0x00000E44, 0x00000E45, 0x00000E46, 0x00000E47, 0x00000E48, 0x00000E49, 0x00000E4A, 0x00000E4B, 0x00000E4C, 0x00000E4D, 0x00000E4E, 0x00000E4F,
|
||||
0x00000E50, 0x00000E51, 0x00000E52, 0x00000E53, 0x00000E54, 0x00000E55, 0x00000E56, 0x00000E57, 0x00000E58, 0x00000E59, 0x00000E5A, 0x00000E5B, 0x000006C0, 0x000006C0, 0x000006C0, 0x000006C0
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_13[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x0000201D, 0x000000A2, 0x000000A3, 0x000000A4, 0x0000201E, 0x000000A6, 0x000000A7, 0x000000D8, 0x000000A9, 0x00000156, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000C6,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x0000201C, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000F8, 0x000000B9, 0x00000157, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000E6,
|
||||
0x00000104, 0x0000012E, 0x00000100, 0x00000106, 0x000000C4, 0x000000C5, 0x00000118, 0x00000112, 0x0000010C, 0x000000C9, 0x00000179, 0x00000116, 0x00000122, 0x00000136, 0x0000012A, 0x0000013B,
|
||||
0x00000160, 0x00000143, 0x00000145, 0x000000D3, 0x0000014C, 0x000000D5, 0x000000D6, 0x000000D7, 0x00000172, 0x00000141, 0x0000015A, 0x0000016A, 0x000000DC, 0x0000017B, 0x0000017D, 0x000000DF,
|
||||
0x00000105, 0x0000012F, 0x00000101, 0x00000107, 0x000000E4, 0x000000E5, 0x00000119, 0x00000113, 0x0000010D, 0x000000E9, 0x0000017A, 0x00000117, 0x00000123, 0x00000137, 0x0000012B, 0x0000013C,
|
||||
0x00000161, 0x00000144, 0x00000146, 0x000000F3, 0x0000014D, 0x000000F5, 0x000000F6, 0x000000F7, 0x00000173, 0x00000142, 0x0000015B, 0x0000016B, 0x000000FC, 0x0000017C, 0x0000017E, 0x00002019
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_14[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x00001E02, 0x00001E03, 0x000000A3, 0x0000010A, 0x0000010B, 0x00001E0A, 0x000000A7, 0x00001E80, 0x000000A9, 0x00001E82, 0x00001E0B, 0x00001EF2, 0x000000AD, 0x000000AE, 0x00000178,
|
||||
0x00001E1E, 0x00001E1F, 0x00000120, 0x00000121, 0x00001E40, 0x00001E41, 0x000000B6, 0x00001E56, 0x00001E81, 0x00001E57, 0x00001E83, 0x00001E60, 0x00001EF3, 0x00001E84, 0x00001E85, 0x00001E61,
|
||||
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x00000174, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x00001E6A, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x00000176, 0x000000DF,
|
||||
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x00000175, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00001E6B, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x00000177, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t tableIso8859_15[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
|
||||
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
|
||||
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
|
||||
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
|
||||
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
|
||||
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
|
||||
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
|
||||
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000020AC, 0x000000A5, 0x00000160, 0x000000A7, 0x00000161, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
|
||||
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x0000017D, 0x000000B5, 0x000000B6, 0x000000B7, 0x0000017E, 0x000000B9, 0x000000BA, 0x000000BB, 0x00000152, 0x00000153, 0x00000178, 0x000000BF,
|
||||
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
|
||||
0x000000D0, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
|
||||
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
|
||||
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __UNICODE_TABLE_H__
|
||||
#define __UNICODE_TABLE_H__
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern const uint32_t tableIso8859_1[];
|
||||
extern const uint32_t tableIso8859_2[];
|
||||
extern const uint32_t tableIso8859_3[];
|
||||
extern const uint32_t tableIso8859_4[];
|
||||
extern const uint32_t tableIso8859_5[];
|
||||
extern const uint32_t tableIso8859_6[];
|
||||
extern const uint32_t tableIso8859_7[];
|
||||
extern const uint32_t tableIso8859_8[];
|
||||
extern const uint32_t tableIso8859_9[];
|
||||
extern const uint32_t tableIso8859_10[];
|
||||
extern const uint32_t tableIso8859_11[];
|
||||
extern const uint32_t tableIso8859_13[];
|
||||
extern const uint32_t tableIso8859_14[];
|
||||
extern const uint32_t tableIso8859_15[];
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
@ -15,11 +15,7 @@ def create(target):
|
||||
myModule.add_src_file([
|
||||
'etk/debugGeneric.cpp',
|
||||
'etk/debug.cpp',
|
||||
'etk/unicode.cpp',
|
||||
'etk/unicodeTable.cpp',
|
||||
'etk/Char.cpp',
|
||||
'etk/UChar.cpp',
|
||||
'etk/UString.cpp',
|
||||
'etk/stdTools.cpp',
|
||||
'etk/Stream.cpp',
|
||||
'etk/RegExp.cpp',
|
||||
'etk/tool.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user