[NEW] extract the etk toolbox from ewol ==> became external

This commit is contained in:
Edouard DUPIN 2012-11-10 14:32:14 +01:00
commit 167829eb73
43 changed files with 10033 additions and 0 deletions

28
Generic.mk Normal file
View File

@ -0,0 +1,28 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := etk
LOCAL_LIBRARIES := libzip
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -Wno-write-strings \
-Wall
else
LOCAL_CFLAGS := -Wno-write-strings \
-DMODE_RELEASE
endif
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST)
include $(BUILD_STATIC_LIBRARY)

68
etk/Debug.cpp Normal file
View File

@ -0,0 +1,68 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Debug.h>
#include <time.h>
// Max string size : (wide screan console nb caractere)
#define EDN_LOG_MAX_LENGTH 250
#define FUNCTION_NAME_SIZE (70)
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName)
{
char tmpName[FUNCTION_NAME_SIZE] = "";
if (NULL == className) {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s ",ligne, funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s ",libName, ligne, funcName);
}
} else {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s::%s ",ligne, className, funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s::%s ", libName, ligne, className, funcName);
}
}
tmpName[FUNCTION_NAME_SIZE-4] = ' ';
tmpName[FUNCTION_NAME_SIZE-3] = '|';
tmpName[FUNCTION_NAME_SIZE-2] = ' ';
tmpName[FUNCTION_NAME_SIZE-1] = '\0';
etk::cout << tmpName;
}
void TOOLS_DisplayTime(void)
{
char tmpdata[50];
#ifdef __TARGET_OS__Android
struct timeval now;
gettimeofday(&now, NULL);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
#else
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
#endif
etk::cout << tmpdata ;
}
#ifdef __TARGET_OS__Android
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_VERBOSE;
#else
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_ERROR;
#endif
void GeneralDebugSetLevel(etk::logLevel_te ccc) {
g_requestedLevel = ccc;
}

86
etk/Debug.h Normal file
View File

@ -0,0 +1,86 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Stream.h>
#include <etk/Types.h>
#ifndef __ETK_DEBUG_H__
#define __ETK_DEBUG_H__
// Log Message System For EDN
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName);
void TOOLS_DisplayTime(void);
#undef __class__
#define __class__ (NULL)
extern etk::logLevel_te g_requestedLevel;
void GeneralDebugSetLevel(etk::logLevel_te ccc);
#define ETK_DBG_COMMON(libName, info, data) do { \
if (info <= g_requestedLevel) { \
etk::cout << etk::cstart << info; \
TOOLS_DisplayTime(); \
TOOLS_DisplayFuncName(__LINE__, __class__, __func__, libName); \
etk::cout << data; \
etk::cout <<etk::endl; \
} \
}while(0)
#define ETK_CRITICAL(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data)
#if DEBUG_LEVEL > 0
# define ETK_WARNING(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_WARNING, data)
# define ETK_ERROR(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_ERROR, data)
#else
# define ETK_WARNING(libName, data) do {}while(0)
# define ETK_ERROR(libName, data) do {}while(0)
#endif
#if DEBUG_LEVEL > 1
# define ETK_INFO(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_INFO, data)
#else
# define ETK_INFO(libName, data) do {}while(0)
#endif
#if DEBUG_LEVEL > 2
# define ETK_DEBUG(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_DEBUG, data)
#else
# define ETK_DEBUG(libName, data) do {}while(0)
#endif
#if DEBUG_LEVEL > 3
# define ETK_VERBOSE(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_VERBOSE, data)
#else
# define ETK_VERBOSE(libName, data) do {}while(0)
#endif
#define ETK_ASSERT(libName, cond, data) do { \
if (!(cond)) { \
ETK_CRITICAL(libName, data); \
assert(!#cond); \
} \
} while (0)
#if DEBUG_LEVEL > 1
# define ETK_CHECK_INOUT(libName, cond) ETK_ASSERT(libName, (cond), "Internal input error : "#cond)
#elif DEBUG_LEVEL > 0
# define ETK_CHECK_INOUT(libName, cond) do { \
if (!(cond)) { \
ETK_CRITICAL(libName, "Internal input error : "#cond); \
} \
} while (0)
#else
# define ETK_CHECK_INOUT(libName, cond) do { } while (0)
#endif
#define ETK_TODO(libName, data) ETK_INFO(libName, "TODO : " << data)
#endif

9
etk/DebugInternal.cpp Normal file
View File

@ -0,0 +1,9 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
const char * etkLibName = "Etk ";

28
etk/DebugInternal.h Normal file
View File

@ -0,0 +1,28 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include "etk/Debug.h"
#ifndef __ETK_DEBUG_INTERNAL_H__
#define __ETK_DEBUG_INTERNAL_H__
extern const char * etkLibName;
#define TK_CRITICAL(data) ETK_CRITICAL(etkLibName, data)
#define TK_WARNING(data) ETK_WARNING(etkLibName, data)
#define TK_ERROR(data) ETK_ERROR(etkLibName, data)
#define TK_INFO(data) ETK_INFO(etkLibName, data)
#define TK_DEBUG(data) ETK_DEBUG(etkLibName, data)
#define TK_VERBOSE(data) ETK_VERBOSE(etkLibName, data)
#define TK_ASSERT(cond, data) ETK_ASSERT(etkLibName, cond, data)
#define TK_CHECK_INOUT(cond) ETK_CHECK_INOUT(etkLibName, cond)
#define TK_TODO(cond) ETK_TODO(etkLibName, cond)
#endif

104
etk/MessageFifo.h Normal file
View File

