[DEV] UniChar ==> UChar & Hach ==> Hash

This commit is contained in:
Edouard DUPIN 2013-10-18 21:15:02 +02:00
parent e889200de8
commit 5ceab908cf
16 changed files with 245 additions and 277 deletions

View File

@ -196,7 +196,7 @@ namespace etk
* @param[in] _pos Desired position read
* @return Reference on the Element
*/
esize_t get(esize_t _pos, UniChar& _value, charset_te _charset) const
esize_t get(esize_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) {

View File

@ -18,40 +18,33 @@
#define __class__ "etk::Hash"
namespace etk
{
template<class MY_TYPE> class HashData
{
namespace etk {
template<class MY_TYPE> class HashData {
public:
etk::UString m_key; //!< name of the current hash
MY_TYPE m_value; //!< data of the current Hash
HashData(const etk::UString& _key, const MY_TYPE& _val) :
m_key(_key),
m_value(_val)
{
m_key(_key),
m_value(_val) {
// nothing to do ...
}
};
template<class MY_TYPE> class Hash
{
template<class MY_TYPE> class Hash {
private:
etk::Vector<HashData<MY_TYPE>* > m_data; //!< Data of the hash ==> the Hash table is composed of pointer, this permit to have high speed when resize the vestor ...
public:
Hash(int32_t _count=0) :
m_data(_count)
{
m_data(_count) {
}
~Hash(void)
{
~Hash(void) {
clear();
}
/**
* @brief Remove all entry in the Hash table
*/
void clear(void)
{
void clear(void) {
for (int32_t iii=0; iii<m_data.size(); iii++) {
if (m_data[iii] != NULL) {
delete(m_data[iii]);
@ -65,8 +58,7 @@ namespace etk
* @param[in] _key Name of the hash requested
* @return Id of the element in the table or -1 of it does not existed
*/
int64_t getId(const etk::UString& _key) const
{
int64_t getId(const etk::UString& _key) const {
for (int32_t iii=0; iii<m_data.size(); iii++) {
if (m_data[iii] != NULL) {
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
@ -83,8 +75,7 @@ namespace etk
* @param[in] _key Name of the hash requested
* @return true if the element exist
*/
bool exist(const etk::UString& _name) const
{
bool exist(const etk::UString& _name) const {
int64_t elementId = getId(_name);
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
if (elementId<0) {
@ -99,8 +90,7 @@ namespace etk
* @param[in] _key Name of the hash requested
* @return Reference on the Element
*/
MY_TYPE& get(const etk::UString& _key) const
{
MY_TYPE& get(const etk::UString& _key) const {
static MY_TYPE g_error;
int64_t elementId = getId(_key);
if (elementId<0) {
@ -114,17 +104,14 @@ namespace etk
* @param[in] _key Name of the hash requested
* @return An reference on the copy of selected element
*/
MY_TYPE& operator[] (const etk::UString& _key)
{
MY_TYPE& operator[] (const etk::UString& _key) {
return get(_key);
}
const MY_TYPE& operator[] (const etk::UString& _key) const
{
const MY_TYPE& operator[] (const etk::UString& _key) const {
return get(_key);
}
void add(const etk::UString& _key, const MY_TYPE& _value)
{
void add(const etk::UString& _key, const MY_TYPE& _value) {
int64_t elementId = getId(_key);
if (elementId <0) {
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
@ -137,12 +124,10 @@ namespace etk
}
m_data[elementId]->m_value = _value;
}
void set(const etk::UString& _key, const MY_TYPE& _value)
{
void set(const etk::UString& _key, const MY_TYPE& _value) {
add(_key, _value);
}
void remove(const etk::UString& _key)
{
void remove(const etk::UString& _key) {
int64_t elementId = getId(_key);
if (elementId <0) {
//nothing to do ==> not existed
@ -156,20 +141,16 @@ namespace etk
* @brief Get the number of element in the hash table
* @return number of elements
*/
esize_t size(void) const
{
esize_t size(void) const {
return m_data.size();
}
MY_TYPE& operator[] (esize_t _pos)
{
MY_TYPE& operator[] (esize_t _pos) {
return getValue(_pos);
}
const MY_TYPE& operator[] (esize_t _pos) const
{
const MY_TYPE& operator[] (esize_t _pos) const {
return getValue(_pos);
}
const etk::UString& getKey(esize_t _pos) const
{
const etk::UString& getKey(esize_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
@ -178,8 +159,7 @@ namespace etk
#endif
return m_data[_pos]->m_key;
}
const MY_TYPE& getValue(esize_t _pos) const
{
const MY_TYPE& getValue(esize_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
@ -188,8 +168,7 @@ namespace etk
#endif
return m_data[_pos]->m_value;
}
MY_TYPE& getValue(esize_t _pos)
{
MY_TYPE& getValue(esize_t _pos) {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
@ -202,7 +181,7 @@ namespace etk
};
#undef __class__
#define __class__ NULL
#define __class__ NULL
#endif

View File

@ -64,7 +64,7 @@ const etk::convertionTable_ts etk::constConvertionTable[] = {
};
const esize_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ;
void etk::displayElem(const etk::Vector<etk::UniChar>& _data, esize_t _start, esize_t _stop)
void etk::displayElem(const etk::Vector<etk::UChar>& _data, esize_t _start, esize_t _stop)
{
etk::cout<< ETK_BASH_COLOR_NORMAL;
for (esize_t iii=_start; iii<_data.size() && iii<_stop ; iii++) {
@ -125,7 +125,7 @@ char * etk::levelSpace(uint32_t _level)
}
esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UChar>& _data, esize_t _startPos)
{
if (_startPos>=_data.size()){
return 0;
@ -166,7 +166,7 @@ esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t
return pos - _startPos;
}
esize_t etk::getLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
esize_t etk::getLenOfPThese(const etk::Vector<etk::UChar>& _data, esize_t _startPos)
{
esize_t pos = _startPos;
int32_t nbOpen = 0;
@ -208,7 +208,7 @@ esize_t etk::getLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _sta
}
esize_t etk::getLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
esize_t etk::getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _startPos)
{
esize_t pos = _startPos;
// special case of the (...) or | ==> we search '|' or ')'
@ -242,7 +242,7 @@ esize_t etk::getLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _st
}
esize_t etk::getLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
esize_t etk::getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startPos)
{
int32_t pos = _startPos;
// special case of the (...) or | ==> we search '|' or ')'
@ -277,7 +277,7 @@ esize_t etk::getLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _star
}
esize_t etk::getLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
esize_t etk::getLenOfNormal(const etk::Vector<etk::UChar>& _data, esize_t _startPos)
{
esize_t pos = _startPos;
@ -329,7 +329,7 @@ esize_t etk::getLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _sta
}
bool etk::parseBrace(const etk::Vector<etk::UniChar>& _data, uint32_t& _min, uint32_t& _max)
bool etk::parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint32_t& _max)
{
//TK_INFO("parse {...} in "; DisplayElem(data); );
esize_t k=0;

View File

@ -56,14 +56,14 @@ typedef struct {
extern const convertionTable_ts constConvertionTable[];
extern const esize_t constConvertionTableSize;
void displayElem(const etk::Vector<etk::UniChar>& _data, esize_t _start=0, esize_t _stop=0x7FFFFFFF);
void displayElem(const etk::Vector<etk::UChar>& _data, esize_t _start=0, esize_t _stop=0x7FFFFFFF);
char * levelSpace(uint32_t _level);
esize_t getLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t _startPos);
esize_t getLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _startPos);
esize_t getLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _startPos);
esize_t getLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _startPos);
esize_t getLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _startPos);
bool parseBrace(const etk::Vector<etk::UniChar>& _data, uint32_t& _min, uint32_t& _max);
esize_t getLenOfPTheseElem(const etk::Vector<etk::UChar>& _data, esize_t _startPos);
esize_t getLenOfPThese(const etk::Vector<etk::UChar>& _data, esize_t _startPos);
esize_t getLenOfBracket(const etk::Vector<etk::UChar>& _data, esize_t _startPos);
esize_t getLenOfBrace(const etk::Vector<etk::UChar>& _data, esize_t _startPos);
esize_t getLenOfNormal(const etk::Vector<etk::UChar>& _data, esize_t _startPos);
bool parseBrace(const etk::Vector<etk::UChar>& _data, uint32_t& _min, uint32_t& _max);
#undef __class__
@ -78,7 +78,7 @@ template<class CLASS_TYPE> class RegExpNode
uint32_t m_multipleMin; //!< minimum repetition (included)
uint32_t m_multipleMax; //!< maximum repetition (included)
// Data Section ... (can have no data...)
etk::Vector<etk::UniChar> m_RegExpData; //!< data to parse and compare in some case ...
etk::Vector<etk::UChar> m_RegExpData; //!< data to parse and compare in some case ...
public :
/**
* @brief Constructor
@ -98,7 +98,7 @@ template<class CLASS_TYPE> class RegExpNode
* @param[in] _data Property of the regexp
* @return the number of element used
*/
virtual int32_t generate(const etk::Vector<etk::UniChar>& _data)
virtual int32_t generate(const etk::Vector<etk::UChar>& _data)
{
return 0;
};
@ -151,7 +151,7 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
{
protected :
// SubNodes :
etk::Vector<etk::UniChar> m_data;
etk::Vector<etk::UChar> m_data;
public :
/**
@ -164,7 +164,7 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
*/
~RegExpNodeValue(void) { };
int32_t generate(const etk::Vector<etk::UniChar>& _data)
int32_t generate(const etk::Vector<etk::UChar>& _data)
{
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse \"Value\" data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
@ -234,7 +234,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
{
protected :
// SubNodes :
etk::Vector<etk::UniChar> m_data;
etk::Vector<etk::UChar> m_data;
public :
/**
@ -247,13 +247,13 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
*/
~RegExpNodeBracket(void) { };
int32_t generate(const etk::Vector<etk::UniChar>& _data)
int32_t generate(const etk::Vector<etk::UChar>& _data)
{
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse [...] data="; displayElem(_data););
m_data.clear();
etk::UniChar lastElement = 'a';
etk::UChar lastElement = 'a';
bool multipleElement = false;
//
for (int32_t kkk=0; kkk<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); kkk++) {
@ -261,7 +261,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
TK_ERROR("Can not have 2 consecutive - in [...]");
return 0;
} else if (multipleElement == true) {
etk::UniChar jjj='\0';
etk::UChar jjj='\0';
for (jjj=lastElement+1; jjj <= RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]; jjj+=1) {
m_data.pushBack(jjj);
}
@ -347,7 +347,7 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE>
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
TK_REG_EXP_DBG_MODE("compare : " << tmpVal);
if( tmpVal >= '0'
&& tmpVal <= '9')
@ -402,7 +402,7 @@ template<class CLASS_TYPE> class RegExpNodeDigitNot : public RegExpNode<CLASS_TY
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( tmpVal < '0'
|| tmpVal > '9') {
_findLen += 1;
@ -451,7 +451,7 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z')
|| ( tmpVal >= 'A'
@ -505,7 +505,7 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( ( tmpVal < 'a'
&& tmpVal > 'Z')
|| tmpVal < 'A'
@ -559,7 +559,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( tmpVal == ' '
|| tmpVal == '\t'
|| tmpVal == '\n'
@ -615,7 +615,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( tmpVal != ' '
&& tmpVal != '\t'
&& tmpVal != '\n'
@ -670,7 +670,7 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TY
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z' )
|| ( tmpVal >= 'A'
@ -725,7 +725,7 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( ( tmpVal < 'A'
&& tmpVal > '9' )
|| ( tmpVal < 'a'
@ -782,7 +782,7 @@ template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE>
bool tmpFind = true;
uint32_t jjj;
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
etk::UniChar tmpVal = _data[_currentPos+jjj];
etk::UChar tmpVal = _data[_currentPos+jjj];
if( ( tmpVal > 0x08
&& tmpVal < 0x0A )
|| ( tmpVal > 0x1F
@ -908,13 +908,13 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
*/
~RegExpNodePTheseElem(void) { };
int32_t generate(const etk::Vector<etk::UniChar>& _data)
int32_t generate(const etk::Vector<etk::UChar>& _data)
{
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
esize_t pos = 0;
esize_t elementSize = 0;
etk::Vector<etk::UniChar> tmpData;
etk::Vector<etk::UChar> tmpData;
while (pos < RegExpNode<CLASS_TYPE>::m_RegExpData.size()) {
tmpData.clear();
switch (RegExpNode<CLASS_TYPE>::m_RegExpData[pos].get()) {
@ -1123,7 +1123,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
};
int32_t generate(const etk::Vector<etk::UniChar>& _data)
int32_t generate(const etk::Vector<etk::UChar>& _data)
{
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
TK_REG_EXP_DBG_MODE("Request Parse (...) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
@ -1133,7 +1133,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
// generate all the "elemTypePTheseElem" of the Node
while (elementSize>0) {
// geerate output deta ...
etk::Vector<etk::UniChar> tmpData;
etk::Vector<etk::UChar> tmpData;
for (esize_t kkk=pos; kkk<pos+elementSize; kkk++) {
tmpData.pushBack(RegExpNode<CLASS_TYPE>::m_RegExpData[kkk]);
}
@ -1248,7 +1248,7 @@ template<class CLASS_TYPE> class RegExp
void setRegExp(const etk::UString &_regexp)
{
m_expressionRequested = _regexp;
etk::Vector<etk::UniChar> tmpExp;
etk::Vector<etk::UChar> tmpExp;
TK_REG_EXP_DBG_MODE("---------------------------------------------------------------------");
TK_REG_EXP_DBG_MODE("Parse RegExp : (" << _regexp << ")" );
@ -1409,7 +1409,7 @@ template<class CLASS_TYPE> class RegExp
bool process(const CLASS_TYPE& _SearchIn,
esize_t _startPos,
esize_t _endPos,
etk::UniChar _escapeChar=0)
etk::UChar _escapeChar=0)
{
if (false == m_isOk) {
return false;
@ -1426,7 +1426,7 @@ template<class CLASS_TYPE> class RegExp
esize_t maxlen = _endPos-iii;
if (true == m_notBeginWithChar) {
if (iii>0) {
etk::UniChar tmpVal = _SearchIn[iii-1];
etk::UChar tmpVal = _SearchIn[iii-1];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z' )
|| ( tmpVal >= 'A'
@ -1451,7 +1451,7 @@ template<class CLASS_TYPE> class RegExp
// Check end :
if (true == m_notEndWithChar) {
if (iii+findLen < _SearchIn.size() ) {
etk::UniChar tmpVal = _SearchIn[iii+findLen];
etk::UChar tmpVal = _SearchIn[iii+findLen];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z' )
|| ( tmpVal >= 'A'
@ -1487,7 +1487,7 @@ template<class CLASS_TYPE> class RegExp
bool processOneElement( const CLASS_TYPE& _SearchIn,
esize_t _startPos,
esize_t _endPos,
etk::UniChar _escapeChar=0)
etk::UChar _escapeChar=0)
{
if (false == m_isOk) {
return false;
@ -1503,7 +1503,7 @@ template<class CLASS_TYPE> class RegExp
esize_t maxlen = _endPos-_startPos;
if (true == m_notBeginWithChar) {
if (_startPos>0) {
etk::UniChar tmpVal = _SearchIn[_startPos-1];
etk::UChar tmpVal = _SearchIn[_startPos-1];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z' )
|| ( tmpVal >= 'A'
@ -1528,7 +1528,7 @@ template<class CLASS_TYPE> class RegExp
// Check end :
if (true == m_notEndWithChar) {
if (_startPos+findLen < _SearchIn.size() ) {
etk::UniChar tmpVal = _SearchIn[_startPos+findLen];
etk::UChar tmpVal = _SearchIn[_startPos+findLen];
if( ( tmpVal >= 'a'
&& tmpVal <= 'z' )
|| ( tmpVal >= 'A'
@ -1574,10 +1574,10 @@ template<class CLASS_TYPE> class RegExp
* @param[in,out]
* @return
*/
bool checkGoodPosition(const etk::Vector<etk::UniChar>& _tmpExp, esize_t& _pos)
bool checkGoodPosition(const etk::Vector<etk::UChar>& _tmpExp, esize_t& _pos)
{
etk::UniChar curentCode = _tmpExp[_pos];
etk::UniChar endCode = REGEXP_OPCODE_PTHESE_OUT;
etk::UChar curentCode = _tmpExp[_pos];
etk::UChar endCode = REGEXP_OPCODE_PTHESE_OUT;
const char *input = "(...)";
if (curentCode == REGEXP_OPCODE_BRACKET_IN) {
endCode = REGEXP_OPCODE_BRACKET_OUT;
@ -1679,7 +1679,7 @@ template<class CLASS_TYPE> class RegExp
* @param[in,out]
* @return
*/
bool checkGoodPosition(const etk::Vector<etk::UniChar>& _tmpExp)
bool checkGoodPosition(const etk::Vector<etk::UChar>& _tmpExp)
{
esize_t pos = 0;
while (pos < _tmpExp.size()) {

View File

@ -149,7 +149,7 @@ etk::CCout::~CCout()
};
etk::CCout& etk::CCout::operator << (const etk::UniChar& _t)
etk::CCout& etk::CCout::operator << (const etk::UChar& _t)
{
char output[5];
_t.getUtf8(output);

View File

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

View File

@ -7,7 +7,7 @@
*/
#include <etk/types.h>
#include <etk/UniChar.h>
#include <etk/UChar.h>
#include <etk/unicode.h>
#include <etk/DebugInternal.h>
@ -15,16 +15,16 @@
#include <etk/Vector.h>
#include <etk/Char.h>
const etk::UniChar etk::UniChar::Null('\0');
const etk::UniChar etk::UniChar::Return('\n');
const etk::UniChar etk::UniChar::CarrierReturn('\r');
const etk::UniChar etk::UniChar::Tabulation('\t');
const etk::UniChar etk::UniChar::Suppress((const char)127);
const etk::UniChar etk::UniChar::Delete((const char)8);
const etk::UniChar etk::UniChar::Space(' ');
const etk::UniChar etk::UniChar::Escape((const char)27);
const etk::UChar etk::UChar::Null('\0');
const etk::UChar etk::UChar::Return('\n');
const etk::UChar etk::UChar::CarrierReturn('\r');
const etk::UChar etk::UChar::Tabulation('\t');
const etk::UChar etk::UChar::Suppress((const char)127);
const etk::UChar etk::UChar::Delete((const char)8);
const etk::UChar etk::UChar::Space(' ');
const etk::UChar etk::UChar::Escape((const char)27);
void etk::UniChar::lower(void)
void etk::UChar::lower(void)
{
if( m_value>=(uint32_t)'A'
&& m_value<=(uint32_t)'Z') {
@ -32,7 +32,7 @@ void etk::UniChar::lower(void)
}
}
etk::UniChar etk::UniChar::toLower(void) const
etk::UChar etk::UChar::toLower(void) const
{
if( m_value>=(uint32_t)'A'
&& m_value<=(uint32_t)'Z') {
@ -41,7 +41,7 @@ etk::UniChar etk::UniChar::toLower(void) const
return m_value;
}
void etk::UniChar::upper(void)
void etk::UChar::upper(void)
{
if( m_value>=(uint32_t)'a'
&& m_value<=(uint32_t)'z') {
@ -49,7 +49,7 @@ void etk::UniChar::upper(void)
}
}
etk::UniChar etk::UniChar::toUpper(void) const
etk::UChar etk::UChar::toUpper(void) const
{
if( m_value>=(uint32_t)'a'
&& m_value<=(uint32_t)'z') {
@ -60,13 +60,13 @@ etk::UniChar etk::UniChar::toUpper(void) const
bool etk::UniChar::compareNoCase(const etk::UniChar& _obj) const
bool etk::UChar::compareNoCase(const etk::UChar& _obj) const
{
return toUpper() == _obj.toUpper();
}
etk::UniChar etk::UniChar::changeOrder(void) const
etk::UChar etk::UChar::changeOrder(void) const
{
if (m_value >= 'A' && m_value <= 'Z') {
return (m_value - (uint32_t)'A')*2 + 'A';
@ -84,7 +84,7 @@ etk::UniChar etk::UniChar::changeOrder(void) const
}
bool etk::UniChar::isWhiteChar(void) const
bool etk::UChar::isWhiteChar(void) const
{
if( m_value == ' '
|| m_value == '\t'
@ -95,7 +95,7 @@ bool etk::UniChar::isWhiteChar(void) const
return false;
}
bool etk::UniChar::isSpecialChar(void) const
bool etk::UChar::isSpecialChar(void) const
{
if( m_value < '0'
|| (m_value > '9' && m_value < 'A')
@ -106,7 +106,7 @@ bool etk::UniChar::isSpecialChar(void) const
return false;
}
bool etk::UniChar::isInteger(void) const
bool etk::UChar::isInteger(void) const
{
if( m_value>=(uint32_t)'0'
&& m_value<=(uint32_t)'9') {
@ -115,12 +115,12 @@ bool etk::UniChar::isInteger(void) const
return false;
}
int32_t etk::UniChar::toInt32(void) const
int32_t etk::UChar::toInt32(void) const
{
return m_value - (uint32_t)'0';
}
/*
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UniChar& _obj)
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UChar& _obj)
{
char output_UTF8[8];
unicode::convertUnicodeToUtf8(_obj, output_UTF8);
@ -130,7 +130,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UniChar& _obj)
*/
uint32_t etk::UniChar::getUtf8(void) const
uint32_t etk::UChar::getUtf8(void) const
{
uint32_t output = 0;
if (m_value <= 127) {
@ -164,7 +164,7 @@ uint32_t etk::UniChar::getUtf8(void) const
return output;
}
int8_t etk::UniChar::getUtf8(char _output[5]) const
int8_t etk::UChar::getUtf8(char _output[5]) const
{
uint32_t value = getUtf8();
if (0xFF >= value) {
@ -192,7 +192,7 @@ int8_t etk::UniChar::getUtf8(char _output[5]) const
}
}
/*
etk::Vector<int8_t> etk::UniChar::GetUtf8(void) const
etk::Vector<int8_t> etk::UChar::GetUtf8(void) const
{
etk::Vector<int8_t> ret;
uint32_t value = GetUtf8();
@ -246,7 +246,7 @@ uint8_t sizeElement(const char* _data, int32_t _lenMax)
}
int8_t etk::UniChar::setUtf8(const char* _input)
int8_t etk::UChar::setUtf8(const char* _input)
{
m_value = 0;
if (NULL == _input) {
@ -280,7 +280,7 @@ int8_t etk::UniChar::setUtf8(const char* _input)
}
}
int8_t etk::UniChar::theoricUTF8Len(const char _input)
int8_t etk::UChar::theoricUTF8Len(const char _input)
{
if((_input&0x80) == 0x00 ) {
return 1;
@ -297,7 +297,7 @@ int8_t etk::UniChar::theoricUTF8Len(const char _input)
return 1;
}
bool etk::UniChar::theoricUTF8First(const char _input)
bool etk::UChar::theoricUTF8First(const char _input)
{
// When started with the bit 0 then the size is signle element.
if((_input&0x80) == 0x00 ) {

View File

@ -9,9 +9,7 @@
#ifndef __ETK_UNI_CHAR_H__
#define __ETK_UNI_CHAR_H__
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
typedef enum {
@ -41,97 +39,91 @@ namespace etk
REGEXP_OPCODE_ERROR, // not used
} regExpPrivateSection_te;
class UniChar
{
class UChar {
public: // classic unicar code :
static const UniChar Null; //!< '\0'
static const UniChar Return; //!< '\n'
static const UniChar CarrierReturn; //!< '\r' CR
static const UniChar Tabulation; //!< '\t' TAB
static const UniChar Suppress; //!< BS (SUPPRESS)
static const UniChar Delete; //!< DEL
static const UniChar Space; //!< ' ' SPACE
static const UniChar Escape; //!< ESC Escape
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
private:
uint32_t m_value;
public:
// note : No preset at this element to prevent unneded set
UniChar(void) { };
UniChar(const etk::UniChar& _obj) :
m_value(_obj.m_value)
{ };
UniChar(const char _obj) :
m_value((uint32_t)_obj)
{ };
UniChar(const regExpPrivateSection_te _obj) :
m_value((uint32_t)_obj)
{ };
~UniChar(void) {}
UChar(void) {
};
UChar(const etk::UChar& _obj) :
m_value(_obj.m_value) {
};
UChar(const char _obj) :
m_value((uint32_t)_obj){
};
UChar(const regExpPrivateSection_te _obj) :
m_value((uint32_t)_obj) {
};
~UChar(void) {}
/*****************************************************
* = assigment
*****************************************************/
const etk::UniChar& operator= (const etk::UniChar& _obj )
{
const etk::UChar& operator= (const etk::UChar& _obj ) {
m_value = _obj.m_value;
return *this;
};
/*****************************************************
* == operator
*****************************************************/
bool operator== (const etk::UniChar& _obj) const
{
bool operator== (const etk::UChar& _obj) const {
return m_value == _obj.m_value;
};
bool compareNoCase(const etk::UniChar& _obj) const;
bool compareNoCase(const etk::UChar& _obj) const;
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const etk::UniChar& _obj) const
{
bool operator!= (const etk::UChar& _obj) const {
return m_value != _obj.m_value;
};
/*****************************************************
* > < >= <= operator
*****************************************************/
bool operator> (const etk::UniChar& _obj) const
{
bool operator> (const etk::UChar& _obj) const {
return m_value > _obj.m_value;
};
bool operator>= (const etk::UniChar& _obj) const
{
bool operator>= (const etk::UChar& _obj) const {
return m_value >= _obj.m_value;
};
bool operator< (const etk::UniChar& _obj) const
{
bool operator< (const etk::UChar& _obj) const {
return m_value < _obj.m_value;
};
bool operator<= (const etk::UniChar& _obj) const
{
bool operator<= (const etk::UChar& _obj) const {
return m_value <= _obj.m_value;
};
/*****************************************************
* += operator
*****************************************************/
const etk::UniChar& operator+= (const etk::UniChar& _obj)
{
const etk::UChar& operator+= (const etk::UChar& _obj) {
m_value += _obj.m_value;
return *this;
};
/*****************************************************
* + operator
*****************************************************/
etk::UniChar operator+ (const etk::UniChar& _obj) const
{
etk::UniChar tmp = *this;
etk::UChar operator+ (const etk::UChar& _obj) const {
etk::UChar tmp = *this;
tmp += _obj;
return tmp;
};
/*****************************************************
* -= operator
*****************************************************/
const etk::UniChar& operator-= (const etk::UniChar& _obj)
{
const etk::UChar& operator-= (const etk::UChar& _obj) {
if (_obj.m_value >= m_value) {
m_value = 0;
} else {
@ -142,9 +134,8 @@ namespace etk
/*****************************************************
* - operator
*****************************************************/
etk::UniChar operator- (const etk::UniChar& _obj) const
{
etk::UniChar tmp = *this;
etk::UChar operator- (const etk::UChar& _obj) const {
etk::UChar tmp = *this;
tmp -= _obj;
return tmp;
};
@ -166,11 +157,11 @@ namespace etk
int32_t toInt32(void) const;
void lower(void);
UniChar toLower(void) const;
UChar toLower(void) const;
void upper(void);
UniChar toUpper(void) const;
UChar toUpper(void) const;
UniChar changeOrder(void) const;
UChar changeOrder(void) const;
uint32_t get(void) const { return m_value; };
void set(uint32_t _val) { m_value = _val; };
@ -195,7 +186,5 @@ namespace etk
};
};
typedef etk::UniChar uniChar_t;
#endif

View File

@ -10,7 +10,7 @@
#include <etk/unicode.h>
#include <etk/Debug.h>
int32_t strlen(const etk::UniChar * _data)
int32_t strlen(const etk::UChar * _data)
{
if (NULL == _data) {
return 0;
@ -54,7 +54,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector<etk::UString>& _
etk::UString::UString(void)
{
//TK_INFO("new etk::UString()");
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
@ -73,8 +73,8 @@ etk::UString::UString(const char* _data, unicode::charset_te _inputCharset)
unicode::convertIsoToUnicode(_inputCharset, transformData, m_data);
}
if( 0 == m_data.size()
|| m_data[m_data.size()-1]!=etk::UniChar::Null) {
m_data.pushBack(etk::UniChar::Null);
|| m_data[m_data.size()-1]!=etk::UChar::Null) {
m_data.pushBack(etk::UChar::Null);
}
}
@ -131,7 +131,7 @@ etk::UString::UString(const bool _inputData, etk::UString::printMode_te _mode, b
}
break;
}
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
etk::UString::UString(const etk::UString& _obj)
@ -140,10 +140,10 @@ etk::UString::UString(const etk::UString& _obj)
m_data = _obj.m_data;
}
etk::UString::UString(const etk::UniChar& _inputData)
etk::UString::UString(const etk::UChar& _inputData)
{
m_data.pushBack(_inputData);
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
etk::UString::UString(const float _inputData)
@ -289,9 +289,9 @@ void etk::UString::setNumber(bool _negative, const uint64_t& _inputData, etk::US
//TK_ERROR (" " << ploppp);
}
if (m_data.size()==0) {
m_data.pushBack(etk::UniChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UniChar::Null) {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UChar::Null) {
m_data.pushBack(etk::UChar::Null);
}
//TK_ERROR(" convert : " << _inputData << " in : " << *this << " len=" << m_data.Size());
}
@ -316,7 +316,7 @@ void etk::UString::set(const uint64_t& _inputData, etk::UString::printMode_te _m
}
// multiple element add
etk::UString::UString(const etk::UniChar* _inputData, int32_t _len)
etk::UString::UString(const etk::UChar* _inputData, int32_t _len)
{
set(_inputData, _len);
}
@ -336,7 +336,7 @@ etk::UString::UString(const etk::Vector<int8_t>& _inputData)
set(_inputData);
}
etk::UString::UString(const etk::Vector<etk::UniChar>& _inputData)
etk::UString::UString(const etk::Vector<etk::UChar>& _inputData)
{
set(_inputData);
}
@ -348,7 +348,7 @@ void etk::UString::set(const etk::Vector<char>& _inputData)
clear();
return;
}
etk::Vector<etk::UniChar> output_Unicode;
etk::Vector<etk::UChar> output_Unicode;
unicode::convertUtf8ToUnicode(_inputData, output_Unicode);
set(output_Unicode);
}
@ -359,21 +359,21 @@ void etk::UString::set(const etk::Vector<int8_t>& _inputData)
clear();
return;
}
etk::Vector<etk::UniChar> output_Unicode;
etk::Vector<etk::UChar> output_Unicode;
unicode::convertUtf8ToUnicode(_inputData, output_Unicode);
set(output_Unicode);
}
void etk::UString::set(const etk::Vector<etk::UniChar>& _inputData)
void etk::UString::set(const etk::Vector<etk::UChar>& _inputData)
{
m_data = _inputData;
if (m_data.size()>0) {
if (m_data[m_data.size()-1] != etk::UniChar::Null) {
m_data.pushBack(etk::UniChar::Null);
if (m_data[m_data.size()-1] != etk::UChar::Null) {
m_data.pushBack(etk::UChar::Null);
}
} else {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
}
@ -383,7 +383,7 @@ void etk::UString::set(const char* _inputData, int32_t _len)
// clear all the data
m_data.clear();
if (NULL == _inputData) {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
// nothing to add ... ==> just exit
return;
}
@ -406,18 +406,18 @@ void etk::UString::set(const char* _inputData, int32_t _len)
unicode::convertUtf8ToUnicode(tmpChar, m_data);
}
if (m_data.size()==0) {
m_data.pushBack(etk::UniChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UniChar::Null) {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UChar::Null) {
m_data.pushBack(etk::UChar::Null);
}
}
void etk::UString::set(const etk::UniChar* _inputData, int32_t _len)
void etk::UString::set(const etk::UChar* _inputData, int32_t _len)
{
// clear all the data
m_data.clear();
if (NULL == _inputData) {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
// nothing to add ... ==> just exit
return;
}
@ -430,9 +430,9 @@ void etk::UString::set(const etk::UniChar* _inputData, int32_t _len)
m_data.pushBack(_inputData, _len);
}
if (m_data.size()==0) {
m_data.pushBack(etk::UniChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UniChar::Null) {
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
} else if (m_data[m_data.size()-1]!=etk::UChar::Null) {
m_data.pushBack(etk::UChar::Null);
}
}
@ -452,8 +452,8 @@ bool etk::UString::operator> (const etk::UString& _obj) const
if( this != &_obj ) {
for (int32_t iii=0; iii < m_data.size() && iii < _obj.m_data.size(); iii++) {
//TK_DEBUG(" compare : '" << (char)m_data[iii] << "'>'" << (char)_obj.m_data[iii] << "' ==> " << changeOrder(m_data[iii]) << ">" << changeOrder(_obj.m_data[iii]) << "");
etk::UniChar elemA = m_data[iii].changeOrder();
etk::UniChar elemB = _obj.m_data[iii].changeOrder();
etk::UChar elemA = m_data[iii].changeOrder();
etk::UChar elemB = _obj.m_data[iii].changeOrder();
if (elemA != elemB) {
if (elemA > elemB) {
return true;
@ -472,8 +472,8 @@ bool etk::UString::operator>= (const etk::UString& _obj) const
{
if( this != &_obj ) {
for (int32_t iii=0; iii < m_data.size() && iii < _obj.m_data.size(); iii++) {
etk::UniChar elemA = m_data[iii].changeOrder();
etk::UniChar elemB = _obj.m_data[iii].changeOrder();
etk::UChar elemA = m_data[iii].changeOrder();
etk::UChar elemB = _obj.m_data[iii].changeOrder();
if (elemA != elemB) {
if (elemA > elemB) {
return true;
@ -492,8 +492,8 @@ bool etk::UString::operator< (const etk::UString& _obj) const
{
if( this != &_obj ) {
for (int32_t iii=0; iii < m_data.size() && iii < _obj.m_data.size(); iii++) {
etk::UniChar elemA = m_data[iii].changeOrder();
etk::UniChar elemB = _obj.m_data[iii].changeOrder();
etk::UChar elemA = m_data[iii].changeOrder();
etk::UChar elemB = _obj.m_data[iii].changeOrder();
if (elemA != elemB) {
if (elemA < elemB) {
return true;
@ -512,8 +512,8 @@ bool etk::UString::operator<= (const etk::UString& _obj) const
{
if( this != &_obj ) {
for (int32_t iii=0; iii < m_data.size() && iii < _obj.m_data.size(); iii++) {
etk::UniChar elemA = m_data[iii].changeOrder();
etk::UniChar elemB = _obj.m_data[iii].changeOrder();
etk::UChar elemA = m_data[iii].changeOrder();
etk::UChar elemB = _obj.m_data[iii].changeOrder();
if (elemA != elemB) {
if (elemA < elemB) {
return true;
@ -577,7 +577,7 @@ const etk::UString& etk::UString::operator+= (const etk::UString &_obj)
// This previous include the \0 in case of the 2 UString are different...
if( this == &_obj ) {
// add the removed end UString
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
}
return *this;
@ -619,7 +619,7 @@ void etk::UString::add(int32_t _currentID, const char* _inputData)
}
void etk::UString::add(int32_t _currentID, const etk::UniChar* _inputData)
void etk::UString::add(int32_t _currentID, const etk::UChar* _inputData)
{
// get the input lenght
int32_t len = strlen(_inputData);
@ -638,19 +638,19 @@ void etk::UString::add(int32_t _currentID, const etk::UniChar* _inputData)
}
void etk::UString::add(int32_t _currentID, const etk::UniChar _inputData)
void etk::UString::add(int32_t _currentID, const etk::UChar _inputData)
{
etk::UniChar data[2];
etk::UChar data[2];
data[0] = _inputData;
data[1] = etk::UniChar::Null;
data[1] = etk::UChar::Null;
add(_currentID, data);
}
void etk::UString::append(const etk::UniChar& _inputData)
void etk::UString::append(const etk::UChar& _inputData)
{
m_data.popBack();
m_data.pushBack(_inputData);
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
@ -668,10 +668,10 @@ void etk::UString::remove(int32_t _currentID, int32_t _len)
void etk::UString::clear(void)
{
m_data.clear();
m_data.pushBack(etk::UniChar::Null);
m_data.pushBack(etk::UChar::Null);
}
int32_t etk::UString::findForward(const etk::UniChar _element, int32_t _startPos) const
int32_t etk::UString::findForward(const etk::UChar _element, int32_t _startPos) const
{
if (_startPos < 0) {
_startPos = 0;
@ -686,7 +686,7 @@ int32_t etk::UString::findForward(const etk::UniChar _element, int32_t _startPos
return -1;
}
int32_t etk::UString::findBack(const etk::UniChar _element, int32_t _startPos) const
int32_t etk::UString::findBack(const etk::UChar _element, int32_t _startPos) const
{
if (_startPos < 0) {
return -1;
@ -716,7 +716,7 @@ etk::UString etk::UString::extract(int32_t _posStart, int32_t _posEnd) const
_posEnd = size();
}
out.m_data = m_data.extract(_posStart, _posEnd);
out.m_data.pushBack(etk::UniChar::Null);
out.m_data.pushBack(etk::UChar::Null);
return out;
}
@ -749,13 +749,13 @@ etk::UString etk::UString::extractLine(int32_t _pos) const
stopPos = size();
}
out.m_data = m_data.extract(startPos, stopPos);
out.m_data.pushBack(etk::UniChar::Null);
out.m_data.pushBack(etk::UChar::Null);
return out;
}
etk::Vector<etk::UniChar> etk::UString::getVector(void)
etk::Vector<etk::UChar> etk::UString::getVector(void)
{
etk::Vector<etk::UniChar> out = m_data;
etk::Vector<etk::UChar> out = m_data;
out.popBack();
return out;
}
@ -826,7 +826,7 @@ etk::Char etk::UString::c_str(void) const
return tmpVar;
}
etk::Vector<etk::UString> etk::UString::split(const etk::UniChar& _val)
etk::Vector<etk::UString> etk::UString::split(const etk::UChar& _val)
{
etk::Vector<etk::UString> list;
int32_t lastStartPos=0;
@ -843,7 +843,7 @@ etk::Vector<etk::UString> etk::UString::split(const etk::UniChar& _val)
}
void etk::UString::replace(const etk::UniChar& _out, const etk::UniChar& _in)
void etk::UString::replace(const etk::UChar& _out, const etk::UChar& _in)
{
for(int32_t iii=0 ; iii<m_data.size() ; iii++) {
if (m_data[iii]==_out) {

View File

@ -28,7 +28,7 @@ namespace etk
printModeString,
} printMode_te;
private :
etk::Vector<etk::UniChar> m_data; //!< internal data is stored in the Unicode properties ...
etk::Vector<etk::UChar> m_data; //!< internal data is stored in the Unicode properties ...
public:
// Constructeurs
UString(void);
@ -39,7 +39,7 @@ namespace etk
// single element adding
UString(const bool _inputData, printMode_te _mode=printModeString, bool _preset=false);
UString(const etk::UniChar& _inputData);
UString(const etk::UChar& _inputData);
UString(const char* _data, unicode::charset_te _inputCharset);
UString(const float _inputData);
UString(const double _inputData);
@ -52,17 +52,17 @@ namespace etk
UString(const uint32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
UString(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set(_inputData, _mode, _preset, _leadingZero); };
// multiple element add
UString(const etk::UniChar* _inputData, int32_t _len = -1);
UString(const etk::UChar* _inputData, int32_t _len = -1);
UString(const char* _inputData, int32_t _len = -1);
UString(const etk::Vector<char>& _inputData);
UString(const etk::Vector<int8_t>& _inputData);
UString(const etk::Vector<etk::UniChar>& _inputData);
UString(const etk::Vector<etk::UChar>& _inputData);
// generic setter
void set(const etk::UniChar* _inputData, int32_t _len=-1);
void set(const etk::UChar* _inputData, int32_t _len=-1);
void set(const char* _inputData, int32_t _len=-1);
void set(const etk::Vector<char>& _inputData);
void set(const etk::Vector<int8_t>& _inputData);
void set(const etk::Vector<etk::UniChar>& _inputData);
void set(const etk::Vector<etk::UChar>& _inputData);
private:
void setNumber(bool _negative, const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset, int32_t _leadingZero);
public:
@ -93,7 +93,7 @@ namespace etk
* += operator
*****************************************************/
const etk::UString& operator+= (const etk::UString& _obj);
//const etk::UString& operator+= (const etk::UniChar& _obj);
//const etk::UString& operator+= (const etk::UChar& _obj);
/*****************************************************
* + operator
*****************************************************/
@ -117,10 +117,10 @@ namespace etk
/*****************************************************
* [] operator
*****************************************************/
const etk::UniChar& operator[] (esize_t _pos) const {
const etk::UChar& operator[] (esize_t _pos) const {
return m_data[_pos];
}
etk::UniChar& operator[] (esize_t _pos) {
etk::UChar& operator[] (esize_t _pos) {
return m_data[_pos];
}
@ -132,8 +132,8 @@ namespace etk
// End With ...
bool endWith(const etk::UString& _data, bool _caseSensitive=true) const ;
// Find element
int32_t findForward(const etk::UniChar _data, int32_t _startPos=0) const;
int32_t findBack(const etk::UniChar _data, int32_t _startPos=0x7FFFFFFF) const;
int32_t findForward(const etk::UChar _data, int32_t _startPos=0) const;
int32_t findBack(const etk::UChar _data, int32_t _startPos=0x7FFFFFFF) const;
bool isEmpty(void) const;
int32_t size(void) const;
@ -142,27 +142,27 @@ namespace etk
* Generic modification function
*****************************************************/
void add(int32_t _currentID, const char* _inputData);
void add(int32_t _currentID, const etk::UniChar* _inputData);
void add(int32_t _currentID, const etk::UniChar _inputData);
void add(int32_t _currentID, const etk::UChar* _inputData);
void add(int32_t _currentID, const etk::UChar _inputData);
void remove(int32_t _currentID, int32_t _len);
void clear(void);
void append(const etk::UniChar& _inputData);
void append(const etk::UChar& _inputData);
/**
* @brief Split a string in multiple separate by a specific char
* @param[in] _val Separate value of the string
* @return The list of all sthe string splited.
*/
etk::Vector<etk::UString> split(const etk::UniChar& _val);
etk::Vector<etk::UString> split(const etk::UChar& _val);
/**
* @brief Replace a char with an other
* @param[in] _out element to replace.
* @param[in] _in Element to set.
*/
void replace(const etk::UniChar& _out, const etk::UniChar& _in);
void replace(const etk::UChar& _out, const etk::UChar& _in);
etk::Vector<etk::UniChar> getVector(void);
etk::UniChar* pointer(void) { return &m_data[0]; };
etk::Vector<etk::UChar> getVector(void);
etk::UChar* pointer(void) { return &m_data[0]; };
etk::Char c_str(void) const;
@ -242,7 +242,7 @@ namespace etk
}
int32_t strlen(const etk::UniChar * _data);
int32_t strlen(const etk::UChar * _data);

View File

@ -11,7 +11,7 @@
#include <etk/UString.h>
#include <etk/Vector.h>
#include <etk/Hach.h>
#include <etk/Hash.h>
namespace etk
{

View File

@ -43,7 +43,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/UniChar.h>
#include <etk/UChar.h>
#if 0
typedef size_t esize_t;
#define ESIZE_T_IS_UNSIGNED

View File

@ -15,7 +15,7 @@
void unicode::convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, uniChar_t & _output_Unicode)
void unicode::convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, etk::UChar & _output_Unicode)
{
switch(_inputCharset)
{
@ -41,7 +41,7 @@ void unicode::convertIsoToUnicode(charset_te _inputCharset, const char _input_IS
}
void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _input_Unicode, char & _output_ISO)
void unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::UChar _input_Unicode, char & _output_ISO)
{
const uint32_t *tmpTable = NULL;
switch(_inputCharset)
@ -75,10 +75,10 @@ void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _inp
}
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode)
{
_output_Unicode.clear();
uniChar_t output;
etk::UChar output;
for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
_output_Unicode.pushBack(output);
@ -91,10 +91,10 @@ int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector
return _output_Unicode.size();
}
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode)
{
_output_Unicode.clear();
uniChar_t output;
etk::UChar output;
for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
_output_Unicode.pushBack(output);
@ -108,7 +108,7 @@ int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector
}
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_ISO)
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_ISO)
{
_output_ISO.clear();
char output[10];
@ -124,7 +124,7 @@ int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector
return _output_ISO.size();
}
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_ISO)
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_ISO)
{
_output_ISO.clear();
char output[10];
@ -142,7 +142,7 @@ int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_UTF8)
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_UTF8)
{
char output[10];
@ -158,7 +158,7 @@ int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unico
return _output_UTF8.size()-1;
}
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8)
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8)
{
char output[10];
@ -175,7 +175,7 @@ int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unico
}
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode)
{
char tmpData[20];
int32_t pos = 0;
@ -219,14 +219,14 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk:
tmpData[0] = '\0';
pos += 1;
}
uniChar_t tmpUnicode;
etk::UChar tmpUnicode;
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
}
return 0;
}
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode)
{
char tmpData[20];
int32_t pos = 0;
@ -270,14 +270,14 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, et
tmpData[0] = '\0';
pos += 1;
}
uniChar_t tmpUnicode;
etk::UChar tmpUnicode;
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
}
return 0;
}
int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode)
{
char tmpData[20];
int32_t pos = 0;
@ -325,7 +325,7 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniC
tmpData[0] = '\0';
pos += 1;
}
uniChar_t tmpUnicode;
etk::UChar tmpUnicode;
tmpUnicode.setUtf8(tmpData);
_output_Unicode.pushBack(tmpUnicode);
}
@ -336,7 +336,7 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniC
// Transform ISO <==> UTF-8
void unicode::convertIsoToUtf8(charset_te _inputCharset, const char _input_ISO, char * _output_UTF8)
{
uniChar_t tmpUnicode;
etk::UChar tmpUnicode;
// concert Iso in UniCode
convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode );
// convert UniCode in Utf-8
@ -346,7 +346,7 @@ void unicode::convertIsoToUtf8(charset_te _inputCharset, const char _input_ISO,
void unicode::convertUtf8ToIso(charset_te _inputCharset, const char * _input_UTF8, char & _output_ISO)
{
uniChar_t tmpUnicode;
etk::UChar tmpUnicode;
// convert Utf-8 in UniCode
tmpUnicode.setUtf8(_input_UTF8);
// concert UniCode in Iso

View File

@ -32,18 +32,18 @@ namespace unicode {
} charset_te;
// transform ISO <==> Unicode
void convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, uniChar_t & _output_Unicode);
void convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _input_Unicode, char & _output_ISO);
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode);
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode);
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_ISO);
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_ISO);
void convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, etk::UChar & _output_Unicode);
void convertUnicodeToIso(charset_te _inputCharset, const etk::UChar _input_Unicode, char & _output_ISO);
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode);
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<etk::UChar>& _output_Unicode);
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_ISO);
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_ISO);
// Transform UTF-8 <==> Unicode
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_UTF8);
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8);
int32_t convertUtf8ToUnicode( const etk::Vector<char>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
int32_t convertUtf8ToUnicode( const etk::Vector<int8_t>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
int32_t convertUtf8ToUnicode( const char * _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
int32_t convertUnicodeToUtf8( const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<char>& _output_UTF8);
int32_t convertUnicodeToUtf8( const etk::Vector<etk::UChar>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8);
int32_t convertUtf8ToUnicode( const etk::Vector<char>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode);
int32_t convertUtf8ToUnicode( const etk::Vector<int8_t>& _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode);
int32_t convertUtf8ToUnicode( const char * _input_UTF8, etk::Vector<etk::UChar>& _output_Unicode);
// Transform ISO <==> UTF-8
void convertIsoToUtf8( charset_te _inputCharset, const char _input_ISO, char * _output_UTF8);
void convertUtf8ToIso( charset_te _inputCharset, const char * _input_UTF8, char & _output_ISO);

View File

@ -13,7 +13,7 @@ def Create(target):
'etk/unicode.cpp',
'etk/unicodeTable.cpp',
'etk/Char.cpp',
'etk/UniChar.cpp',
'etk/UChar.cpp',
'etk/UString.cpp',
'etk/Stream.cpp',
'etk/RegExp.cpp',

View File

@ -22,7 +22,7 @@ void testVector(void)
}
void testUniChar(void)
void testUChar(void)
{
}
@ -151,7 +151,7 @@ int main(int argc, const char *argv[])
// the only one init for etk:
debug::setGeneralLevel(etk::LOG_LEVEL_VERBOSE);
//testVector();
//testUniChar();
//testUChar();
//testUString();
testHash();
//testFSNode();