@ -0,0 +1,104 @@
/**
* @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 <etk/Vector.h>
namespace etk
{
template<class MY_TYPE=int32_t> class MessageFifo
{
private :
etk::Mutex m_mutex;
etk::Semaphore m_semaphore;
etk::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(0);
// 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.PushBack(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

403
etk/RegExp.cpp Normal file
View File

@ -0,0 +1,403 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/RegExp.h>
const etk::convertionTable_ts etk::constConvertionTable[] = {
// haveBackSlash, inputValue, newValue
{ false , '(' , REGEXP_OPCODE_PTHESE_IN},
{ true , '(' , (int16_t)'('},
{ false , ')' , REGEXP_OPCODE_PTHESE_OUT},
{ true , ')' , (int16_t)')'},
{ false , '[' , REGEXP_OPCODE_BRACKET_IN},
{ true , '[' , (int16_t)'['},
{ false , ']' , REGEXP_OPCODE_BRACKET_OUT},
{ true , ']' , (int16_t)']'},
{ false , '{' , REGEXP_OPCODE_BRACE_IN},
{ true , '{' , (int16_t)'{'},
{ false , '}' , REGEXP_OPCODE_BRACE_OUT},
{ true , '}' , (int16_t)'}'},
{ false , '-' , REGEXP_OPCODE_TO},
{ true , '-' , (int16_t)'-'},
{ false , '*' , REGEXP_OPCODE_STAR},
{ true , '*' , (int16_t)'*'},
{ false , '.' , REGEXP_OPCODE_DOT},
{ true , '.' , (int16_t)'.'},
{ false , '?' , REGEXP_OPCODE_QUESTION},
{ true , '?' , (int16_t)'?'},
{ false , '+' , REGEXP_OPCODE_PLUS},
{ true , '+' , (int16_t)'+'},
{ false , '|' , REGEXP_OPCODE_PIPE},
{ true , '|' , (int16_t)'|'},
{ false , '^' , REGEXP_OPCODE_START_OF_LINE},
{ true , '^' , (int16_t)'^'},
{ false , '$' , REGEXP_OPCODE_END_OF_LINE},
{ true , '$' , (int16_t)'$'},
{ true , 'd' , REGEXP_OPCODE_DIGIT},
{ true , 'D' , REGEXP_OPCODE_DIGIT_NOT},
{ true , 'l' , REGEXP_OPCODE_LETTER},
{ true , 'L' , REGEXP_OPCODE_LETTER_NOT},
{ true , 's' , REGEXP_OPCODE_SPACE},
{ true , 'S' , REGEXP_OPCODE_SPACE_NOT},
{ true , 'w' , REGEXP_OPCODE_WORD},
{ true , 'W' , REGEXP_OPCODE_WORD_NOT},
{ true , 'a' , (int16_t)'\a'},
{ true , 'b' , (int16_t)'\b'},
{ true , 'e' , 0x001B}, // Escape character <Esc>
{ true , 'f' , (int16_t)'\f'},
{ true , 'n' , (int16_t)'\n'},
{ true , 'r' , (int16_t)'\r'},
{ true , 't' , (int16_t)'\t'},
{ true , 'v' , (int16_t)'\v'},
{ true , '\\' , (int16_t)'\\'},
{ true , '&' , (int16_t)'&'},
{ true , '0' , (int16_t)'\0'},
{ true , '@' , REGEXP_OPCODE_NO_CHAR},
};
const int32_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ;
void etk::DisplayData(etk::Vector<char> &data)
{
int32_t i;
for (i=0; i<(int32_t)data.Size() ; i++) {
etk::cout<< (char)(data[i]&0x00FF );
}
}
void etk::DisplayElem(etk::Vector<int16_t> &data, int32_t start, int32_t stop)
{
int32_t i;
etk::cout<< ETK_BASH_COLOR_NORMAL;
for (i=start; i<(int32_t)data.Size() && i<stop ; i++) {
switch(data[i])
{
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<< (char)(data[i]&0x00FF ); break;
}
}
}
char * etk::levelSpace(int32_t level)
{
switch(level)
{
case 0: return (char*)"";
case 1: return (char*)" ";
case 2: return (char*)" ";
case 3: return (char*)" ";
case 4: return (char*)" ";
case 5: return (char*)" ";
case 6: return (char*)" ";
case 7: return (char*)" ";
case 8: return (char*)" ";
case 9: return (char*)" ";
case 10: return (char*)" ";
case 11: return (char*)" ";
case 12: return (char*)" ";
case 13: return (char*)" ";
case 14: return (char*)" ";
case 15: return (char*)" ";
case 16: return (char*)" ";
default: return (char*)" ";
}
}
int32_t etk::GetLenOfPTheseElem(etk::Vector<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_PTHESE_OUT == data[pos]
|| REGEXP_OPCODE_PIPE == data[pos]) {
return 0;
}
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
TK_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( REGEXP_OPCODE_PTHESE_OUT == data[pos]
|| REGEXP_OPCODE_PIPE == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
TK_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
return pos - startPos;
}
int32_t etk::GetLenOfPThese(etk::Vector<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_PTHESE_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_PTHESE_IN == data[pos])
{
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
TK_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos-1;
if (0 >= sizeInside) {
TK_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
} else {
return -1;
}
return 0;
}
int32_t etk::GetLenOfBracket(etk::Vector<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_BRACKET_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_BRACKET_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_BRACKET_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
TK_ERROR("Error in the [...] no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( REGEXP_OPCODE_TO != data[pos]
&& ( 0 > data[pos]
|| 0xFF < data[pos]) )
{
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
int32_t etk::GetLenOfBrace(etk::Vector<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_BRACE_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_BRACE_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_BRACE_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
TK_ERROR("Error in the {...} no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( ',' != data[pos]
&& ( '0' > data[pos]
|| '9' < data[pos]) )
{
TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
int32_t etk::GetLenOfNormal(etk::Vector<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// find size ...
while (pos < (int32_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:
{
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
TK_ERROR("Error in the normal data : no data ...");
}
return sizeInside;
}
break;
default :
// nothing to do ...
break;
}
pos++;
}
return pos - startPos ;
}
bool etk::ParseBrace(etk::Vector<int16_t> &data, int32_t &min, int32_t &max)
{
//TK_INFO("parse {...} in "; DisplayElem(data); );
int32_t k=0;
int32_t firstElement = 0;
int32_t SecondElement = 0;
while(k<data.Size()) {
if (',' == (char)data[k]) {
k++;
break;
} if ('}' == (char)data[k]) {
SecondElement = firstElement;
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
firstElement *=10;
firstElement += (char)data[k] - '0';
} else {
TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
if (k==data.Size()) {
SecondElement = firstElement;
}
while(k<data.Size()) {
if (',' == (char)data[k]) {
TK_ERROR("Can not find a second , in {} at pos " << k);
return false;
} if ('}' == (char)data[k]) {
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
SecondElement *=10;
SecondElement += (char)data[k] - '0';
} else {
TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
allIsSet:
if (SecondElement == 0 && firstElement != 0) {
min = 0;
max = firstElement;
} else {
min = firstElement;
max = SecondElement;
}
if (min > max) {
TK_ERROR("Minimum=" << min << " can not be < maximum=" << max );
return false;
}
return true;
}

2109
etk/RegExp.h Normal file

File diff suppressed because it is too large Load Diff

15
etk/Stream.cpp Normal file
View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Stream.h>
etk::CCout etk::cout;
etk::CEndl etk::endl;
etk::CHex etk::hex;
etk::CStart etk::cstart;

279
etk/Stream.h Normal file
View File

@ -0,0 +1,279 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_STREAM_DEC_H__
#define __ETK_STREAM_DEC_H__
namespace etk{
typedef enum {
LOG_LEVEL_NONE,
LOG_LEVEL_CRITICAL,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_VERBOSE
} logLevel_te;
};
#endif
#include <string.h>
#include <etk/Types.h>
#include <etk/os/Mutex.h>
#ifndef __ETK_STREAM_H__
#define __ETK_STREAM_H__
#if defined(__TARGET_OS__Android)
# include <android/log.h>
# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "EWOL", __VA_ARGS__))
# define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "EWOL", __VA_ARGS__))
# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "EWOL", __VA_ARGS__))
#endif
#define MAX_LOG_SIZE (16000)
#define MAX_LOG_SIZE_TMP (512)
//regular colors
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
#define ETK_BASH_COLOR_RED "\e[0;31m"
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
//emphasized (bolded) colors
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
//background colors
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
#define ETK_BASH_COLOR_BG_RED "\e[41m"
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
// Return to the normal color setings
#define ETK_BASH_COLOR_NORMAL "\e[0m"
//go to the Top of bash
#define ETK_BASH_GO_TOP "\e[0;0f"
namespace etk{
class CEndl{};
class CHex{};
class CStart{};
class CCout{
private:
bool hex;
char m_tmpChar[MAX_LOG_SIZE+1];
char tmp[MAX_LOG_SIZE_TMP];
etk::Mutex m_mutex;
public:
CCout(){
hex=false;
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
};
~CCout() {
};
CCout& operator << (CHex t) {
hex = true;
return *this;
}
CCout& operator << (int t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (unsigned int t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
/*
CCout& operator << (uniChar_t t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
*/
CCout& operator << (long t) {
if (true == hex) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X", (unsigned int)t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
} else {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (long long t) {
if (true == hex) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X%08X", (unsigned int)(t>>32), (unsigned int)(t));
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
} else {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (double t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (float t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (const char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (char t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (bool t) {
if (t) {
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
} else {
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (Vector2D<float> t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (Vector2D<int32_t> t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i)", t.x, t.y);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (Vector3D<float> t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (Vector3D<int32_t> t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i,%i)", t.x, t.y, t.z);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (clipping_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
hex = false;
return *this;
}
CCout& operator << (CStart ccc) {
m_mutex.Lock();
return *this;
}
CCout& operator << (logLevel_te ccc) {
switch (ccc)
{
case LOG_LEVEL_CRITICAL:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_BOLD_RED, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[C]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_ERROR:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_RED, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[E]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_WARNING:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_MAGENTA, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[W]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_INFO:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_CYAN, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[I]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_DEBUG:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_YELLOW, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[D]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_VERBOSE:
#if !defined(__TARGET_OS__Windows)
strncat(m_tmpChar, ETK_BASH_COLOR_WHITE, MAX_LOG_SIZE);
#endif
strncat(m_tmpChar, "[V]", MAX_LOG_SIZE);
break;
default:
strncat(m_tmpChar, "[?]", MAX_LOG_SIZE);
break;
}
return *this;
}
CCout& operator << (etk::CEndl t) {
strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE);
strncat(m_tmpChar, "\n", MAX_LOG_SIZE);
m_tmpChar[MAX_LOG_SIZE] = '\0';
#if defined(__TARGET_OS__Android)
LOGI("%s", m_tmpChar);
#else
printf("%s", m_tmpChar);
#endif
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
m_mutex.UnLock();
return *this;
}
};
extern etk::CCout cout;
extern etk::CEndl endl;
extern etk::CHex hex;
extern etk::CStart cstart;
}
#endif

69
etk/Types.h Normal file
View File

@ -0,0 +1,69 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TYPES_H__
#define __ETK_TYPES_H__
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#ifndef __int8_t_defined
# define __int8_t_defined
typedef signed char int8_t;
typedef signed short int int16_t;
typedef int int32_t;
typedef signed long long int int64_t;
#endif
#ifndef __uint8_t_defined
# define __uint8_t_defined
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
# if __WORDSIZE == 64
typedef unsigned long int uint64_t;
# else
typedef unsigned long long int uint64_t;
# endif
#endif
typedef uint32_t uniChar_t;
typedef enum {
ERR_NONE = 0, //!< No error, luckily everything went fine
ERR_FAIL, //!< Miscellaneous failure
ERR_INVAL, //!< Invalid entry parameter
ERR_MEM, //!< Dynamic memory allocation failure
ERR_TIMEOUT, //!< Request time out
ERR_BUSY, //!< Element curently Busy
}erreurCode_te;
#define etk_min(elemA, elemB) (((elemA)<(elemB)) ? (elemA) : (elemB))
#define etk_max(elemA, elemB) (((elemA)<(elemB)) ? (elemB) : (elemA))
#define etk_avg(minimim, elem, maximum) (((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem))
typedef struct {
float u;
float v;
}texCoord_ts;
typedef struct {
float x;
float y;
float w;
float h;
}clipping_ts;
#include <etk/math/math.h>
#endif

574
etk/UString.cpp Normal file
View File

@ -0,0 +1,574 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/UString.h>
#include <etk/os/Memory.h>
#include <etk/unicode.h>
int32_t strlen(const uniChar_t * data)
{
if (NULL == data) {
return 0;
}
int32_t iii=0;
while (*data != 0) {
data++;
iii++;
if (iii > 0x7FFFFFF0) {
return iii;
}
}
return iii;
}
#undef __class__
#define __class__ "etk::UString"
etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj)
{
etk::Vector<char> output_UTF8;
unicode::convertUnicodeToUtf8(obj.m_data, output_UTF8);
output_UTF8.PushBack('\0');
os << &output_UTF8[0];
return os;
}
etk::UString::~UString(void)
{
//m_data.Clear();
//m_dataUtf8.Clear();
}
etk::UString::UString(void)
{
//TK_INFO("new etk::UString()");
m_data.Clear();
m_data.PushBack('\0');
}
etk::UString::UString(const char* inputData, int32_t len)
{
m_data.Clear();
m_data.PushBack('\0');
Set(inputData, len);
}
etk::UString::UString(const uniChar_t* inputData, int32_t len)
{
m_data.Clear();
m_data.PushBack('\0');
Set(inputData, len);
}
/*
etk::UString::UString(const uniChar_t inputData)
{
m_data.Clear();
m_data.PushBack('\0');
Set(&inputData, 1);
}
*/
void etk::UString::Set(const char * inputData, int32_t len)
{
if (NULL == inputData) {
// nothing to add ...
return;
}
// overwrite the len if needed :
if ((-1) == len) {
len = strlen(inputData);
}
// convert the string
etk::Vector<char> tmpChar;
for (int32_t iii=0; iii<len; iii++) {
tmpChar.PushBack(inputData[iii]);
}
// add it ...
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
unicode::convertUtf8ToUnicode(tmpChar, m_data);
// add the last '\0'
m_data.PushBack('\0');
}
}
void etk::UString::Set(const uniChar_t * inputData, int32_t len)
{
if (NULL == inputData) {
// nothing to add ...
return;
}
// overwrite the len if needed :
if ((-1) == len) {
len = strlen(inputData);
}
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data.PushBack(inputData, len);
// add the last '\0'
m_data.PushBack('\0');
}
}
etk::UString::UString(char inputData)
{
char tmpVal[2];
// generate the UString :
sprintf(tmpVal, "%c", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(int inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(unsigned int inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(float inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%f", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(double inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%lf", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(const etk::UString &etkS)
{
//etk_INFO("Constructeur de recopie");
m_data = etkS.m_data;
}
const etk::UString& etk::UString::operator= (const etk::UString &etkS )
{
//TK_INFO("OPERATOR de recopie");
if( this != &etkS ) {
m_data = etkS.m_data;
}
return *this;
}
const etk::UString& etk::UString::operator= (etk::Vector<char> inputData)
{
etk::Vector<uniChar_t> output_Unicode;
unicode::convertUtf8ToUnicode(inputData, output_Unicode);
*this = output_Unicode;
return *this;
}
const etk::UString& etk::UString::operator= (etk::Vector<int8_t> inputData)
{
etk::Vector<uniChar_t> output_Unicode;
unicode::convertUtf8ToUnicode(inputData, output_Unicode);
*this = output_Unicode;
return *this;
}
const etk::UString& etk::UString::operator= (etk::Vector<uniChar_t> inputData)
{
m_data = inputData;
if (m_data.Size()>0) {
if (m_data[m_data.Size()-1] != '\0') {
m_data.PushBack('\0');
}
}
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
return *this;
}
uniChar_t changeOrder(uniChar_t elemA)
{
if (elemA >= 'A' && elemA <= 'Z') {
return (elemA - (uniChar_t)'A')*2 + 'A';
}
if (elemA >= 'a' && elemA <= 'z') {
return (elemA - (uniChar_t)'a')*2 + 'A' + 1;
}
if (elemA >= ':' && elemA <= '@') {
return elemA + 52;
}
if (elemA >= '[' && elemA <= '`') {
return elemA +26;
}
return elemA;
}
bool etk::UString::operator> (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
//TK_DEBUG(" compare : '" << (char)m_data[iii] << "'>'" << (char)etkS.m_data[iii] << "' ==> " << changeOrder(m_data[iii]) << ">" << changeOrder(etkS.m_data[iii]) << "");
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA > elemB) {
return true;
}
return false;
}
}
if (m_data.Size() > etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator>= (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA > elemB) {
return true;
}
return false;
}
}
if (m_data.Size() >= etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator< (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA < elemB) {
return true;
}
return false;
}
}
if (m_data.Size() < etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator<= (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA < elemB) {
return true;
}
return false;
}
}
if (m_data.Size() <= etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator== (const etk::UString& etkS) const
{
if( this != &etkS ) {
if (etkS.m_data.Size() != m_data.Size()) {
//TK_DEBUG(" not the same size : " << etkS.m_data.Size() << "!=" << m_data.Size());
return false;
}
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
//TK_DEBUG(" check : " << etkS.m_data[iii] << "!=" << m_data[iii]);
if (etkS.m_data[iii]!= m_data[iii]){
return false;
}
}
return true;
}
return true;
}
bool etk::UString::operator!= (const etk::UString& etkS) const
{
return !(*this == etkS);
}
const etk::UString& etk::UString::operator+= (const etk::UString &etkS)
{
if (0 < etkS.Size()) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data += etkS.m_data;
// This previous include the \0 in case of the 2 UString are different...
if( this == &etkS ) {
// add the removed end UString
m_data.PushBack('\0');
}
}
return *this;
}
etk::UString etk::UString::operator+ (const etk::UString &etkS)
{
etk::UString temp;
//TK_INFO(" UString(arg) : \"" << etkS.m_data << "\"");
//TK_INFO(" UString(direct) : \"" << m_data << "\"");
temp += *this;
temp += etkS;
return temp;
}
bool etk::UString::IsEmpty(void) const
{
if(1 >= m_data.Size() ) {
return true;
} else {
return false;
}
}
int32_t etk::UString::Size(void) const
{
if (m_data.Size() == 0) {
return 0;
} else {
return m_data.Size() - 1;
}
}
void etk::UString::Add(int32_t currentID, const char* inputData)
{
etk::UString tmpString(inputData);
Add(currentID, tmpString.pointer() );
}
void etk::UString::Add(int32_t currentID, const uniChar_t* inputData)
{
// get the input lenght
int32_t len = strlen(inputData);
if (0 == len) {
TK_WARNING("no data to add on the current UString");
return;
} else if (currentID < 0) {
TK_WARNING("Curent ID(" << currentID << ") < 0 ==> Add at the start");
currentID = 0;
} else if (currentID > Size() ) {
TK_ERROR("Curent ID(" << currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ...");
m_data.PushBack(inputData, len);
return;
}
m_data.Insert(currentID, inputData, len);
}
void etk::UString::Add(int32_t currentID, const uniChar_t inputData)
{
uniChar_t data[2];
data[0] = inputData;
data[1] = 0;
Add(currentID, data);
}
void etk::UString::Remove(int32_t currentID, int32_t len)
{
if (0 >= len) {
TK_ERROR("no data to remove on the current UString");
return;
}
// TODO : check the size of the data
m_data.EraseLen(currentID, len);
}
void etk::UString::Clear(void)
{
m_data.Clear();
m_data.PushBack('\0');
}
int32_t etk::UString::FindForward(const char element, int32_t startPos) const
{
return FindForward((uniChar_t)element, startPos);
}
int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos) const
{
if (startPos < 0) {
startPos = 0;
} else if (startPos >= Size() ) {
return -1;
}
for (int32_t iii=startPos; iii< Size(); iii++) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
int32_t etk::UString::FindBack(const char element, int32_t startPos) const
{
return FindBack((uniChar_t)element, startPos);
}
int32_t etk::UString::FindBack(const uniChar_t element, int32_t startPos) const
{
if (startPos < 0) {
return -1;
} else if (startPos >= Size() ) {
startPos = Size();
}
for (int32_t iii=startPos; iii>=0; iii--) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
etk::UString etk::UString::Extract(int32_t posStart, int32_t posEnd) const
{
etk::UString out;
if (posStart < 0) {
posStart = 0;
} else if (posStart >= Size() ) {
return out;
}
if (posEnd < 0) {
return out;
} else if (posEnd >= Size() ) {
posEnd = Size();
}
out.m_data = m_data.Extract(posStart, posEnd);
out.m_data.PushBack('\0');
return out;
}
etk::Vector<uniChar_t> etk::UString::GetVector(void)
{
etk::Vector<uniChar_t> out = m_data;
out.PopBack();
return out;
}
bool etk::UString::StartWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for (int32_t iii=0; iii<data.Size(); iii++) {
if (data[iii] != m_data[iii]) {
return false;
}
}
return true;
}
bool etk::UString::EndWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for( int32_t iii=Size()-1, jjj=data.Size()-1;
iii>=0 && jjj>=0;
iii--, jjj--) {
if (data[jjj] != m_data[iii]) {
return false;
}
}
return true;
}
char * etk::UString::c_str(void)
{
// UTF8 generation :
m_dataUtf8.Clear();
unicode::convertUnicodeToUtf8(m_data, m_dataUtf8);
m_dataUtf8.PushBack('\0');
return &m_dataUtf8[0];
}

141
etk/UString.h Normal file
View File

@ -0,0 +1,141 @@
/**
* @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/DebugInternal.h>
#include <etk/Stream.h>
#include <etk/Vector.h>
namespace etk
{
class UString
{
public:
// Constructeurs
UString(void);
UString(const uniChar_t* inputData, int32_t len = -1);
UString(const char* inputData, int32_t len = -1);
void Set(const uniChar_t* inputData, int32_t len=-1);
void Set(const char* inputData, int32_t len=-1);
// basic convertion integer en string
UString(char inputData);
UString(int inputData);
UString(unsigned int inputData);
UString(float inputData);
UString(double inputData);
UString(const etk::UString &etkS);
//UString(const uniChar_t inputData);
// destructor :
~UString(void);
/*****************************************************
* = assigment
*****************************************************/
const etk::UString& operator= (const etk::UString &etkS );
const etk::UString& operator= (etk::Vector<char> inputData);
const etk::UString& operator= (etk::Vector<int8_t> inputData);
const etk::UString& operator= (etk::Vector<uniChar_t> inputData);
/*****************************************************
* == operator
*****************************************************/
bool operator== (const etk::UString& etkS) const;
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const etk::UString& etkS) const;
/*****************************************************
* > < >= <= operator
*****************************************************/
bool operator> (const etk::UString& etkS) const;
bool operator>= (const etk::UString& etkS) const;
bool operator< (const etk::UString& etkS) const;
bool operator<= (const etk::UString& etkS) const;
/*****************************************************
* += operator
*****************************************************/
const etk::UString& operator+= (const etk::UString &etkS);
/*****************************************************
* + operator
*****************************************************/
etk::UString operator+ (const etk::UString &etkS);
/*****************************************************
* << operator
*****************************************************/
/*
const etk::UString& operator <<= (const char input);
const etk::UString& operator <<= (const int input);
const etk::UString& operator <<= (const unsigned int input);
*/
/*****************************************************
* >> operator
*****************************************************/
/*****************************************************
* Cout << operator
*****************************************************/
friend etk::CCout& operator <<( etk::CCout &os,const etk::UString &obj);
/*****************************************************
* [] operator
*****************************************************/
const uniChar_t& operator[] (int32_t pos) const {
return m_data[pos];
}
uniChar_t& operator[] (int32_t pos) {
return m_data[pos];
}
/*****************************************************
* toolbox
*****************************************************/
// Start With ...
bool StartWith(const etk::UString& data);
// End With ...
bool EndWith(const etk::UString& data);
// Find element
int32_t FindForward(const char data, int32_t startPos=0) const;
int32_t FindForward(const uniChar_t data, int32_t startPos=0) const;
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF) const;
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF) const;
bool IsEmpty(void) const;
int32_t Size(void) const;
/*****************************************************
* Generic modification function
*****************************************************/
void Add(int32_t currentID, const char* inputData);
void Add(int32_t currentID, const uniChar_t* inputData);
void Add(int32_t currentID, const uniChar_t inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
etk::Vector<uniChar_t> GetVector(void);
uniChar_t * pointer(void) { return &m_data[0]; };
// generate temporary allocation (auto unallocated...)
char * c_str(void);
// Sting operation :
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF) const;
private :
etk::Vector<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
etk::Vector<char> m_dataUtf8; //!< Tmp data for the Utf8Data() function
};
etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj);
}
int32_t strlen(const uniChar_t * data);
#endif

776
etk/Vector.h Normal file
View File

@ -0,0 +1,776 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_VECTOR_H__
#define __ETK_VECTOR_H__
#include <etk/DebugInternal.h>
#include <etk/Types.h>
#include <etk/os/Memory.h>
#undef __class__
#define __class__ "etk::Vector"
namespace etk
{
/**
* @brief Vector classes ...
*
* @tparam[in] MY_TYPE class type of the current element.
*
* m_data
* <------------ m_dataSize ------------>
* ----------------------------------------
* | 0 |
* |--------------------------------------|
* | 1 |
* |--------------------------------------|
* | 2 |
* |--------------------------------------|
* m_size | 3 |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* m_allocated | x |
* ----------------------------------------
*
*/
template<class MY_TYPE=int32_t> class Vector
{
public:
class Iterator
{
// Private data :
private:
int32_t m_current; //!< curent Id on the vector
Vector<MY_TYPE> * m_vector; //!< Pointer on the curent element of the vectorBin
public:
/**
* @brief Basic itarator constructor with no link with an etkVector
*/
Iterator():
m_current(-1),
m_vector(NULL)
{
// nothing to do ...
}
/**
* @brief Recopy constructor on a specific etkVector.
* @param[in] otherIterator The Iterator that might be copy
*/
Iterator(const Iterator & otherIterator):
m_current(otherIterator.m_current),
m_vector(otherIterator.m_vector)
{
// nothing to do ...
}
/**
* @brief Asignation operator.
* @param[in] otherIterator The Iterator that might be copy
* @return reference on the curent Iterator
*/
Iterator& operator=(const Iterator & otherIterator)
{
m_current = otherIterator.m_current;
m_vector = otherIterator.m_vector;
return *this;
}
/**
* @brief Basic destructor
*/
~Iterator()
{
m_current = -1;
m_vector = NULL;
}
/**
* @brief basic boolean cast
* @return true if the element is present in the etkVector size
*/
operator bool ()
{
if( 0 <= m_current
&& m_current < m_vector->Size() )
{
return true;
} else {
return false;
}
}
/**
* @brief Incremental operator
* @return Reference on the current iterator incremented
*/
Iterator& operator++ ()
{
if( NULL != m_vector
&& m_current < m_vector->Size() )
{
m_current++;
}
return *this;
}
/**
* @brief Decremental operator
* @return Reference on the current iterator decremented
*/
Iterator& operator-- ()
{
if (m_current >= 0) {
m_current--;
}
return *this;
}
/**
* @brief Incremental operator
* @return Reference on a new iterator and increment the other one
*/
Iterator operator++ (int32_t)
{
Iterator it(*this);
++(*this);
return it;
}
/**
* @brief Decremental operator
* @return Reference on a new iterator and decrement the other one
*/
Iterator operator-- (int32_t)
{
Iterator it(*this);
--(*this);
return it;
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator-> () const
{
TK_CHECK_INOUT(m_current >= 0 && m_current < m_vector->Size());
return &m_vector->Get(m_current);
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator* () const
{
TK_CHECK_INOUT(m_current >= 0 && m_current < m_vector->Size());
return m_vector->Get(m_current);
}
private:
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Iterator(Vector<MY_TYPE> * Evb, int32_t pos):
m_current(pos),
m_vector(Evb)
{
// nothing to do ...
}
friend class Vector;
};
private:
MY_TYPE * m_data; //!< pointer on the curetn table of Data
int32_t m_size; //!< nb Element in the buffer
int32_t m_allocated; //!< Current allocated size
public:
/**
* @brief Create an empty vector
* @param[in] count Minimum request size of the Buffer
*/
Vector(int32_t count = 0):
m_data(NULL),
m_size(0),
m_allocated(0)
{
ChangeAllocation(count);
}
/**
* @brief Re-copy constructor (copy all needed data)
* @param[in] Evb Vector that might be copy
*/
Vector(const etk::Vector<MY_TYPE> & Evb)
{
m_allocated = Evb.m_allocated;
m_size = Evb.m_size;
m_data = NULL;
//TK_DEBUG("USE Specific vector allocator ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
// allocate all same data
m_data = new MY_TYPE[m_allocated];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation ... might nor work corectly anymore");
return;
}
// Copy all data ...
for(int32_t iii=0; iii<m_allocated; iii++) {
// copy operator ...
m_data[iii] = Evb.m_data[iii];
}
}
/**
* @brief Destructor of the current Class
*/
~Vector(void)
{
if (NULL!=m_data) {
delete [] m_data;
m_data = NULL;
}
m_allocated = 0;
m_size = 0;
}
/**
* @brief Re-copy operator
* @param[in] Evb Vector that might be copy
* @return reference on the curent re-copy vector
*/
Vector& operator=(const etk::Vector<MY_TYPE> & Evb)
{
//TK_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
if( this != &Evb ) // avoid copy to itself
{
if (NULL!=m_data) {
delete[] m_data;
m_data = NULL;
}
// Set the new value
m_allocated = Evb.m_allocated;
m_size = Evb.m_size;
// allocate all same data
m_data = new MY_TYPE[m_allocated];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation ... might nor work corectly anymore");
return *this;
}
for(int32_t iii=0; iii<m_allocated; iii++) {
// copy operator ...
m_data[iii] = Evb.m_data[iii];
}
}
// Return the curent pointer
return *this;
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
Vector& operator+= (const etk::Vector<MY_TYPE> & Evb) // += operator
{
int32_t nbElememt = Evb.Size();
int32_t idx = m_size;
Resize(m_size+nbElememt);
if (m_size<=idx) {
TK_CRITICAL("allocation error");
return *this;
}
for(int32_t iii=0; iii<nbElememt; iii++) {
// copy operator ...
m_data[idx+iii] = Evb.m_data[iii];
}
// Return the curent pointer
return *this;
}
/**
* @brief Get the number of element in the vector
* @return The number requested
*/
int32_t Size() const
{
return m_size;
}
/**
* @brief Get the number of element in the vector
* @return The number requested
*/
void ReSize(int32_t newSize, MY_TYPE& basicElement)
{
int32_t idx = m_size;
Resize(newSize);
if (m_size != newSize) {
TK_CRITICAL("error to resize vector");
return;
}
if (newSize > idx) {
// initialize data ...
for(int32_t iii=idx; iii<newSize; iii++) {
m_data[iii] = basicElement;
}
}
}
/**
* @brief Get the Allocated size in the vector
* @return The size of allocation
*/
int32_t AllocatedSize() const
{
return m_allocated;
}
/**
* @brief Get a current element in the vector
* @param[in] pos Desired position read
* @return Reference on the Element
*/
MY_TYPE& Get(int32_t pos)
{
return m_data[pos];
}
/**
* @brief Get an copy Element an a special position
* @param[in] pos Position in the vector that might be get [0..Size()]
* @return An reference on the copy of selected element
*/
MY_TYPE& operator[] (int32_t pos)
{
return Get(pos);
}
/**
* @brief Get an Element an a special position
* @param[in] pos Position in the vector that might be get [0..Size()]
* @return An reference on the selected element
*/
const MY_TYPE& operator[] (int32_t pos) const
{
return m_data[pos];
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
void PushBack(const MY_TYPE& item)
{
int32_t idx = m_size;
Resize(m_size+1);
if (idx < m_size) {
m_data[idx] = item;
} else {
TK_ERROR("Resize does not work corectly ... not added item");
}
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
void PushBack(const MY_TYPE * item, int32_t nbElement)
{
if (NULL == item) {
return;
}
int32_t idx = m_size;
Resize(m_size+nbElement);
if (idx > m_size) {
TK_ERROR("Resize does not work corectly ... not added item");
return;
}
for (int32_t iii=0; iii<nbElement; iii++) {
m_data[idx+iii] = item[iii];
}
}
/**
* @brief Remove the last element of the vector
*/
void PopBack(void)
{
if(m_size>0) {
Resize(m_size-1);
}
}
/**
* @brief Remove all alement in the current vector
*/
void Clear(void)
{
if(m_size>0) {
Resize(0);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Insert(int32_t pos, const MY_TYPE * item, int32_t nbElement)
{
if (pos>m_size) {
TK_WARNING(" can not insert Element at this position : " << pos << " > " << m_size << " add it at the end ... ");
PushBack(item, nbElement);
return;
}
int32_t idx = m_size;
// Request resize of the current buffer
Resize(m_size+nbElement);
if (idx>=m_size) {
TK_ERROR("Resize does not work corectly ... not added item");
return;
}
// move curent data (after the position)
int32_t sizeToMove = (idx - pos);
if ( 0 < sizeToMove) {
for (int32_t iii=1; iii<=sizeToMove; iii++) {
m_data[m_size-iii] = m_data[idx-iii];
}
}
// affectation of all input element
for (int32_t iii=0; iii<nbElement; iii++) {
m_data[pos+iii] = item[iii];
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Insert(int32_t pos, const MY_TYPE& item)
{
Insert(pos, &item, 1);
}
/**
* @brief Remove N element
*
* @param[in] pos Position to remove the data
* @param[in] nbElement number of element to remove
*
* @return ---
*
*/
void EraseLen(int32_t pos, int32_t nbElement)
{
if (pos>m_size) {
TK_ERROR(" can not Erase Len Element at this position : " << pos << " > " << m_size);
return;
}
if (pos+nbElement>m_size) {
nbElement = m_size - pos;
}
int32_t idx = m_size;
// move curent data
int32_t sizeToMove = (idx - (pos+nbElement));
if ( 0 < sizeToMove) {
for (int32_t iii=0; iii<sizeToMove; iii++) {
m_data[pos+iii] = m_data[pos+nbElement+iii];
}
}
// Request resize of the current buffer
Resize(m_size-nbElement);
}
/**
* @brief Remove one element
*
* @param[in] pos Position to remove the data
*
* @return ---
*
*/
void Erase(int32_t pos)
{
EraseLen(pos, 1);
}
/**
* @brief Remove N elements
*
* @param[in] pos Position to remove the data
* @param[in] posEnd Last position number
*
* @return ---
*
*/
void Erase(int32_t pos, int32_t posEnd)
{
if (pos>m_size) {
TK_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
return;
}
if (posEnd>m_size) {
posEnd = m_size;
}
int32_t nbElement = m_size - pos;
int32_t tmpSize = m_size;
// move curent data
int32_t sizeToMove = (tmpSize - (pos+nbElement));
if ( 0 < sizeToMove) {
for (int32_t iii=0; iii<sizeToMove; iii++) {
m_data[pos+iii] = m_data[pos+nbElement+iii];
}
}
// Request resize of the current buffer
Resize(m_size-nbElement);
}
/**
* @brief extract data between two point :
* @param[in] posStart start position to extract data
* @param[in] posEnd End position to extract data
* @return the extracted vector
*/
Vector<MY_TYPE> Extract(int32_t posStart = 0, int32_t posEnd=0x7FFFFFFF) const
{
Vector<MY_TYPE> out;
if (posStart < 0) {
posStart = 0;
} else if (posStart >= Size() ) {
return out;
}
if (posEnd < 0) {
return out;
} else if (posEnd >= Size() ) {
posEnd = Size();
}
out.PushBack(&m_data[posStart], posEnd-posStart);
return out;
}
/**
* @brief Get an iterator an an specific position
* @param[in] pos Requested position of the iterator in the vector
* @return The Iterator
*/
Iterator Position(int32_t pos)
{
return Iterator(this, pos);
}
/**
* @brief Get an Iterator on the start position of the Vector
* @return The Iterator
*/
Iterator Begin(void)
{
return Position(0);
}
/**
* @brief Get an Iterator on the end position of the Vector
* @return The Iterator
*/
Iterator End(void)
{
return Position( Size()-1 );
}
private:
/**
* @brief Change the current size of the vector
* @param[in] newSize New requested size of element in the vector
*/
void Resize(int32_t newSize)
{
// Reallocate memory
if (newSize > m_allocated) {
ChangeAllocation(newSize);
}
m_size = newSize;
}
/**
* @brief Change the current allocation to the corect one (depend on the current size)
* @param[in] newSize Minimum number of element needed
*/
void ChangeAllocation(int32_t newSize)
{
// set the minimal size to 1
if(newSize <= 0) {
newSize = 1;
}
if (m_allocated<0) {
m_allocated = 0;
}
int32_t requestSize = m_allocated;
// set the size with the corect chose type :
if (newSize == requestSize) {
return;
} else if (newSize < requestSize) {
// we did not remove data ???
} else {
while(newSize > requestSize) {
if (0 == requestSize) {
requestSize = 1;
} else {
requestSize = requestSize * 2;
}
}
}
// No reallocation needed :
if (requestSize <= m_allocated) {
return;
}
//TK_INFO("Change vector allocation : " << m_allocated << "==>" << requestSize);
// check if something is allocated :
if (NULL == m_data) {
// no data allocated ==> request an allocation (might be the first)
m_data = new MY_TYPE[requestSize];
if (NULL==m_data) {
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
m_allocated = 0;
return;
}
// no data to copy
} else {
// allocate a new pool of data:
MY_TYPE* m_dataTmp = new MY_TYPE[requestSize];
if (NULL==m_dataTmp) {
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
m_allocated = 0;
return;
}
// copy data in the new pool
int32_t nbElements = etk_min(requestSize, m_allocated);
for(int32_t iii=0; iii<nbElements; iii++) {
m_dataTmp[iii] = m_data[iii];
}
// switch pointer:
MY_TYPE* m_dataTmp2 = m_data;
m_data = m_dataTmp;
// remove old pool
if (m_dataTmp2!= NULL) {
delete [] m_dataTmp2;
}
}
// set the new allocation size
m_allocated = requestSize;
}
public :
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Vector<MY_TYPE>& obj) const
{
// check if it was the same pointer
if( this == &obj ) {
return true;
}
// fiist step : check the size ...
if (m_size!=obj.m_size) {
return false;
}
if( NULL==m_data
|| NULL==obj.m_data) {
return false;
}
for (int32_t iii=0; iii<m_size; iii++) {
if (m_data[iii]!=obj.m_data[iii]) {
return false;
}
}
return true;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Vector<MY_TYPE>& obj) const
{
// check if it was the same pointer
if( this == &obj ) {
return false;
}
// fiist step : check the size ...
if (m_size!=obj.m_size) {
return true;
}
if( NULL==m_data
|| NULL==obj.m_data) {
return false;
}
for (int32_t iii=0; iii<m_size; iii++) {
if (m_data[iii]!=obj.m_data[iii]) {
return true;
}
}
return false;
}
};
/**
* @brief List classes ...
*
* @tparam[in] T The type of objects to store.
*
* m_data
* ---------- |-----------------------|
* | 0 |-------->| Class Data |
* |--------| |-----------------------|
* | 1 |----|
* |--------| |
* | 2 |====|==============| |-----------------------|
* |--------| | --->| Class Data |
* m_count | 3 |-| | |-----------------------|
* |--------| | |
* | x | | | |-----------------------|
* |--------| | -------->| Class Data |
* | x | | |-----------------------|
* |--------| |
* | x | |
* |--------| | |-----------------------|
* | x | --------------------->| Class Data |
* |--------| |-----------------------|
* | x |
* |--------|
* | x |
* |--------|
* m_size | x |
* ----------
*
*/
/*
template<class MY_CLASS> class List
{
};
*/
}
#undef __class__
#define __class__ NULL
#endif

347
etk/math/Matrix.h Normal file
View File

@ -0,0 +1,347 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TYPES_MATRIX_H__
#define __ETK_TYPES_MATRIX_H__
//#include <etk/DebugInternal.h>
#include <etk/math/Vector2D.h>
#include <etk/Vector.h>
namespace etk
{
template <typename T> class Matrix
{
private:
etk::Vector2D<int32_t> m_size;
etk::Vector<T> m_data;
public:
/*****************************************************
* Constructor
*****************************************************/
Matrix(Vector2D<int32_t> size, T* defaultVal=NULL) :
m_size(size),
etk::Vector2D<T>(size.x* size.y)
{
if (NULL != defaultVal) {
// copy all the elements
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
// cast and set value :
m_data[iii] = (T)defaultVal++;
}
} else {
Clear();
}
};
Matrix(int32_t width=0, int32_t heigh=0, T* defaultVal=NULL) :
m_size(width, heigh),
etk::Vector2D<T>(width*heigh)
{
if (NULL != defaultVal) {
// copy all the elements
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
// cast and set value :
m_data[iii] = (T)defaultVal++;
}
} else {
Clear();
}
};
Matrix(const Matrix<double>& obj) :
m_size(obj.m_size.x, obj.m_size.y),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
{
// copy all the elements
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
// cast and set value :
m_data[iii] = (T)obj.m_data[iii];
}
};
Matrix(const Matrix<float>& obj) :
m_size(obj.m_size.x, obj.m_size.y),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
{
// copy all the elements
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
// cast and set value :
m_data[iii] = (T)obj.m_data[iii];
}
};
Matrix(const Matrix<int32_t>& obj) :
m_size(obj.m_size.x, obj.m_size.y),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
{
// copy all the elements
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
// cast and set value :
m_data[iii] = (T)obj.m_data[iii];
}
};
/*****************************************************
* Destructor
*****************************************************/
virtual ~Matrix(void) {};
/*****************************************************
* = assigment
*****************************************************/
const Matrix<T>& operator= (const Matrix<T>& obj )
{
// check if it was the same pointer
if( this == &obj ) {
return *this;
}
// copy data :
m_size = obj.m_size;
m_data = obj.m_data;
return *this;
};
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Matrix<T>& obj) const
{
return (m_data == obj.m_data);
};
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Matrix<T>& obj) const
{
return (m_data != obj.m_data);
};
/*****************************************************
* += operator
*****************************************************/
const Matrix<T>& operator+= (const Matrix<T>& obj)
{
if (m_size != obj.m_size) {
//TK_CRITICAL("add 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix");
etk::Matrix<T> tmpMatrix(etk_max(m_size.x,obj.m_size.x), etk_max(m_size.y,obj.m_size.y));
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = (*this)[jjj];
for (int32_t iii=0; iii< m_size.x; iii++) {
tmpPointer[iii] = tmpPointerIn[iii];
}
}
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = obj[jjj];
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
tmpPointer[iii] += tmpPointerIn[iii];
}
}
// copy in local :
m_size = tmpMatrix.m_size;
m_data = tmpMatrix.m_data;
} else {
// copy data for the same size :
for (int32_t iii=0; iii< m_data.Size(); iii++) {
m_data[iii] += obj.m_data[iii];
}
}
return *this;
};
/*****************************************************
* + operator
*****************************************************/
Matrix<T> operator+ (const Matrix<T>& obj) {
Matrix<T> tmpp(*this);
tmpp += obj;
return tmpp;
}
/*****************************************************
* -= operator
*****************************************************/
const Matrix<T>& operator-= (const Matrix<T>& obj)
{
if (m_size != obj.m_size) {
//TK_CRITICAL("less 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix");
etk::Matrix<T> tmpMatrix(etk_max(m_size.x,obj.m_size.x), etk_max(m_size.y,obj.m_size.y));
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = (*this)[jjj];
for (int32_t iii=0; iii< m_size.x; iii++) {
tmpPointer[iii] = tmpPointerIn[iii];
}
}
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = obj[jjj];
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
tmpPointer[iii] -= tmpPointerIn[iii];
}
}
// copy in local :
m_size = tmpMatrix.m_size;
m_data = tmpMatrix.m_data;
} else {
// copy data for the same size :
for (int32_t iii=0; iii< m_data.Size(); iii++) {
m_data[iii] -= obj.m_data[iii];
}
}
return *this;
};
/*****************************************************
* - operator
*****************************************************/
Matrix<T> operator- (const Matrix<T>& obj) {
Matrix<T> tmpp(*this);
tmpp += obj;
return tmpp;
}
/*****************************************************
* *= operator
*****************************************************/
const Matrix<T>& operator*= (const Matrix<T>& obj)
{
if( m_size.x != obj.m_size.y
|| m_size.y != obj.m_size.x) {
//TK_CRITICAL("Error while multipliying 2 matrix with different size ==> impossible case ...");
return *this;
}
etk::Matrix<T> tmpMatrix(m_size);
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
T tmpVal = 0;
for (int32_t kkk=0; kkk< obj.m_size.x; kkk++) {
tmpVal += (*this)[jjj][iii+kkk] * obj[jjj+kkk][iii];
}
tmpMatrix[jjj][iii] = tmpVal;
}
}
// copy in local :
m_data = tmpMatrix.m_data;
return *this;
};
/*****************************************************
* * operator
*****************************************************/
Matrix<T> operator* (const Matrix<T>& obj) {
Matrix tmpp(*this);
tmpp *= obj;
return tmpp;
}
/*****************************************************
* [] operator
*****************************************************/
const T* operator[] (int32_t line) const {
return &m_data[line*m_size.x];
}
T* operator[] (int32_t line) {
return &m_data[line*m_size.x];
}
/*****************************************************
* Other mathematical function
*****************************************************/
/**
* @ brief Transpose Matrix
* @ return the transpose matrix
*/
Matrix<T> Transpose(void)
{
// create a matrix with the inverted size
Matrix<T> tmpMatrix(m_size.x, m_size.y);
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
for (int32_t iii=0; iii< m_size.x; iii++) {
tmpMatrix[jjj][iii] = (*this)[iii][jjj];
}
}
return tmpMatrix;
};
/**
* @ brief Create a convolution on the matrix : set convolution on the lines
* @ param[in] obj The convolution operator
* @ return the value of the convolution
*/
Matrix<T> Convolution(Matrix<T>& obj)
{
Matrix<T> tmppp(1,1);
// TODO : ...
return tmppp;
};
/**
* @ brief generate a devide of the curent Matrix with the specify power of 2
* @ param[in] decalage The power of 2 of the division
* @ return the result
*/
Matrix<T>& Fix(int32_t decalage)
{
Matrix<T> tmppp(1,1);
// TODO : ...
return tmppp;
};
/**
* @ brief generate a devide of the curent Matrix with the specify power of 2
* @ param[in] decalage The power of 2 of the division
* @ return the result
*/
Matrix<T>& Round2(int32_t decalage)
{
Matrix<T> tmppp(1,1);
// TODO : ...
return tmppp;
};
/*****************************************************
* other stupid action :
*****************************************************/
Vector2D<int32_t> Size(void) { return m_size; };
void Clear(void)
{
// copy data for the same size :
for (int32_t iii=0; iii< m_size.x*m_size.y; iii++) {
m_data[iii] = (T)0;
}
};
void Identity(void)
{
// copy data for the same size :
for (int32_t iii=0; iii< etk_min(m_size.x, m_size.y); iii++) {
(*this)[iii][iii] = (T)1;
}
};
void Set(int32_t iii, int32_t jjj, T value)
{
m_data[iii*m_size.x+jjj] = value;
}
T Get(int32_t iii, int32_t jjj)
{
return m_data[iii*m_size.x+jjj];
}
void Display(void)
{
/*
TK_INFO("Matrix display : ");
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
if (m_size.x == 0) {
TK_INFO(" --- , ");
} else if (m_size.x == 1) {
TK_INFO(" " << (*this)[jjj][0] << " , ");
} else if (m_size.x == 2) {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , ");
} else if (m_size.x == 3) {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , " << (*this)[jjj][2] << " , ");
} else if (m_size.x == 4) {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , " << (*this)[jjj][2] << " , " << (*this)[jjj][3] << " , ");
} else if (m_size.x == 5) {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , " << (*this)[jjj][2] << " , " << (*this)[jjj][3] << " , " << (*this)[jjj][4] << " , ");
} else if (m_size.x == 6) {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , " << (*this)[jjj][2] << " , " << (*this)[jjj][3] << " , " << (*this)[jjj][4] << " , " << (*this)[jjj][5] << " , ");
} else {
TK_INFO(" " << (*this)[jjj][0] << " , " << (*this)[jjj][1] << " , " << (*this)[jjj][2] << " , " << (*this)[jjj][3] << " , " << (*this)[jjj][4] << " , " << (*this)[jjj][5] << " , " << (*this)[jjj][6] << " , ");
}
}
*/
};
};
};
#endif

84
etk/math/Matrix4.cpp Normal file
View File

@ -0,0 +1,84 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Types.h>
#include <etk/math/Matrix4.h>
#include <etk/DebugInternal.h>
#include <math.h>
etk::Matrix4 etk::matrix::Perspective(float left, float right, float bottom, float top, float nearVal, float farVal)
{
etk::Matrix4 tmp;
for(int32_t iii=0; iii<4*4 ; iii++) {
tmp.m_mat[iii] = 0;
}
tmp.m_mat[0] = 2.0 / (right - left);
tmp.m_mat[5] = 2.0 / (top - bottom);
tmp.m_mat[10] = -2.0 / (farVal - nearVal);
tmp.m_mat[3] = -1*(right + left) / (right - left);
tmp.m_mat[7] = -1*(top + bottom) / (top - bottom);
tmp.m_mat[11] = -1*(farVal + nearVal) / (farVal - nearVal);
tmp.m_mat[15] = 1;
//TK_INFO("Perspective :");
//etk::matrix::Display(tmp);
return tmp;
}
etk::Matrix4 etk::matrix::Translate(float x, float y, float z)
{
etk::Matrix4 tmp;
// set translation :
tmp.m_mat[3] = x;
tmp.m_mat[7] = y;
tmp.m_mat[11] = z;
//TK_INFO("Translate :");
//etk::matrix::Display(tmp);
return tmp;
}
etk::Matrix4 etk::matrix::Scale(float x, float y, float z)
{
etk::Matrix4 tmp;
// set scale :
tmp.m_mat[0] = x;
tmp.m_mat[5] = y;
tmp.m_mat[10] = z;
//TK_INFO("Scale :");
//etk::matrix::Display(tmp);
return tmp;
}
etk::Matrix4 etk::matrix::rotate(float x, float y, float z, float angleRad)
{
etk::Matrix4 tmp;
float cosVal = cos(angleRad);
float sinVal = sin(angleRad);
float invVal = 1.0-cosVal;
// set rotation :
tmp.m_mat[0] = x*x*invVal + cosVal;
tmp.m_mat[1] = x*y*invVal - z*cosVal;
tmp.m_mat[2] = x*z*invVal + y*sinVal;
tmp.m_mat[4] = y*x*invVal + z*sinVal;
tmp.m_mat[5] = y*y*invVal + cosVal;
tmp.m_mat[6] = y*z*invVal - x*sinVal;
tmp.m_mat[8] = z*x*invVal - y*sinVal;
tmp.m_mat[9] = z*y*invVal + x*sinVal;
tmp.m_mat[10] = z*z*invVal + cosVal;
return tmp;
}
void etk::matrix::Display(etk::Matrix4& tmp)
{
TK_INFO("matrix : (" << tmp.m_mat[0] << " , " << tmp.m_mat[1] << " , " << tmp.m_mat[2] << " , " << tmp.m_mat[3] << " , ");
TK_INFO(" " << tmp.m_mat[4] << " , " << tmp.m_mat[5] << " , " << tmp.m_mat[6] << " , " << tmp.m_mat[7] << " , ");
TK_INFO(" " << tmp.m_mat[8] << " , " << tmp.m_mat[9] << " , " << tmp.m_mat[10] << " , " << tmp.m_mat[11] << " , ");
TK_INFO(" " << tmp.m_mat[12] << " , " << tmp.m_mat[13] << " , " << tmp.m_mat[14] << " , " << tmp.m_mat[15] << " )");
}

213
etk/math/Matrix4.h Normal file
View File

@ -0,0 +1,213 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TYPES_MATRIX4_H__
#define __ETK_TYPES_MATRIX4_H__
namespace etk {
class Matrix4
{
public:
float m_mat[4*4];
void Identity(void) {
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = 0;
}
m_mat[0] = 1.0;
m_mat[5] = 1.0;
m_mat[10] = 1.0;
m_mat[15] = 1.0;
}
/*****************************************************
* Constructor
*****************************************************/
Matrix4(void) {
Identity();
}
Matrix4(const Matrix4& obj) {
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = obj.m_mat[iii];
}
}
Matrix4(float a1, float b1, float c1, float d1,
float a2, float b2, float c2, float d2,
float a3, float b3, float c3, float d3,
float a4, float b4, float c4, float d4) {
m_mat[0] = a1;
m_mat[1] = b1;
m_mat[2] = c1;
m_mat[3] = d1;
m_mat[4] = a2;
m_mat[5] = b2;
m_mat[6] = c2;
m_mat[7] = d2;
m_mat[8] = a3;
m_mat[9] = b3;
m_mat[10] = c3;
m_mat[11] = d3;
m_mat[12] = a4;
m_mat[13] = b4;
m_mat[14] = c4;
m_mat[15] = d4;
}
Matrix4(float * obj) {
if (NULL == obj) {
Identity();
return;
}
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = obj[iii];
}
}
/*****************************************************
* Destructor
*****************************************************/
virtual ~Matrix4(void) {
}
/*****************************************************
* = assigment
*****************************************************/
const Matrix4& operator= (const Matrix4& obj ) {
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = obj.m_mat[iii];
}
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Matrix4& obj) const {
for(int32_t iii=0; iii<4*4 ; iii++) {
if(m_mat[iii] != obj.m_mat[iii]) {
return false;
}
}
return true;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Matrix4& obj) const {
for(int32_t iii=0; iii<4*4 ; iii++) {
if(m_mat[iii] != obj.m_mat[iii]) {
return true;
}
}
return false;
}
/*****************************************************
* += operator
*****************************************************/
const Matrix4& operator+= (const Matrix4& obj) {
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] += obj.m_mat[iii];
}
return *this;
}
/*****************************************************
* + operator
*****************************************************/
Matrix4 operator+ (const Matrix4& obj) {
Matrix4 tmpp(*this);
tmpp += obj;
return tmpp;
}
/*****************************************************
* -= operator
*****************************************************/
const Matrix4& operator-= (const Matrix4& obj) {
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] -= obj.m_mat[iii];
}
return *this;
}
/*****************************************************
* - operator
*****************************************************/
Matrix4 operator- (const Matrix4& obj) {
Matrix4 tmpp(*this);
tmpp += obj;
return tmpp;
}
/*****************************************************
* *= operator
*****************************************************/
const Matrix4& operator*= (const Matrix4& obj) {
// output Matrix
float matrixOut[4*4];
for(int32_t jjj=0; jjj<4 ; jjj++) {
float* tmpLeft = m_mat + jjj*4;
for(int32_t iii=0; iii<4 ; iii++) {
const float* tmpUpper = obj.m_mat+iii;
float* tmpLeft2 = tmpLeft;
float tmpElement = 0;
for(int32_t kkk=0; kkk<4 ; kkk++) {
tmpElement += *tmpUpper * *tmpLeft2;
tmpUpper += 4;
tmpLeft2++;
}
matrixOut[jjj*4+iii] = tmpElement;
}
}
// set it at the output
for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = matrixOut[iii];
}
return *this;
}
/*****************************************************
* * operator
*****************************************************/
Matrix4 operator* (const Matrix4& obj) {
Matrix4 tmpp(*this);
tmpp *= obj;
return tmpp;
}
/*****************************************************
* other basic function :
*****************************************************/
void Transpose(void)
{
float tmpVal = m_mat[1];
m_mat[1] = m_mat[4];
m_mat[4] = tmpVal;
tmpVal = m_mat[2];
m_mat[2] = m_mat[8];
m_mat[8] = tmpVal;
tmpVal = m_mat[6];
m_mat[6] = m_mat[9];
m_mat[9] = tmpVal;
tmpVal = m_mat[3];
m_mat[3] = m_mat[12];
m_mat[12] = tmpVal;
tmpVal = m_mat[7];
m_mat[7] = m_mat[13];
m_mat[13] = tmpVal;
tmpVal = m_mat[11];
m_mat[11] = m_mat[14];
m_mat[14] = tmpVal;
}
};
namespace matrix {
Matrix4 Perspective(float left, float right, float bottom, float top, float nearVal, float farVal);
Matrix4 Translate(float x=0.0, float y=0.0, float z=0.0);
Matrix4 Scale(float x=1.0, float y=1.0, float z=1.0);
Matrix4 rotate(float x, float y, float z, float angleRad=0.0);
void Display(Matrix4& tmp);
};
};
#endif

231
etk/math/Plane.h Normal file
View File

@ -0,0 +1,231 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TYPES_PLANE_H__
#define __ETK_TYPES_PLANE_H__
#include <etk/DebugInternal.h>
#include <etk/math/Vector3D.h>
#include <etk/Vector.h>
namespace etk {
template <typename T> class Plane
{
public :
//member variables
etk::Vector3D<T> m_normal; //X.N+intercept=0
T m_intercept;
public:
/*****************************************************
* Constructor
*****************************************************/
Plane(void) :
m_normal(0, 0, 0),
m_intercept(0)
{
}
Plane(etk::Vector3D<T> _normal, T _intercept=0) :
m_normal(_normal),
m_intercept(_intercept)
{
}
Plane(const Plane& obj) :
m_normal(obj.m_normal),
m_intercept(obj.m_intercept)
{
}
/*****************************************************
* Destructor
*****************************************************/
~Plane(void)
{
};
/**
* @brief
* @param[in,out]
* @return
*/
void SetNormal(const etk::Vector3D<T>& obj)
{
m_normal=obj;
};
/**
* @brief
* @param[in,out]
* @return
*/
void SetIntercept(float _intercept)
{
m_intercept=_intercept;
};
/**
* @brief
* @param[in,out]
* @return
*/
void SetFromPoints(const etk::Vector3D<T> & p0,
const etk::Vector3D<T> & p1,
const etk::Vector3D<T> & p2)
{
m_normal=(p1-p0).CrossProduct(p2-p0);
m_normal.Normalize();
CalculateIntercept(p0);
};
/**
* @brief
* @param[in,out]
* @return
*/
void CalculateIntercept(const etk::Vector3D<T>& pointOnPlane)
{
m_intercept=-m_normal.DotProduct(pointOnPlane);
}
/**
* @brief
* @param[in,out]
* @return
*/
void Normalize(void)
{
float normalLength=m_normal.GetLength();
m_normal/=normalLength;
m_intercept/=normalLength;
};
/**
* @brief
* @param[in,out]
* @return
*/
etk::Vector3D<T> GetNormal(void)
{
return m_normal;
};
/**
* @brief
* @param[in,out]
* @return
*/
float GetIntercept()
{
return m_intercept;
}
//find point of intersection of 3 planes
/**
* @brief
* @param[in,out]
* @return
*/
bool Intersect3(const Plane<T>& p2,
const Plane<T> & p3,
etk::Vector3D<T> & result)
{
float denominator=m_normal.DotProduct((p2.m_normal).CrossProduct(p3.m_normal));
//scalar triple product of normals
if(denominator==0.0f) {
//no intersection
return false;
}
etk::Vector3D<T> temp1, temp2, temp3;
temp1=(p2.m_normal.CrossProduct(p3.m_normal))*m_intercept;
temp2=(p3.m_normal.CrossProduct(m_normal))*p2.m_intercept;
temp3=(m_normal.CrossProduct(p2.m_normal))*p3.m_intercept;
result=(temp1+temp2+temp3)/(-denominator);
return true;
};
/**
* @brief
* @param[in,out]
* @return
*/
float GetDistance(const etk::Vector3D<T> & point) const
{
return point.x*m_normal.x
+ point.y*m_normal.y
+ point.z*m_normal.z
+ m_intercept;
};
/**
* @brief
* @param[in,out]
* @return
*/
Plane<T> LinearInterpolate(const Plane<T> & p2, float factor)
{
Plane<T> result;
result.m_normal=m_normal*(1.0f-factor) + p2.m_normal*factor;
result.m_normal.Normalize();
result.m_intercept=m_intercept*(1.0f-factor) + p2.m_intercept*factor;
return result;
};
//operators
/**
* @brief
* @param[in,out]
* @return
*/
bool operator==(const Plane<T> & obj) const
{
if( m_normal==obj.m_normal
&& m_intercept==obj.m_intercept) {
return true;
}
return false;
};
/**
* @brief
* @param[in,out]
* @return
*/
bool operator!=(const Plane<T> & obj) const
{
return!((*this)==obj);
}
//unary operators
/**
* @brief
* @param[in,out]
* @return
*/
Plane<T> operator-(void) const
{
return Plane<T>(-m_normal, -m_intercept);
}
/**
* @brief
* @param[in,out]
* @return
*/
Plane<T> operator+(void) const
{
return *this;
}
};
};
#endif

242
etk/math/Vector2D.h Normal file
View File

@ -0,0 +1,242 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_MATH_VECTOR2D_H__
#define __ETK_MATH_VECTOR2D_H__
namespace etk
{
template <typename T> class Vector2D
{
public:
T x;
T y;
public:
/*****************************************************
* Constructor
*****************************************************/
Vector2D(void) : x(0), y(0) { };
Vector2D(double _x, double _y) : x(_x), y(_y) { };
Vector2D(float _x, float _y) : x(_x), y(_y) { };
Vector2D(int32_t _x, int32_t _y) : x(_x), y(_y) { };
Vector2D(const Vector2D<double>& obj) : x((T)obj.x), y((T)obj.y) { };
Vector2D(const Vector2D<float>& obj) : x((T)obj.x), y((T)obj.y) { };
Vector2D(const Vector2D<int32_t>& obj) : x((T)obj.x), y((T)obj.y) { };
~Vector2D(void) { };
/*****************************************************
* = assigment
*****************************************************/
const Vector2D<T>& operator= (const Vector2D<T>& obj ) {
x = (T)obj.x;
y = (T)obj.y;
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Vector2D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y) {
return true;
}
return false;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Vector2D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y) {
return false;
}
return true;
}
/*****************************************************
* += operator
*****************************************************/
const Vector2D<T>& operator+= (const Vector2D<T>& obj) {
x += (T)obj.x;
y += (T)obj.y;
return *this;
}
/*****************************************************
* + operator
*****************************************************/
Vector2D<T> operator+ (const Vector2D<T>& obj) {
Vector2D<T> tmpp(x,y);
tmpp.x += (T)obj.x;
tmpp.y += (T)obj.y;
return tmpp;
}
/*****************************************************
* -= operator
*****************************************************/
const Vector2D<T>& operator-= (const Vector2D<T>& obj) {
x -= (T)obj.x;
y -= (T)obj.y;
return *this;
}
/*****************************************************
* - operator
*****************************************************/
Vector2D<T> operator- (const Vector2D<T>& obj) {
Vector2D<T> tmpp(x,y);
tmpp.x -= (T)obj.x;
tmpp.y -= (T)obj.y;
return tmpp;
}
/*****************************************************
* /= operator
*****************************************************/
const Vector2D<T>& operator/= (const Vector2D<T>& obj) {
x /= (T)obj.x;
y /= (T)obj.y;
return *this;
}
/*****************************************************
* / operator
*****************************************************/
Vector2D<T> operator/ (const Vector2D<T>& obj) {
Vector2D<T> tmpp(x,y);
tmpp.x /= (T)obj.x;
tmpp.y /= (T)obj.y;
return tmpp;
}
/*****************************************************
* *= operator
*****************************************************/
const Vector2D<T>& operator*= (const Vector2D<T>& obj) {
x *= (T)obj.x;
y *= (T)obj.y;
return *this;
}
/*****************************************************
* * operator
*****************************************************/
Vector2D<T> operator* (const Vector2D<T>& obj) {
Vector2D<T> tmpp(x,y);
tmpp.x *= (T)obj.x;
tmpp.y *= (T)obj.y;
return tmpp;
}
/*****************************************************
* ++ operator
*****************************************************/
Vector2D<T>& operator++() // prefix
{
++x;
++y;
return *this;
}
Vector2D<T> operator++(int unused) // postfix
{
Vector2D<T> result = *this;
++(*this);
return result;
}
/*****************************************************
* -- operator
*****************************************************/
Vector2D<T>& operator--() // prefix
{
--x;
--y;
return *this;
}
Vector2D<T> operator--(int unused) // postfix
{
Vector2D<T> result = *this;
--(*this);
return result;
}
/**
* @brief Set the vector at (0,0)
*/
void Zero(void)
{
x=0;
y=0;
};
/**
* @brief Set the vector at (1,1)
*/
void One(void)
{
x=0;
y=0;
};
/**
* @brief normalize the curent vector
*/
void Normalize(void)
{
float length=GetLength();
if( length==1
|| length==0) {
return;
}
float scalefactor = 1.0f/length;
x *= scalefactor;
y *= scalefactor;
};
/**
* @brief Get the normalized vector
* @return a new vector normalized
*/
Vector2D<T> GetNormalized(void) const
{
Vector2D<T> tmp(*this);
tmp.Normalize();
return tmp;
};
/**
* @brief Get the size of the vector
* @return the float value
*/
float GetLength(void) const
{
return (float)sqrt((x*x)+(y*y));
};
/**
* @brief Get the square size of the vector
* @return flat value
*/
float GetSquaredLength(void) const
{
return (float)(x*x)+(y*y);
};
/**
* @brief Linar intermolation of the curent Vector
* @param[in] input
* @param[in] factor
* @return the interpolate vector
*/
Vector2D<T> LinearInterpolate(const Vector2D<T> & input, float factor) const
{
return (*this)*(1.0f-factor) + input*factor;
};
/**
* @brief Quadratic intermolation of the curent Vector
* @param[in] v1
* @param[in] v2
* @param[in] factor
* @return the interpolate vector
*/
Vector2D<T> QuadraticInterpolate(const Vector2D<T> & v2, const Vector2D<T> & v3, float factor) const
{
return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;}
};
};
#endif

404
etk/math/Vector3D.h Normal file
View File

@ -0,0 +1,404 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_MATH_VECTOR3D_H__
#define __ETK_MATH_VECTOR3D_H__
namespace etk
{
template <typename T> class Vector3D
{
public:
T x;
T y;
T z;
public:
/*****************************************************
* Constructor
*****************************************************/
Vector3D(void) : x(0), y(0), z(0) { };
Vector3D(double _x, double _y, double _z) : x(_x), y(_y), z(_z) { };
Vector3D(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { };
Vector3D(int32_t _x, int32_t _y, int32_t _z) : x(_x), y(_y), z(_z) { };
Vector3D(const Vector3D<double>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
Vector3D(const Vector3D<float>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
Vector3D(const Vector3D<int32_t>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
~Vector3D(void) { };
/*****************************************************
* = assigment
*****************************************************/
const Vector3D<T>& operator= (const Vector3D<T>& obj ) {
x = (T)obj.x;
y = (T)obj.y;
z = (T)obj.z;
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Vector3D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
return true;
}
return false;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Vector3D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
return false;
}
return true;
}
/*****************************************************
* += operator
*****************************************************/
const Vector3D<T>& operator+= (const Vector3D<T>& obj) {
x += (T)obj.x;
y += (T)obj.y;
z += (T)obj.z;
return *this;
}
const Vector3D<T>& operator+= (const float val) {
x += val;
y += val;
z += val;
return *this;
}
/*****************************************************
* + operator
*****************************************************/
Vector3D<T> operator+ (const Vector3D<T>& obj) {
Vector3D<T> tmpp(x,y,y);
tmpp.x += (T)obj.x;
tmpp.y += (T)obj.y;
tmpp.z += (T)obj.z;
return *this;
}
Vector3D<T> operator+ (const float val) {
Vector3D<T> tmpp(x,y,y);
tmpp.x += val;
tmpp.y += val;
tmpp.z += val;
return *this;
}
/*****************************************************
* -= operator
*****************************************************/
const Vector3D<T>& operator-= (const Vector3D<T>& obj) {
x -= (T)obj.x;
y -= (T)obj.y;
z -= (T)obj.z;
return *this;
}
const Vector3D<T>& operator-= (const float val) {
x -= val;
y -= val;
z -= val;
return *this;
}
/*****************************************************
* - operator
*****************************************************/
Vector3D<T> operator- (const Vector3D<T>& obj) {
Vector3D<T> tmpp(x,y,y);
tmpp.x -= (T)obj.x;
tmpp.y -= (T)obj.y;
tmpp.z -= (T)obj.z;
return *this;
}
Vector3D<T> operator- (const float val) {
Vector3D<T> tmpp(x,y,y);
tmpp.x -= val;
tmpp.y -= val;
tmpp.z -= val;
return *this;
}
/*****************************************************
* /= operator
*****************************************************/
const Vector3D<T>& operator/= (const Vector3D<T>& obj) {
if (obj.x != 0) {
x /= (T)obj.x;
}
if (obj.y != 0) {
y /= (T)obj.y;
}
if (obj.z != 0) {
z /= (T)obj.z;
}
return *this;
}
const Vector3D<T>& operator/= (const float val) {
if (val==0) {
return *this;
}
x /= val;
y /= val;
z /= val;
return *this;
}
/*****************************************************
* / operator
*****************************************************/
Vector3D<T> operator/ (const Vector3D<T>& obj) {
Vector3D<T> tmpp(x,y,y);
if (obj.x != 0) {
tmpp.x /= (T)obj.x;
}
if (obj.y != 0) {
tmpp.y /= (T)obj.y;
}
if (obj.z != 0) {
tmpp.z /= (T)obj.z;
}
return tmpp;
}
Vector3D<T> operator/ (const float val) {
Vector3D<T> tmpp(x,y,y);
if (val==0) {
return tmpp;
}
tmpp.x /= val;
tmpp.y /= val;
tmpp.z /= val;
return tmpp;
}
/*****************************************************
* *= operator
*****************************************************/
const Vector3D<T>& operator*= (const Vector3D<T>& obj) {
x *= (T)obj.x;
y *= (T)obj.y;
z *= (T)obj.z;
return *this;
}
const Vector3D<T>& operator*= (const float val) {
x *= val;
y *= val;
z *= val;
return *this;
}
/*****************************************************
* * operator
*****************************************************/
Vector3D<T> operator* (const Vector3D<T>& obj) {
Vector3D<T> tmpp(x,y,y);
tmpp.x *= (T)obj.x;
tmpp.y *= (T)obj.y;
tmpp.z *= (T)obj.z;
return tmpp;
}
Vector3D<T> operator* (const float val) {
Vector3D<T> tmpp(x,y,y);
tmpp.x *= val;
tmpp.y *= val;
tmpp.z *= val;
return tmpp;
}
/*****************************************************
* ++ operator
*****************************************************/
Vector3D<T>& operator++() // prefix
{
++x;
++y;
++z;
return *this;
}
Vector3D<T> operator++(int unused) // postfix
{
Vector3D<T> result = *this;
++(*this);
return result;
}
/*****************************************************
* -- operator
*****************************************************/
Vector3D<T>& operator--() // prefix
{
--x;
--y;
--z;
return *this;
}
Vector3D<T> operator--(int unused) // postfix
{
Vector3D<T> result = *this;
--(*this);
return result;
}
void Zero(void)
{
x=0;
y=0;
z=0;
};
void One(void)
{
x=1;
y=1;
z=1;
};
//vector algebra
Vector3D<T> CrossProduct(const Vector3D<T>& obj) const
{
return Vector3D<T>( y*obj.z - z*obj.y,
z*obj.x - x*obj.z,
x*obj.y - y*obj.x);
};
float DotProduct(const Vector3D<T>& obj) const
{
return x*obj.x
+ y*obj.y
+ z*obj.z;
};
void Normalize()
{
float length=GetLength();
if(length==1 || length==0) {
return;
}
float scalefactor = 1.0f/length;
x *= scalefactor;
y *= scalefactor;
z *= scalefactor;
};
Vector3D<T> GetNormalized() const
{
Vector3D<T> tmpp(*this);
tmpp.Normalize();
return tmpp;
};
float GetLength() const
{
return (float)sqrt((x*x)+(y*y)+(z*z));
};
float GetSquaredLength() const
{
return (x*x)+(y*y)+(z*z);
};
//rotations
void RotateX(double angle)
{
(*this)=GetRotatedX(angle);
};
Vector3D<T> GetRotatedX(double angle) const
{
if(angle==0.0) {
return (*this);
}
float sinAngle=(float)sin(M_PI*angle/180);
float cosAngle=(float)cos(M_PI*angle/180);
return Vector3D<T>( x,
y*cosAngle - z*sinAngle,
y*sinAngle + z*cosAngle);
};
void RotateY(double angle)
{
(*this)=GetRotatedY(angle);
};
Vector3D<T> GetRotatedY(double angle) const
{
if(angle==0.0) {
return (*this);
}
float sinAngle=(float)sin(M_PI*angle/180);
float cosAngle=(float)cos(M_PI*angle/180);
return Vector3D<T>( x*cosAngle + z*sinAngle,
y,
-x*sinAngle + z*cosAngle);
};
void RotateZ(double angle)
{
(*this)=GetRotatedZ(angle);
};
Vector3D<T> GetRotatedZ(double angle) const
{
if(angle==0.0) {
return (*this);
}
float sinAngle=(float)sin(M_PI*angle/180);
float cosAngle=(float)cos(M_PI*angle/180);
return Vector3D<T>( x*cosAngle - y*sinAngle,
x*sinAngle + y*cosAngle,
z);
};
void RotateAxis(double angle, const Vector3D<T> & axis)
{
(*this)=GetRotatedAxis(angle, axis);
};
Vector3D<T> GetRotatedAxis(double angle, const Vector3D<T> & axis) const
{
if(angle==0.0) {
return (*this);
}
Vector3D<T> u=axis.GetNormalized();
Vector3D<T> rotMatrixRow0, rotMatrixRow1, rotMatrixRow2;
float sinAngle=(float)sin(M_PI*angle/180);
float cosAngle=(float)cos(M_PI*angle/180);
float MinusCosAngle=1.0f-cosAngle;
rotMatrixRow0.x=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x));
rotMatrixRow0.y=(u.x)*(u.y)*(MinusCosAngle) - sinAngle*u.z;
rotMatrixRow0.z=(u.x)*(u.z)*(MinusCosAngle) + sinAngle*u.y;
rotMatrixRow1.x=(u.x)*(u.y)*(MinusCosAngle) + sinAngle*u.z;
rotMatrixRow1.y=(u.y)*(u.y) + cosAngle*(1-(u.y)*(u.y));
rotMatrixRow1.z=(u.y)*(u.z)*(MinusCosAngle) - sinAngle*u.x;
rotMatrixRow2.x=(u.x)*(u.z)*(MinusCosAngle) - sinAngle*u.y;
rotMatrixRow2.y=(u.y)*(u.z)*(MinusCosAngle) + sinAngle*u.x;
rotMatrixRow2.z=(u.z)*(u.z) + cosAngle*(1-(u.z)*(u.z));
return Vector3D<T>( this->DotProduct(rotMatrixRow0),
this->DotProduct(rotMatrixRow1),
this->DotProduct(rotMatrixRow2));
};
/**
* @brief Linar intermolation of the curent Vector
* @param[in] input
* @param[in] factor
* @return the interpolate vector
*/
Vector3D<T> LinearInterpolate(const Vector3D<T>& input, float factor) const
{
return (*this)*(1.0f-factor) + input*factor;
};
/**
* @brief Quadratic intermolation of the curent Vector
* @param[in] v1
* @param[in] v2
* @param[in] factor
* @return the interpolate vector
*/
Vector3D<T> QuadraticInterpolate(const Vector3D<T>& v2, const Vector3D<T>& v3, float factor) const
{
return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;
};
};
};
#endif

189
etk/math/Vector4D.h Normal file
View File

@ -0,0 +1,189 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_MATH_VECTOR4D_H__
#define __ETK_MATH_VECTOR4D_H__
namespace etk
{
template <typename T> class Vector4D
{
public:
T x;
T y;
union {
T z;
T width;
};
union {
T w;
T height;
};
public:
/*****************************************************
* Constructor
*****************************************************/
Vector4D(void) : x(0), y(0), z(0), w(0) { };
Vector4D(double _x, double _y, double _z, double _w) : x(_x), y(_y), z(_z), w(_w) { };
Vector4D(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) { };
Vector4D(int32_t _x, int32_t _y, int32_t _z, int32_t _w) : x(_x), y(_y), z(_z), w(_w) { };
Vector4D(const Vector4D<double>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z), w((T)obj.w) { };
Vector4D(const Vector4D<float>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z), w((T)obj.w) { };
Vector4D(const Vector4D<int32_t>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z), w((T)obj.w) { };
~Vector4D(void) { };
/*****************************************************
* = assigment
*****************************************************/
const Vector4D<T>& operator= (const Vector4D<T>& obj ) {
x = (T)obj.x;
y = (T)obj.y;
z = (T)obj.z;
w = (T)obj.w;
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator== (const Vector4D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
return true;
}
return false;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Vector4D<T>& obj) const {
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z && (T)obj.w == w) {
return false;
}
return true;
}
/*****************************************************
* += operator
*****************************************************/
const Vector4D<T>& operator+= (const Vector4D<T>& obj) {
x += (T)obj.x;
y += (T)obj.y;
z += (T)obj.z;
w += (T)obj.w;
return *this;
}
/*****************************************************
* + operator
*****************************************************/
Vector4D<T> operator+ (const Vector4D<T>& obj) {
Vector4D<T> tmpp(x,y,y);
tmpp.x += (T)obj.x;
tmpp.y += (T)obj.y;
tmpp.z += (T)obj.z;
tmpp.w += (T)obj.w;
return *this;
}
/*****************************************************
* -= operator
*****************************************************/
const Vector4D<T>& operator-= (const Vector4D<T>& obj) {
x -= (T)obj.x;
y -= (T)obj.y;
z -= (T)obj.z;
w -= (T)obj.w;
return *this;
}
/*****************************************************
* - operator
*****************************************************/
Vector4D<T> operator- (const Vector4D<T>& obj) {
Vector4D<T> tmpp(x,y,y);
tmpp.x -= (T)obj.x;
tmpp.y -= (T)obj.y;
tmpp.z -= (T)obj.z;
tmpp.w -= (T)obj.w;
return *this;
}
/*****************************************************
* /= operator
*****************************************************/
const Vector4D<T>& operator/= (const Vector4D<T>& obj) {
x /= (T)obj.x;
y /= (T)obj.y;
z /= (T)obj.z;
w /= (T)obj.w;
return *this;
}
/*****************************************************
* / operator
*****************************************************/
Vector4D<T> operator/ (const Vector4D<T>& obj) {
Vector4D<T> tmpp(x,y,y);
tmpp.x /= (T)obj.x;
tmpp.y /= (T)obj.y;
tmpp.z /= (T)obj.z;
tmpp.w /= (T)obj.w;
return *this;
}
/*****************************************************
* *= operator
*****************************************************/
const Vector4D<T>& operator*= (const Vector4D<T>& obj) {
x *= (T)obj.x;
y *= (T)obj.y;
z *= (T)obj.z;
w *= (T)obj.w;
return *this;
}
/*****************************************************
* * operator
*****************************************************/
Vector4D<T> operator* (const Vector4D<T>& obj) {
Vector4D<T> tmpp(x,y,y);
tmpp.x *= (T)obj.x;
tmpp.y *= (T)obj.y;
tmpp.z *= (T)obj.z;
tmpp.w *= (T)obj.w;
return *this;
}
/*****************************************************
* ++ operator
*****************************************************/
Vector4D<T>& operator++() // prefix
{
++x;
++y;
++z;
++w;
return *this;
}
Vector4D<T> operator++(int unused) // postfix
{
Vector4D<T> result = *this;
++(*this);
return result;
}
/*****************************************************
* -- operator
*****************************************************/
Vector4D<T>& operator--() // prefix
{
--x;
--y;
--z;
--w;
return *this;
}
Vector4D<T> operator--(int unused) // postfix
{
Vector4D<T> result = *this;
--(*this);
return result;
}
};
};
#endif

20
etk/math/math.h Normal file
View File

@ -0,0 +1,20 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef EPSILON
#define EPSILON 0.01f
#endif
#include <math.h>
#include <etk/math/Vector2D.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Vector4D.h>
#include <etk/math/Matrix.h>
#include <etk/math/Matrix4.h>
#include <etk/math/Plane.h>

1291
etk/os/FSNode.cpp Normal file

File diff suppressed because it is too large Load Diff

230
etk/os/FSNode.h Normal file
View File

@ -0,0 +1,230 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_FILE_SYSTEM_NODE_H__
#define __ETK_FILE_SYSTEM_NODE_H__
#include <etk/UString.h>
#include <etk/os/FSNodeRight.h>
#define MAX_FILE_NAME (10240)
//http://developer.android.com/guide/topics/data/data-storage.html
namespace etk
{
typedef enum {
FSN_UNKNOW,
FSN_BLOCK,
FSN_CHARACTER,
FSN_FOLDER,
FSN_FIFO,
FSN_LINK,
FSN_FILE,
FSN_SOCKET,
} typeNode_te;
etk::CCout& operator <<(etk::CCout &os, const etk::typeNode_te &obj);
typedef enum {
FSN_TYPE_UNKNOW,
// user might done abstraction ==> acces of the sdcard when possible ...
FSN_TYPE_DIRECT,
FSN_TYPE_RELATIF,
// depend on case
// - PC : ~/
// - Android : /sdcard/
// - Apple : ????
FSN_TYPE_HOME,
// depend of the case
// - PC : /usr/shared/programName/
// - Android : Internal at the executable file (pointer on static area)
// - Apple : Internal at the executable file
FSN_TYPE_DATA,
// depend on case
// - PC : ~/.local/programName/
// - Android : /data/data/programName/files/
// - Apple : ????
FSN_TYPE_USER_DATA,
// depend on case
// - PC : ~/.programName/cache/
// - Android : /data/data/programName/cache/
// - Apple : ????
FSN_TYPE_CACHE,
// depend on case
// - try on FSN_TYPE_USER_DATA/theme/themeName/xxx
// - try on FSN_TYPE_DATA/theme/themeName/xxx
// - try on FSN_TYPE_EWOL_DATA/theme/themeName/xxx ==> later when the lib will be accessible in packages
// and jump to the default theme file
// - try on FSN_TYPE_USER_DATA/theme/default/xxx
// - try on FSN_TYPE_DATA/theme/default/xxx
// - try on FSN_TYPE_EWOL_DATA/theme/default/xxx ==> later when the lib will be accessible in packages
FSN_TYPE_THEME,
FSN_TYPE_THEME_DATA
} FSNType_te;
etk::CCout& operator <<(etk::CCout &os, const etk::FSNType_te &obj);
/*
note : The filename can be
Direct mode :
DIRECT:/sdfsdfsdf/
/XX ==> for Linux / Mac / Android
[a-zA-Z]:/xxx ==> for Windows
Data mode :
DATA:folder/File.ccc
User data mode :
USERDATA:folder/File.ccc
Cache Data :
CACHE:folder/File.ccc
Theme data :
THEME:folder/file.xxx
Get the root folder :
ROOT:
/
[a-zA-Z]: ==> create more risk ...
Get the Home folder :
HOME:
~
*/
class FSNode
{
private:
etk::UString m_userFileName; //!< the name requested by the User
etk::UString m_systemFileName; //!< the compleate filename for the system
FSNType_te m_type; //!< the Type of data requested by the User
typeNode_te m_typeNode; //!< type of the current file/Folder/Link
etk::FSNodeRight m_rights; //!< IO right of the current file
// specific when file Access :
FILE * m_PointerFile;
uint64_t m_timeCreate;
uint64_t m_timeModify;
uint64_t m_timeAccess;
uint32_t m_idOwner;
uint32_t m_idGroup;
private:
etk::UString GetFileSystemName(void) const;
etk::UString GetFileSystemNameTheme(void);
void PrivateSetName(etk::UString& newName);
bool DirectExistFile(etk::UString tmpFileNameDirect, bool checkInAPKIfNeeded = false);
// Now we generate the real FS path:
void GenerateFileSystemPath(void);
// now we get all the right if the file existed:
void UpdateFileSystemProperty(void);
private:
#ifdef __TARGET_OS__Android
bool LoadDataZip(void);
int32_t m_idZipFile;
char * m_zipData;
int32_t m_zipDataSize;
int32_t m_zipReadingOffset;
#endif
public:
FSNode(void);
FSNode(etk::UString nodeName);
~FSNode(void);
/*
All Right of the file
*/
bool Exist(void) { return (m_typeNode!=etk::FSN_UNKNOW); };
typeNode_te GetNodeType(void) { return m_typeNode; };
etk::FSNodeRight GetRight(void) { return m_rights; };
bool SetRight(etk::FSNodeRight newRight);
/*
Common API :
*/
void SetName(etk::UString newName);
etk::UString GetNameFolder(void) const;
etk::UString GetName(void) const;
etk::UString GetNameFile(void) const;
etk::UString GetRelativeFolder(void) const;
bool Touch(void);
FSNType_te GetTypeAccess(void) { return m_type; };
bool Remove(void);
// File time properties
uint64_t TimeCreated(void) const;
etk::UString TimeCreatedString(void) const;
uint64_t TimeModified(void) const;
etk::UString TimeModifiedString(void) const;
uint64_t TimeAccessed(void) const;
etk::UString TimeAccessedString(void) const;
/*
Operator :
*/
const etk::FSNode& operator= (const etk::FSNode &obj );
bool operator== (const etk::FSNode &obj ) const;
bool operator!= (const etk::FSNode &obj ) const;
friend etk::CCout& operator <<( etk::CCout &os,const etk::FSNode &obj);
/*
Folder specific :
*/
int32_t FolderCount(void);
etk::Vector<etk::FSNode *> FolderGetSubList(bool showHidenFile=true,
bool getFolderAndOther=true,
bool getFile=true,
bool temporaryFile=true);
etk::FSNode FolderGetParent(void); // ordered by name ...
/*
File Specific :
*/
bool FileHasExtention(void);
etk::UString FileGetExtention(void);
uint64_t FileSize(void);
bool FileOpenRead(void);
bool FileOpenWrite(void);
bool FileClose(void);
char* FileGets(char * elementLine, int32_t maxData);
// TODO : Set the return and the size of block in 64 bits
int32_t FileRead(void * data, int32_t blockSize, int32_t nbBlock);
int32_t FileWrite(void * data, int32_t blockSize, int32_t nbBlock);
bool FileSeek(long int offset, int origin);
private:
void SortElementList(etk::Vector<etk::FSNode *> &list);
};
etk::CCout& operator <<(etk::CCout &os, const etk::FSNode &obj);
void SetBaseFolderData(const char * folder);
void SetBaseFolderDataUser(const char * folder);
void SetBaseFolderCache(const char * folder);
void InitDefaultFolder(const char * applName);
etk::UString GetUserHomeFolder(void);
namespace theme
{
// TODO : Add an INIT ...
// set the Folder of a subset of a theme ...
void SetName(etk::UString refName, etk::UString folderName);
// get the folder from a Reference theme
etk::UString GetName(etk::UString refName);
// get the list of all the theme folder availlable in the user Home/appl
etk::Vector<etk::UString> List(void);
};
};
#endif

236
etk/os/FSNodeRight.cpp Normal file
View File

@ -0,0 +1,236 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Types.h>
#include <etk/DebugInternal.h>
#include <etk/os/FSNodeRight.h>
// Right Flags :
enum {
RIGHT_OTHER_EXECUTE = 1 << 0,
RIGHT_OTHER_WRITE = 1 << 1,
RIGHT_OTHER_READ = 1 << 2,
RIGHT_GROUP_EXECUTE = 1 << 3,
RIGHT_GROUP_WRITE = 1 << 4,
RIGHT_GROUP_READ = 1 << 5,
RIGHT_USER_EXECUTE = 1 << 6,
RIGHT_USER_WRITE = 1 << 7,
RIGHT_USER_READ = 1 << 8,
};
etk::FSNodeRight::FSNodeRight(void) :
m_rights(0)
{
}
etk::FSNodeRight::FSNodeRight(int16_t newRight) :
m_rights(newRight&0x01FF)
{
}
// copy operator :
const etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &obj )
{
m_rights = obj.m_rights;
return *this;
}
// set right :
const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t newVal )
{
m_rights = newVal&0x01FF;
return *this;
}
// User
bool etk::FSNodeRight::IsUserReadable(void) const
{
return ((m_rights&RIGHT_USER_READ)!=0)?true:false;
}
bool etk::FSNodeRight::IsUserWritable(void) const
{
return ((m_rights&RIGHT_USER_WRITE)!=0)?true:false;
}
bool etk::FSNodeRight::IsUserRunable(void) const
{
return ((m_rights&RIGHT_USER_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetUserReadable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_READ);
if (true == newStatus) {
m_rights |= RIGHT_USER_READ;
}
}
void etk::FSNodeRight::SetUserWritable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_WRITE);
if (true == newStatus) {
m_rights |= RIGHT_USER_WRITE;
}
}
void etk::FSNodeRight::SetUserRunable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_EXECUTE);
if (true == newStatus) {
m_rights |= RIGHT_USER_EXECUTE;
}
}
// group
bool etk::FSNodeRight::IsGroupReadable(void) const
{
return ((m_rights&RIGHT_GROUP_READ)!=0)?true:false;
}
bool etk::FSNodeRight::IsGroupWritable(void) const
{
return ((m_rights&RIGHT_GROUP_WRITE)!=0)?true:false;
}
bool etk::FSNodeRight::IsGroupRunable(void) const
{
return ((m_rights&RIGHT_GROUP_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetGroupReadable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_READ);
if (true == newStatus) {
m_rights |= RIGHT_GROUP_READ;
}
}
void etk::FSNodeRight::SetGroupWritable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_WRITE);
if (true == newStatus) {
m_rights |= RIGHT_GROUP_WRITE;
}
}
void etk::FSNodeRight::SetGroupRunable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_EXECUTE);
if (true == newStatus) {
m_rights |= RIGHT_GROUP_EXECUTE;
}
}
// other
bool etk::FSNodeRight::IsOtherReadable(void) const
{
return ((m_rights&RIGHT_OTHER_READ)!=0)?true:false;
}
bool etk::FSNodeRight::IsOtherWritable(void) const
{
return ((m_rights&RIGHT_OTHER_WRITE)!=0)?true:false;
}
bool etk::FSNodeRight::IsOtherRunable(void) const
{
return ((m_rights&RIGHT_OTHER_EXECUTE)!=0)?true:false;
}
void etk::FSNodeRight::SetOtherReadable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_READ);
if (true == newStatus) {
m_rights |= RIGHT_OTHER_READ;
}
}
void etk::FSNodeRight::SetOtherWritable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_WRITE);
if (true == newStatus) {
m_rights |= RIGHT_OTHER_WRITE;
}
}
void etk::FSNodeRight::SetOtherRunable(bool newStatus)
{
// reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_EXECUTE);
if (true == newStatus) {
m_rights |= RIGHT_OTHER_EXECUTE;
}
}
etk::UString etk::FSNodeRight::GetRight(void) const
{
etk::UString tmp;
if (true==IsUserReadable()) {
tmp += "r";
} else {
tmp += "-";
}
if (true==IsUserWritable()) {
tmp += "w";
} else {
tmp += "-";
}
if (true==IsUserRunable()) {
tmp += "x";
} else {
tmp += "-";
}
if (true==IsGroupReadable()) {
tmp += "r";
} else {
tmp += "-";
}
if (true==IsGroupWritable()) {
tmp += "w";
} else {
tmp += "-";
}
if (true==IsGroupRunable()) {
tmp += "x";
} else {
tmp += "-";
}
if (true==IsOtherReadable()) {
tmp += "r";
} else {
tmp += "-";
}
if (true==IsOtherWritable()) {
tmp += "w";
} else {
tmp += "-";
}
if (true==IsOtherRunable()) {
tmp += "x";
} else {
tmp += "-";
}
return tmp;
}
etk::CCout& etk::operator <<(etk::CCout &os, const etk::FSNodeRight &obj)
{
os << obj.GetRight();
return os;
};

58
etk/os/FSNodeRight.h Normal file
View File

@ -0,0 +1,58 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_FILE_SYSTEM_NODE_RIGHT_H__
#define __ETK_FILE_SYSTEM_NODE_RIGHT_H__
#include <etk/UString.h>
namespace etk
{
class FSNodeRight
{
private:
uint16_t m_rights;
public:
FSNodeRight(void);
FSNodeRight(int16_t newRight);
~FSNodeRight(void) { };
// copy operator :
const etk::FSNodeRight& operator= (const etk::FSNodeRight &obj );
// set right :
const etk::FSNodeRight& operator= (const int32_t newVal );
void Clear(void) { m_rights = 0; };
// User
bool IsUserReadable(void) const;
bool IsUserWritable(void) const;
bool IsUserRunable(void) const;
void SetUserReadable(bool newStatus);
void SetUserWritable(bool newStatus);
void SetUserRunable(bool newStatus);
// group
bool IsGroupReadable(void) const;
bool IsGroupWritable(void) const;
bool IsGroupRunable(void) const;
void SetGroupReadable(bool newStatus);
void SetGroupWritable(bool newStatus);
void SetGroupRunable(bool newStatus);
// other
bool IsOtherReadable(void) const;
bool IsOtherWritable(void) const;
bool IsOtherRunable(void) const;
void SetOtherReadable(bool newStatus);
void SetOtherWritable(bool newStatus);
void SetOtherRunable(bool newStatus);
etk::UString GetRight(void) const;
};
etk::CCout& operator <<(etk::CCout &os, const etk::FSNodeRight &obj);
};
#endif

35
etk/os/Memory.cpp Normal file
View File

@ -0,0 +1,35 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Types.h>
#include <etk/os/Memory.h>
// General
#if ETK_MEMORY_CHECKER > 0
void etk::MemFree( void * pointerData, const char * variableName, const char * functionName, int32_t line, const char * fileName )
{
TK_CRITICAL(" MEM FREE is not written ==> TODO...");
if (NULL != pointerData) {
free(pointerData);
}
}
void * etk::MemMalloc( size_t num, size_t size, uint8_t init, const char * variableName, const char * functionName, int32_t line, const char * fileName )
{
TK_CRITICAL(" MEM ALLOCATOR is not written ==> TODO...");
return calloc(num, size);
}
void etk::MemShowLogs( void )
{
TK_CRITICAL(" MEM DISPLAY is not written ==> TODO...");
}
#endif

80
etk/os/Memory.h Normal file
View File

@ -0,0 +1,80 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TOOLS_MEMORY_H__
#define __ETK_TOOLS_MEMORY_H__
#ifndef ETK_MEMORY_CHECKER
#define ETK_MEMORY_CHECKER 0
#endif
// General
#if ETK_MEMORY_CHECKER > 0
namespace etk {
void MemFree( void * pointerData, const char * variableName, const char * functionName, int32_t line, const char * fileName );
void * MemMalloc( size_t num, size_t size, uint8_t init, const char * variableName, const char * functionName, int32_t line, const char * fileName );
void MemShowLogs( void );
};
# define ETK_MALLOC(pointerData, nbElements, dataType) do { \
pointerData = (dataType *)etk::MemMalloc( (nbElements), sizeof(dataType), 0, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_MALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
pointerData = (cast)etk::MemMalloc( (nbElements), sizeof(dataType), 0, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_CALLOC(pointerData, nbElements, dataType) do { \
pointerData = (dataType *)etk::MemMalloc( (nbElements), sizeof(dataType), 1, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_CALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
pointerData = (cast)etk::MemMalloc( (nbElements), sizeof(dataType), 1, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_FREE(pointerData) do { \
etk::MemFree( (pointerData) , #pointerData, __func__, __LINE__, __FILE__); \
(pointerData) = NULL; \
}while(0)
# define ETK_MEM_SHOW_LOG() do { \
etk::MemShowLogs(); \
}while(0)
#else
# define ETK_MALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)malloc( (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_MALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)malloc( (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_CALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)calloc( (nbElements), sizeof(dataType) ); \
}while(0)
# define ETK_CALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)calloc( (nbElements), sizeof(dataType) ); \
}while(0)
# define ETK_REALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)realloc( (pointerData), (nbElements)* sizeof(dataType) ); \
}while(0)
# define ETK_REALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)realloc( (pointerData), (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_FREE(pointerData) do { \
free( pointerData ); \
(pointerData) = NULL; \
}while(0)
# define ETK_MEM_SHOW_LOG() do { \
TK_DEBUG("No Memory check availlable"); \
}while(0)
#endif
#endif

44
etk/os/Mutex.Generic.cpp Normal file
View File

@ -0,0 +1,44 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/os/Mutex.h>
#include <etk/DebugInternal.h>
etk::Mutex::Mutex(void)
{
// create interface mutex :
int ret = pthread_mutex_init(&m_mutex, NULL);
TK_ASSERT(ret == 0, "Error creating Mutex ...");
}
etk::Mutex::~Mutex(void)
{
// Remove mutex
int ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
void etk::Mutex::Lock(void)
{
pthread_mutex_lock(&m_mutex);
}
bool etk::Mutex::TryLock(void)
{
return pthread_mutex_trylock(&m_mutex) != 0;
}
void etk::Mutex::UnLock(void)
{
pthread_mutex_unlock(&m_mutex);
}

40
etk/os/Mutex.Windows.cpp Normal file
View File

@ -0,0 +1,40 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/os/Mutex.h>
etk::Mutex::Mutex(void)
{
InitializeCriticalSection(&m_mutex);
}
etk::Mutex::~Mutex(void)
{
DeleteCriticalSection(&m_mutex);
}
void etk::Mutex::Lock(void)
{
EnterCriticalSection(&m_mutex);
}
bool etk::Mutex::TryLock(void)
{
return TryEnterCriticalSection(&m_mutex) != 0;
}
void etk::Mutex::UnLock(void)
{
LeaveCriticalSection(&m_mutex);
}

40
etk/os/Mutex.h Normal file
View File

@ -0,0 +1,40 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/Types.h>
#ifndef __ETK_MUTEX_H__
#define __ETK_MUTEX_H__
#ifdef __TARGET_OS__Windows
#include <windows.h>
#else
#include <pthread.h>
#endif
namespace etk
{
class Mutex
{
private:
#ifdef __TARGET_OS__Windows
CRITICAL_SECTION m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
public:
Mutex(void);
~Mutex(void);
void Lock(void);
bool TryLock(void);
void UnLock(void);
};
};
#endif

View File

@ -0,0 +1,96 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/os/Semaphore.h>
#include <etk/DebugInternal.h>
#include <sys/time.h>
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 ...");
// create contition :
ret = pthread_cond_init(&m_condition, NULL);
TK_ASSERT(ret == 0, "Error creating Condition ...");
if (ret != 0) {
ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
m_maximum = nbMessageMax;
m_data = nbBasicElement;
}
etk::Semaphore::~Semaphore(void)
{
// Remove condition
int ret = pthread_cond_destroy(&m_condition);
TK_ASSERT(ret == 0, "Error destroying Condition ...");
// Remove Mutex
ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
uint32_t etk::Semaphore::GetCount(void)
{
int32_t tmpData = 0;
pthread_mutex_lock(&m_mutex);
tmpData = m_data;
pthread_mutex_unlock(&m_mutex);
return tmpData;
}
void etk::Semaphore::Post(void)
{
pthread_mutex_lock(&m_mutex);
if (m_data>=m_maximum) {
m_data = m_maximum;
} else {
m_data++;
}
// send message
pthread_cond_broadcast(&m_condition);
pthread_mutex_unlock(&m_mutex);
}
void etk::Semaphore::Wait(void)
{
pthread_mutex_lock(&m_mutex);
while(m_data == 0) {
pthread_cond_wait(&m_condition, &m_mutex);
}
m_data--;
pthread_mutex_unlock(&m_mutex);
}
bool etk::Semaphore::Wait(uint32_t timeOutInUs)
{
pthread_mutex_lock(&m_mutex);
if(m_data == 0) {
struct timeval tp;
struct timespec ts;
gettimeofday(&tp,NULL);
uint64_t totalTimeUS = tp.tv_sec * 1000000 + tp.tv_usec;
totalTimeUS += timeOutInUs;
ts.tv_sec = totalTimeUS / 1000000;
ts.tv_nsec = (totalTimeUS%1000000) * 1000;
int ret = pthread_cond_timedwait(&m_condition, &m_mutex, &ts);
if (ret !=0) { //== ETIMEOUT) {
pthread_mutex_unlock(&m_mutex);
return false;
}
}
m_data--;
pthread_mutex_unlock(&m_mutex);
return true;
}

View File

@ -0,0 +1,54 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/os/Semaphore.h>
#include <etk/DebugInternal.h>
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)
{
CloseHandle(m_semaphore);
}
uint32_t etk::Semaphore::GetCount(void)
{
LONG tmpData = 0;
ReleaseSemaphore(m_semaphore, 0, &tmpData);
return tmpData;
}
void etk::Semaphore::Post(void)
{
ReleaseSemaphore(m_semaphore, 1, NULL);
}
void etk::Semaphore::Wait(void)
{
WaitForSingleObject(m_semaphore, INFINITE);
}
bool etk::Semaphore::Wait(uint32_t timeOutInUs)
{
DWORD result = WaitForSingleObject(m_semaphore, timeOutInUs);
if (result == WAIT_FAILED) {
TK_ERROR("Failed to wait for semaphore ");
return false;
} else {
return result == WAIT_OBJECT_0;
}
}

0
etk/os/Semaphore.cpp Normal file
View File

45
etk/os/Semaphore.h Normal file
View File

@ -0,0 +1,45 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_SEMAPHORE_H__
#define __ETK_SEMAPHORE_H__
#include <etk/Types.h>
#ifdef __TARGET_OS__Windows
#include <windows.h>
#else
#include <pthread.h>
#endif
namespace etk
{
class Semaphore
{
private:
#ifdef __TARGET_OS__Windows
HANDLE m_semaphore;
#else
pthread_mutex_t m_mutex;
pthread_cond_t m_condition;
uint32_t m_data;
uint32_t m_maximum;
#endif
public:
Semaphore(uint32_t nbBasicElement=0, uint32_t nbMessageMax=1);
~Semaphore(void);
uint32_t GetCount(void);
void Post(void);
void Wait(void);
// wait with a timeout in us; return true if get the semaphore
bool Wait(uint32_t timeOutInUs);
};
};
#endif

135
etk/tool.cpp Normal file
View File

@ -0,0 +1,135 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/tool.h>
#include <etk/os/FSNode.h>
// for the rand ...
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <stdlib.h>
float etk::tool::frand(float a, float b)
{
return ( rand()/(float)RAND_MAX ) * (b-a) + a;
}
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(etk::Vector<etk::UString *> &m_listDirectory)
{
etk::Vector<etk::UString *> tmpList = m_listDirectory;
m_listDirectory.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
int32_t findPos = 0;
for(int32_t jjj=0; jjj<m_listDirectory.Size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (*tmpList[iii] > *m_listDirectory[jjj]) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
m_listDirectory.Insert(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;
}
etk::UString etk::tool::SimplifyPath(etk::UString input)
{
int32_t findStartPos = input.FindForward('/') + 1;
int32_t findPos = input.FindForward('/', findStartPos);
//TK_DEBUG("Siplify : \"" << input << "\"");
int32_t preventBadCode = 0;
while (findPos!=-1)
{
//TK_DEBUG(" string=\"" << input << "\"");
//TK_DEBUG(" '/' @" << findPos);
if (input.Size()<findPos+1) {
// no more element ...
break;
}
if( input[findPos+1] == '/'
|| ( input[findPos+1] == '.'
&& input.Size()==findPos+2 )) {
// cleane the element path
input.Remove(findPos+1, 1);
//TK_DEBUG(" Remove // string=\"" << input << "\"");
} else {
if (input.Size()<findPos+2) {
// no more element ...
break;
}
if( input[findPos+1] == '.'
&& input[findPos+2] == '.') {
// cleane the element path
input.Remove(findStartPos, findPos+3 - findStartPos );
//TK_DEBUG(" Remove xxx/.. string=\"" << input << "\"");
} else if( input[findPos+1] == '.'
&& input[findPos+2] == '/') {
// cleane the element path
input.Remove(findPos+1, 2);
//TK_DEBUG(" Remove ./ string=\"" << input << "\"");
} else {
findStartPos = findPos+1;
}
}
findPos = input.FindForward('/', findStartPos);
preventBadCode++;
if (preventBadCode>5000) {
TK_CRITICAL("ERROR when getting the small path ... this is loop prevention...");
break;
}
}
#ifndef __TARGET_OS__Windows
// for the target that supported the Realpath system :
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok = realpath(input.c_str(), buf);
if (!ok) {
TK_ERROR("Error to get the real path");
input = "/";
} else {
input = buf;
}
#endif
//TK_DEBUG(" ==> \"" << input << "\"");
return input;
}

25
etk/tool.h Normal file
View File

@ -0,0 +1,25 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_TOOL_H__
#define __ETK_TOOL_H__
#include <etk/Types.h>
#include <etk/UString.h>
namespace etk {
namespace tool {
float frand(float a, float b);
int32_t irand(int32_t a, int32_t b);
void SortList(etk::Vector<etk::UString *> &m_listDirectory);
bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxLen);
etk::UString SimplifyPath(etk::UString input);
};
};
#endif

763
etk/unicode.cpp Normal file
View File

@ -0,0 +1,763 @@
/**
* @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(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode)
{
switch(inputCharset)
{
case EDN_CHARSET_ISO_8859_1: output_Unicode = TableIso8859_1[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_2: output_Unicode = TableIso8859_2[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_3: output_Unicode = TableIso8859_3[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_4: output_Unicode = TableIso8859_4[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_5: output_Unicode = TableIso8859_5[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_6: output_Unicode = TableIso8859_6[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_7: output_Unicode = TableIso8859_7[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_8: output_Unicode = TableIso8859_8[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_9: output_Unicode = TableIso8859_9[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_10: output_Unicode = TableIso8859_10[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_11: output_Unicode = TableIso8859_11[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_13: output_Unicode = TableIso8859_13[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_14: output_Unicode = TableIso8859_14[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_15:
output_Unicode = TableIso8859_15[(uint32_t)input_ISO&0xFF];
break;
default :
TK_WARNING("Unknow charset ... " << inputCharset);
output_Unicode = '?';
break;
}
}
void unicode::convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO)
{
const uniChar_t *tmpTable = NULL;
switch(inputCharset)
{
case EDN_CHARSET_ISO_8859_1: tmpTable = TableIso8859_1; break;
case EDN_CHARSET_ISO_8859_2: tmpTable = TableIso8859_2; break;
case EDN_CHARSET_ISO_8859_3: tmpTable = TableIso8859_3; break;
case EDN_CHARSET_ISO_8859_4: tmpTable = TableIso8859_4; break;
case EDN_CHARSET_ISO_8859_5: tmpTable = TableIso8859_5; break;
case EDN_CHARSET_ISO_8859_6: tmpTable = TableIso8859_6; break;
case EDN_CHARSET_ISO_8859_7: tmpTable = TableIso8859_7; break;
case EDN_CHARSET_ISO_8859_8: tmpTable = TableIso8859_8; break;
case EDN_CHARSET_ISO_8859_9: tmpTable = TableIso8859_9; break;
case EDN_CHARSET_ISO_8859_10: tmpTable = TableIso8859_10; break;
case EDN_CHARSET_ISO_8859_11: tmpTable = TableIso8859_11; break;
case EDN_CHARSET_ISO_8859_13: tmpTable = TableIso8859_13; break;
case EDN_CHARSET_ISO_8859_14: tmpTable = TableIso8859_14; break;
case EDN_CHARSET_ISO_8859_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(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<uniChar_t>& output_Unicode)
{
output_Unicode.Clear();
uniChar_t output;
for(int32_t iii=0; iii<input_ISO.Size(); iii++) {
convertIsoToUnicode(inputCharset, (char)input_ISO[iii], output);
output_Unicode.PushBack(output);
}
if (output_Unicode.Size() == 0) {
output_Unicode.PushBack(0);
} else if (output_Unicode[output_Unicode.Size()-1] != 0) {
output_Unicode.PushBack(0);
}
return output_Unicode.Size();
}
int32_t unicode::convertIsoToUnicode(charset_te inputCharset, etk::Vector<int8_t>& input_ISO, etk::Vector<uniChar_t>& output_Unicode)
{
output_Unicode.Clear();
uniChar_t output;
for(int32_t iii=0; iii<input_ISO.Size(); iii++) {
convertIsoToUnicode(inputCharset, (char)input_ISO[iii], output);
output_Unicode.PushBack(output);
}
if (output_Unicode.Size() == 0) {
output_Unicode.PushBack(0);
} else if (output_Unicode[output_Unicode.Size()-1] != 0) {
output_Unicode.PushBack(0);
}
return output_Unicode.Size();
}
int32_t unicode::convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_ISO)
{
output_ISO.Clear();
char output[10];
for(int32_t iii=0; iii<input_Unicode.Size(); iii++) {
convertUnicodeToUtf8(input_Unicode[iii], output);
char * tmp = output;
while(*tmp != '\0') {
output_ISO.PushBack(*tmp);
tmp++;
}
}
output_ISO.PushBack(0);
return output_ISO.Size();
}
int32_t unicode::convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_ISO)
{
output_ISO.Clear();
char output[10];
for(int32_t iii=0; iii<input_Unicode.Size(); iii++) {
convertUnicodeToUtf8(input_Unicode[iii], output);
char * tmp = output;
while(*tmp != '\0') {
output_ISO.PushBack(*tmp);
tmp++;
}
}
output_ISO.PushBack(0);
return output_ISO.Size();
}
static uint32_t unicodeToUtf8(uniChar_t value)
{
uint32_t output = 0;
if (127 >= value) {
output = value;
} else if (2047 >= value) {
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
// input ==> -------- -------- -----222 22111111
output = 0x0000C080;
output+= (value & 0x000007C0)<<2;
output+= value & 0x0000003F;
} else if (65535 >= value) {
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
// input ==> -------- -------- 33332222 22111111
output = 0x00E08080;
output+= (value & 0x0000F000)<<4;
output+= (value & 0x00000FC0)<<2;
output+= value & 0x0000003F;
} else if (1114111 >= value) {
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// input ==> -------- ---44433 33332222 22111111
output = 0xF0808080;
output+= (value & 0x001C0000)<<6;
output+= (value & 0x0003F000)<<4;
output+= (value & 0x00000FC0)<<2;
output+= value & 0x0000003F;
} else {
TK_ERROR("NON UTF8 caracter input...");
return 0;
}
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
return output;
}
void unicode::convertUnicodeToUtf8(uniChar_t input_Unicode, char * output_UTF8)
{
uint32_t value = unicodeToUtf8(input_Unicode);
if (0xFF >= value) {
output_UTF8[0] = (char)value;
output_UTF8[1] = '\0';
} else if (0xFFFF >= value) {
output_UTF8[0] = (char)((value>>8) & 0x000000FF);
output_UTF8[1] = (char)value;
output_UTF8[2] = '\0';
} else if (0xFFFFFF >= value) {
output_UTF8[0] = (char)((value>>16) & 0x000000FF);
output_UTF8[1] = (char)((value>>8) & 0x000000FF);
output_UTF8[2] = (char)value;
output_UTF8[3] = '\0';
} else {
output_UTF8[0] = (char)((value>>24) & 0x000000FF);
output_UTF8[1] = (char)((value>>16) & 0x000000FF);
output_UTF8[2] = (char)((value>>8) & 0x000000FF);
output_UTF8[3] = (char)value;
output_UTF8[4] = '\0';
}
}
void unicode::convertUtf8ToUnicode(char * input_UTF8, uniChar_t &output_Unicode)
{
int32_t len = strlen(input_UTF8);
output_Unicode = 0;
switch (len) {
case 1:
output_Unicode = (uint8_t)(input_UTF8[0]) & 0x7F;
break;
case 2:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x1F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[1]) & 0x3F;
break;
case 3:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x0F)<< 12;
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[2]) & 0x3F;
break;
default:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x07)<< 18;
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 12;
output_Unicode += (((uint8_t)input_UTF8[2]) & 0x3F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[3]) & 0x3F;
break;
}
}
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_UTF8)
{
char output[10];
for (int32_t iii=0; iii<input_Unicode.Size(); iii++) {
unicode::convertUnicodeToUtf8(input_Unicode[iii], output);
char * tmp = output ;
while (*tmp != '\0') {
output_UTF8.PushBack(*tmp);
tmp++;
}
}
output_UTF8.PushBack('\0');
return output_UTF8.Size()-1;
}
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_UTF8)
{
char output[10];
for (int32_t iii=0; iii<input_Unicode.Size(); iii++) {
unicode::convertUnicodeToUtf8(input_Unicode[iii], output);
char * tmp = output ;
while (*tmp != '\0') {
output_UTF8.PushBack((int8_t)*tmp);
tmp++;
}
}
output_UTF8.PushBack('\0');
return output_UTF8.Size()-1;
}
int32_t unicode::convertUtf8ToUnicode(etk::Vector<char>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode)
{
char tmpData[20];
int32_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;
}
uniChar_t tmpUnicode;
convertUtf8ToUnicode(tmpData, tmpUnicode);
output_Unicode.PushBack(tmpUnicode);
}
return 0;
}
int32_t unicode::convertUtf8ToUnicode(etk::Vector<int8_t>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode)
{
char tmpData[20];
int32_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;
}
uniChar_t tmpUnicode;
convertUtf8ToUnicode(tmpData, tmpUnicode);
output_Unicode.PushBack(tmpUnicode);
}
return 0;
}
int32_t unicode::convertUtf8ToUnicode(char * input_UTF8, etk::Vector<uniChar_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;
}
uniChar_t tmpUnicode;
convertUtf8ToUnicode(tmpData, tmpUnicode);
output_Unicode.PushBack(tmpUnicode);
}
return 0;
}
// Transform ISO <==> UTF-8
void unicode::convertIsoToUtf8(charset_te inputCharset, char input_ISO, char * output_UTF8)
{
uniChar_t tmpUnicode;
// concert Iso in UniCode
convertIsoToUnicode(inputCharset, input_ISO, tmpUnicode );
// convert UniCode in Utf-8
convertUnicodeToUtf8(tmpUnicode, output_UTF8);
}
void unicode::convertUtf8ToIso(charset_te inputCharset, char * input_UTF8, char & output_ISO)
{
uniChar_t tmpUnicode;
// convert Utf-8 in UniCode
convertUtf8ToUnicode(input_UTF8, tmpUnicode);
// concert UniCode in Iso
convertUnicodeToIso(inputCharset, tmpUnicode, output_ISO);
}
int32_t unicode::convertIsoToUtf8(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<char>& output_UTF8)
{
TK_WARNING("TODO : not coded...");
return 0;
}
int32_t unicode::convertUtf8ToIso(charset_te inputCharset, etk::Vector<char>& input_UTF8, etk::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

59
etk/unicode.h Normal file
View File

@ -0,0 +1,59 @@
/**
* @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 <etk/Vector.h>
namespace unicode {
typedef enum {
EDN_CHARSET_UTF8,
EDN_CHARSET_ISO_8859_1,
EDN_CHARSET_ISO_8859_2,
EDN_CHARSET_ISO_8859_3,
EDN_CHARSET_ISO_8859_4,
EDN_CHARSET_ISO_8859_5,
EDN_CHARSET_ISO_8859_6,
EDN_CHARSET_ISO_8859_7,
EDN_CHARSET_ISO_8859_8,
EDN_CHARSET_ISO_8859_9,
EDN_CHARSET_ISO_8859_10,
EDN_CHARSET_ISO_8859_11,
EDN_CHARSET_ISO_8859_13,
EDN_CHARSET_ISO_8859_14,
EDN_CHARSET_ISO_8859_15,
} charset_te;
// transform ISO <==> Unicode
void convertIsoToUnicode(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode);
void convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO);
int32_t convertIsoToUnicode(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<uniChar_t>& output_Unicode);
int32_t convertIsoToUnicode(charset_te inputCharset, etk::Vector<int8_t>& input_ISO, etk::Vector<uniChar_t>& output_Unicode);
int32_t convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_ISO);
int32_t convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_ISO);
// Transform UTF-8 <==> Unicode
void convertUnicodeToUtf8( uniChar_t input_Unicode, char * output_UTF8);
void convertUtf8ToUnicode( char * input_UTF8, uniChar_t& output_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( etk::Vector<char>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
int32_t convertUtf8ToUnicode( etk::Vector<int8_t>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
int32_t convertUtf8ToUnicode( char * input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
// Transform ISO <==> UTF-8
void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8);
void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO);
int32_t convertIsoToUtf8( charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<char>& output_UTF8);
int32_t convertUtf8ToIso( charset_te inputCharset, etk::Vector<char>& input_UTF8, etk::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

282
etk/unicodeTable.cpp Normal file
View File

@ -0,0 +1,282 @@
/**
* @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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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 uniChar_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
};
}

34
etk/unicodeTable.h Normal file
View File

@ -0,0 +1,34 @@
/**
* @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 uniChar_t TableIso8859_1[];
extern const uniChar_t TableIso8859_2[];
extern const uniChar_t TableIso8859_3[];
extern const uniChar_t TableIso8859_4[];
extern const uniChar_t TableIso8859_5[];
extern const uniChar_t TableIso8859_6[];
extern const uniChar_t TableIso8859_7[];
extern const uniChar_t TableIso8859_8[];
extern const uniChar_t TableIso8859_9[];
extern const uniChar_t TableIso8859_10[];
extern const uniChar_t TableIso8859_11[];
extern const uniChar_t TableIso8859_13[];
extern const uniChar_t TableIso8859_14[];
extern const uniChar_t TableIso8859_15[];
;
}
#endif

32
file.mk Normal file
View File

@ -0,0 +1,32 @@
FILE_LIST = \
etk/Debug.cpp \
etk/DebugInternal.cpp \
etk/unicode.cpp \
etk/unicodeTable.cpp \
etk/UString.cpp \
etk/Stream.cpp \
etk/RegExp.cpp \
etk/tool.cpp
FILE_LIST+= \
etk/math/Matrix4.cpp
FILE_LIST+= \
etk/os/FSNode.cpp \
etk/os/FSNodeRight.cpp \
etk/os/Memory.cpp \
ifeq ("$(TARGET_OS)","Windows")
FILE_LIST += etk/os/Mutex.Windows.cpp
FILE_LIST += etk/os/Semaphore.Windows.cpp
else
FILE_LIST += etk/os/Mutex.Generic.cpp
FILE_LIST += etk/os/Semaphore.Generic.cpp
endif

35
license.txt Normal file
View File

@ -0,0 +1,35 @@
Copyright (c)
=============
2011, Edouard DUPIN
License (DSB)
=============
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.