[DEV] change base coding style
This commit is contained in:
parent
dfcb78c081
commit
006233a2fd
174
etk/Buffer.h
174
etk/Buffer.h
@ -64,7 +64,7 @@ namespace etk
|
||||
m_gapStart(0),
|
||||
m_gapEnd(GAP_SIZE_MIN)
|
||||
{
|
||||
ChangeAllocation(_count+GAP_SIZE_MIN);
|
||||
changeAllocation(_count+GAP_SIZE_MIN);
|
||||
}
|
||||
/**
|
||||
* @brief Re-copy constructor (copy all needed data)
|
||||
@ -100,16 +100,16 @@ namespace etk
|
||||
* @param[in,out] _file Pointer on the file where data might be writed
|
||||
* @return true if OK / false if an error occured
|
||||
*/
|
||||
bool DumpIn(etk::FSNode& _file)
|
||||
bool dumpIn(etk::FSNode& _file)
|
||||
{
|
||||
if (false == _file.FileOpenWrite()) {
|
||||
if (false == _file.fileOpenWrite()) {
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
// write Data
|
||||
(void)_file.FileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)_file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
_file.FileClose();
|
||||
(void)_file.fileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)_file.fileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
_file.fileClose();
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
@ -117,21 +117,21 @@ namespace etk
|
||||
* @param[in,out] _myFile Pointer on the file where data might be read
|
||||
* @return true if OK / false if an error occured
|
||||
*/
|
||||
bool DumpFrom(etk::FSNode& _file)
|
||||
bool dumpFrom(etk::FSNode& _file)
|
||||
{
|
||||
if (false == _file.FileOpenRead()) {
|
||||
if (false == _file.fileOpenRead()) {
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
uint32_t length = _file.FileSize();
|
||||
uint32_t length = _file.fileSize();
|
||||
// error case ...
|
||||
if (length > 2000000000) {
|
||||
return false;
|
||||
}
|
||||
// allocate the current buffer :
|
||||
ChangeAllocation(length + GAP_SIZE_MIN);
|
||||
changeAllocation(length + GAP_SIZE_MIN);
|
||||
// insert Data
|
||||
int32_t nbReadData = _file.FileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
int32_t nbReadData = _file.fileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
TK_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
|
||||
// check ERROR
|
||||
if (nbReadData != length) {
|
||||
@ -141,7 +141,7 @@ namespace etk
|
||||
// set the gapsize at the end ...
|
||||
m_gapStart = 0;
|
||||
m_gapEnd = GAP_SIZE_MIN;
|
||||
_file.FileClose();
|
||||
_file.fileClose();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ namespace etk
|
||||
*/
|
||||
int8_t operator[] (int32_t _pos) const
|
||||
{
|
||||
TK_ASSERT(0 <= _pos || _pos < Size(), "try to read an element non existing");
|
||||
TK_ASSERT(0 <= _pos || _pos < size(), "try to read an element non existing");
|
||||
if (_pos < m_gapStart) {
|
||||
return m_data[_pos];
|
||||
}
|
||||
@ -190,9 +190,9 @@ namespace etk
|
||||
* @param[in] _pos Desired position read
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
int8_t& Get(int32_t _pos) const
|
||||
int8_t& get(int32_t _pos) const
|
||||
{
|
||||
TK_ASSERT(0 <= _pos || _pos < Size(), "try to read an element non existing");
|
||||
TK_ASSERT(0 <= _pos || _pos < size(), "try to read an element non existing");
|
||||
if (_pos < m_gapStart) {
|
||||
return m_data[_pos];
|
||||
}
|
||||
@ -204,9 +204,9 @@ namespace etk
|
||||
* @param[in] _pos Desired position read
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
esize_t Get(esize_t _pos, UniChar& _value, charset_te _charset) const
|
||||
esize_t get(esize_t _pos, UniChar& _value, charset_te _charset) const
|
||||
{
|
||||
TK_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
|
||||
TK_ASSERT(0 <= pos || pos < size(), "try to read an element non existing");
|
||||
if (pos < m_gapStart) {
|
||||
return m_data[pos];
|
||||
}
|
||||
@ -219,19 +219,19 @@ namespace etk
|
||||
* @param[in] _nbElement Number of element needed.
|
||||
* @return The data requested
|
||||
*/
|
||||
etk::Vector<int8_t> Get(int32_t _pos, int32_t _nbElement)
|
||||
etk::Vector<int8_t> get(int32_t _pos, int32_t _nbElement)
|
||||
{
|
||||
etk::Vector<int8_t> tmpBuffer;
|
||||
tmpBuffer.Clear();
|
||||
tmpBuffer.clear();
|
||||
if (_pos < m_gapStart) {
|
||||
if (_pos + _nbElement < m_gapStart) {
|
||||
tmpBuffer.PushBack(&m_data[_pos], _nbElement);
|
||||
tmpBuffer.pushBack(&m_data[_pos], _nbElement);
|
||||
} else {
|
||||
tmpBuffer.PushBack(&m_data[_pos], m_gapStart - _pos);
|
||||
tmpBuffer.PushBack(&m_data[m_gapEnd], _nbElement - (m_gapStart - _pos) );
|
||||
tmpBuffer.pushBack(&m_data[_pos], m_gapStart - _pos);
|
||||
tmpBuffer.pushBack(&m_data[m_gapEnd], _nbElement - (m_gapStart - _pos) );
|
||||
}
|
||||
} else {
|
||||
tmpBuffer.PushBack(&m_data[_pos+(m_gapEnd-m_gapStart)], _nbElement);
|
||||
tmpBuffer.pushBack(&m_data[_pos+(m_gapEnd-m_gapStart)], _nbElement);
|
||||
}
|
||||
return tmpBuffer;
|
||||
}
|
||||
@ -239,24 +239,24 @@ namespace etk
|
||||
* @brief Add at the Last position of the Vector
|
||||
* @param[in] _item Element to add at the end of vector
|
||||
*/
|
||||
void PushBack(const int8_t& _item)
|
||||
void pushBack(const int8_t& _item)
|
||||
{
|
||||
Insert(Size(), _item);
|
||||
insert(size(), _item);
|
||||
}
|
||||
/**
|
||||
* @brief Insert One item at the specify position.
|
||||
* @param[in] _pos Position where data might be inserted
|
||||
* @param[in] _items Data that might be inserted.
|
||||
*/
|
||||
void Insert(int32_t _pos, const int8_t& _item)
|
||||
void insert(int32_t _pos, const int8_t& _item)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << Size());
|
||||
return;
|
||||
}
|
||||
if( 0 == GapSize() ) {
|
||||
if (false == GapResize(_pos, GAP_SIZE_MIN + 1) ) {
|
||||
if( 0 == gapSize() ) {
|
||||
if (false == gapResize(_pos, GAP_SIZE_MIN + 1) ) {
|
||||
return;
|
||||
}
|
||||
} else if( _pos == m_gapStart
|
||||
@ -264,7 +264,7 @@ namespace etk
|
||||
{
|
||||
// mothing to do ...
|
||||
} else {
|
||||
if (GapMove(_pos) == false) {
|
||||
if (gapMove(_pos) == false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -281,9 +281,9 @@ namespace etk
|
||||
* @param[in] _pos Position where data might be inserted
|
||||
* @param[in] _items Data that might be inserted.
|
||||
*/
|
||||
void Insert(int32_t _pos, etk::Vector<int8_t>& _items)
|
||||
void insert(int32_t _pos, etk::Vector<int8_t>& _items)
|
||||
{
|
||||
Insert(_pos, _items.DataPointer(), _items.Size());
|
||||
insert(_pos, _items.dataPointer(), _items.size());
|
||||
}
|
||||
/**
|
||||
* @brief Insert data in the buffer
|
||||
@ -291,19 +291,19 @@ namespace etk
|
||||
* @param[in] _items Data that might be inserted. (no need of '\0')
|
||||
* @param[in] _nbElement number of element to insert
|
||||
*/
|
||||
void Insert(int32_t _pos, int8_t* _items, int32_t _nbElement)
|
||||
void insert(int32_t _pos, int8_t* _items, int32_t _nbElement)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
return;
|
||||
}
|
||||
if(_nbElement > GapSize()) {
|
||||
if (false == GapResize(_pos, GAP_SIZE_MIN + _nbElement) ) {
|
||||
if(_nbElement > gapSize()) {
|
||||
if (false == gapResize(_pos, GAP_SIZE_MIN + _nbElement) ) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (false == GapMove(_pos) ) {
|
||||
if (false == gapMove(_pos) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -317,18 +317,18 @@ namespace etk
|
||||
* @param[in] _pos The first element to remove.
|
||||
* @param[in] _items Data that might be inserted.
|
||||
*/
|
||||
void Replace(int32_t _pos, const int8_t& _item)
|
||||
void replace(int32_t _pos, const int8_t& _item)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
return;
|
||||
}
|
||||
// just replace the element, not update Gap position
|
||||
if (_pos < m_gapStart) {
|
||||
m_data[_pos] = _item;
|
||||
} else {
|
||||
m_data[_pos+GapSize()] = _item;
|
||||
m_data[_pos+gapSize()] = _item;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -337,9 +337,9 @@ namespace etk
|
||||
* @param[in] _nbRemoveElement number of element to remove.
|
||||
* @param[in] _items Data that might be inserted.
|
||||
*/
|
||||
void Replace(int32_t _pos, int32_t _nbRemoveElement, etk::Vector<int8_t>& _items)
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, etk::Vector<int8_t>& _items)
|
||||
{
|
||||
Replace(_pos, _nbRemoveElement, _items.DataPointer(), _items.Size());
|
||||
replace(_pos, _nbRemoveElement, _items.dataPointer(), _items.size());
|
||||
}
|
||||
/**
|
||||
* @brief Replace specified data.
|
||||
@ -348,47 +348,47 @@ namespace etk
|
||||
* @param[in] _items Data that might be inserted.
|
||||
* @param[in] _nbElement Number of element that might be added.
|
||||
*/
|
||||
void Replace(int32_t _pos, int32_t _nbRemoveElement, int8_t* _items, int32_t _nbElement)
|
||||
void replace(int32_t _pos, int32_t _nbRemoveElement, int8_t* _items, int32_t _nbElement)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
return;
|
||||
}
|
||||
if( _pos+_nbRemoveElement > Size() ) {
|
||||
if( _pos+_nbRemoveElement > size() ) {
|
||||
TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
|
||||
<< _pos+_nbRemoveElement << " bufferSize=" << Size());
|
||||
<< _pos+_nbRemoveElement << " bufferSize=" << size());
|
||||
return;
|
||||
}
|
||||
if (false == GapMove(_pos)) {
|
||||
if (false == gapMove(_pos)) {
|
||||
return;
|
||||
}
|
||||
// Remove elements :
|
||||
m_gapEnd += _nbRemoveElement;
|
||||
//Display();
|
||||
// insert elements
|
||||
Insert(_pos, _items, _nbElement);
|
||||
insert(_pos, _items, _nbElement);
|
||||
// Resize buffer if needed...
|
||||
GapCheckMaxSize();
|
||||
gapCheckMaxSize();
|
||||
}
|
||||
/**
|
||||
* @brief Remove specific data in the buffer.
|
||||
* @param[in] _pos The first element to remove
|
||||
* @param[in] _nbRemoveElement number of element to remove
|
||||
*/
|
||||
void Remove(int32_t _pos, int32_t _nbRemoveElement = 1)
|
||||
void remove(int32_t _pos, int32_t _nbRemoveElement = 1)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
||||
return;
|
||||
}
|
||||
if( _pos+_nbRemoveElement > Size() ) {
|
||||
if( _pos+_nbRemoveElement > size() ) {
|
||||
TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
|
||||
<< _pos+_nbRemoveElement << " bufferSize=" << Size());
|
||||
<< _pos+_nbRemoveElement << " bufferSize=" << size());
|
||||
return;
|
||||
}
|
||||
if (GapMove(_pos) == false) {
|
||||
if (gapMove(_pos) == false) {
|
||||
return;
|
||||
}
|
||||
// Remove elements :
|
||||
@ -398,30 +398,30 @@ namespace etk
|
||||
m_gapEnd += _nbRemoveElement;
|
||||
}
|
||||
// Resize buffer if needed...
|
||||
GapCheckMaxSize();
|
||||
gapCheckMaxSize();
|
||||
}
|
||||
/**
|
||||
* @brief Remove the last element of the Buffer.
|
||||
*/
|
||||
void PopBack(void)
|
||||
void popBack(void)
|
||||
{
|
||||
if (Size()>0) {
|
||||
Remove( Size() );
|
||||
if (size()>0) {
|
||||
remove( size() );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Clean all the data in the buffer.
|
||||
*/
|
||||
void Clear(void)
|
||||
void clear(void)
|
||||
{
|
||||
Remove(0, Size() );
|
||||
remove(0, size() );
|
||||
}
|
||||
/**
|
||||
* @brief Get a current element in the vector (iterator system)
|
||||
* @param[in] _realElementPosition Real position in the buffer (only use in the ITERATOR)
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
int8_t& GetDirect(int32_t _realElementPosition)
|
||||
int8_t& getDirect(int32_t _realElementPosition)
|
||||
{
|
||||
return m_data[_realElementPosition];
|
||||
};
|
||||
@ -429,16 +429,16 @@ namespace etk
|
||||
* @brief Get the number of element in the vector
|
||||
* @return The number requested
|
||||
*/
|
||||
int32_t Size(void) const
|
||||
int32_t size(void) const
|
||||
{
|
||||
return m_allocated - GapSize();
|
||||
return m_allocated - gapSize();
|
||||
};
|
||||
private:
|
||||
/**
|
||||
* @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)
|
||||
void changeAllocation(int32_t _newSize)
|
||||
{
|
||||
// set the minimal size to 1
|
||||
if(_newSize <= 0) {
|
||||
@ -468,11 +468,11 @@ namespace etk
|
||||
* @return false The operation can not be proccesed.
|
||||
* @return true The operation done correctly.
|
||||
*/
|
||||
bool GapMove(int32_t _pos)
|
||||
bool gapMove(int32_t _pos)
|
||||
{
|
||||
if( _pos > Size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << size());
|
||||
return false;
|
||||
}
|
||||
int32_t gapLen = m_gapEnd - m_gapStart;
|
||||
@ -492,21 +492,21 @@ namespace etk
|
||||
* @return false The operation can not be proccesed.
|
||||
* @return true The operation done correctly.
|
||||
*/
|
||||
bool GapResize(int32_t _pos, int32_t _newGapLen)
|
||||
bool gapResize(int32_t _pos, int32_t _newGapLen)
|
||||
{
|
||||
if( _pos > Size()
|
||||
if( _pos > size()
|
||||
|| _pos < 0 ) {
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<Size());
|
||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << size());
|
||||
return false;
|
||||
}
|
||||
int32_t previousSize = Size();
|
||||
if (_newGapLen == GapSize() ) {
|
||||
int32_t previousSize = size();
|
||||
if (_newGapLen == gapSize() ) {
|
||||
// nothing to do ...
|
||||
return true;
|
||||
} else {
|
||||
if (_newGapLen > GapSize() ) {
|
||||
if (_newGapLen > gapSize() ) {
|
||||
// reallocation
|
||||
ChangeAllocation( previousSize + _newGapLen);
|
||||
changeAllocation( previousSize + _newGapLen);
|
||||
}
|
||||
// move Data
|
||||
if (_pos <= m_gapStart) {
|
||||
@ -515,20 +515,20 @@ namespace etk
|
||||
// update gap end position
|
||||
m_gapEnd = m_gapStart + _newGapLen;
|
||||
if (_pos < m_gapStart) {
|
||||
if (false == GapMove(_pos)) {
|
||||
if (false == gapMove(_pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// no else
|
||||
} else {
|
||||
if (false == GapMove(_pos) ) {
|
||||
if (false == gapMove(_pos) ) {
|
||||
return false;
|
||||
}
|
||||
memmove(&m_data[m_gapStart + _newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
|
||||
}
|
||||
if (_newGapLen < GapSize() ) {
|
||||
if (_newGapLen < gapSize() ) {
|
||||
// rellocation
|
||||
ChangeAllocation(previousSize + _newGapLen);
|
||||
changeAllocation(previousSize + _newGapLen);
|
||||
}
|
||||
}
|
||||
// update gap position
|
||||
@ -540,23 +540,23 @@ namespace etk
|
||||
* @brief Get the current gap size.
|
||||
* @return The number of element in the gap
|
||||
*/
|
||||
int32_t GapSize(void) const
|
||||
int32_t gapSize(void) const
|
||||
{
|
||||
return m_gapEnd - m_gapStart;
|
||||
}
|
||||
/**
|
||||
* @brief Control if the writing gap is not too big (automatic resize the buffer).
|
||||
*/
|
||||
void GapCheckMaxSize(void)
|
||||
void gapCheckMaxSize(void)
|
||||
{
|
||||
if(GapSize() > GAP_SIZE_MAX) {
|
||||
int32_t currentSize = Size();
|
||||
if(gapSize() > GAP_SIZE_MAX) {
|
||||
int32_t currentSize = size();
|
||||
// Change the gap Size
|
||||
if (false == GapResize(m_gapStart, GAP_SIZE_MAX) ) {
|
||||
if (false == gapResize(m_gapStart, GAP_SIZE_MAX) ) {
|
||||
return;
|
||||
}
|
||||
// remove deprecated elements at the end of the buffer ...
|
||||
ChangeAllocation(currentSize + GAP_SIZE_MAX);
|
||||
changeAllocation(currentSize + GAP_SIZE_MAX);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
12
etk/Char.cpp
12
etk/Char.cpp
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
etk::Char::Char(void) {
|
||||
m_data.PushBack('\0');
|
||||
m_data.pushBack('\0');
|
||||
}
|
||||
|
||||
etk::Char::~Char(void)
|
||||
@ -29,21 +29,21 @@ etk::Char::operator void *()
|
||||
};
|
||||
|
||||
|
||||
void etk::Char::SetValue(const etk::Vector<char>& _data)
|
||||
void etk::Char::setValue(const etk::Vector<char>& _data)
|
||||
{
|
||||
m_data = _data;
|
||||
// check presence of '\0' (note : start by the end might be faster ...
|
||||
for (int32_t iii=m_data.Size()-1; iii>=0; iii--) {
|
||||
for (int32_t iii=m_data.size()-1; iii>=0; iii--) {
|
||||
if (m_data[iii] == '\0') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_data.PushBack('\0');
|
||||
m_data.pushBack('\0');
|
||||
}
|
||||
|
||||
|
||||
int64_t etk::Char::Size(void)
|
||||
int64_t etk::Char::size(void)
|
||||
{
|
||||
return m_data.Size()-1;
|
||||
return m_data.size()-1;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ namespace etk
|
||||
~Char(void);
|
||||
operator const char *();
|
||||
operator void *();
|
||||
void SetValue(const etk::Vector<char>& _data);
|
||||
int64_t Size(void);
|
||||
void setValue(const etk::Vector<char>& _data);
|
||||
int64_t size(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -40,12 +40,12 @@ typedef struct {
|
||||
etk::Color<> color;
|
||||
} colorList_ts;
|
||||
|
||||
static esize_t GetColorSize(void);
|
||||
static const colorList_ts* GetColorList(void);
|
||||
static esize_t getColorSize(void);
|
||||
static const colorList_ts* getColorList(void);
|
||||
|
||||
namespace etk
|
||||
{
|
||||
template<> void Color<uint8_t>::Set(float _r, float _g, float _b, float _a)
|
||||
template<> void Color<uint8_t>::set(float _r, float _g, float _b, float _a)
|
||||
{
|
||||
m_r = (uint8_t)(_r*255.0f);
|
||||
m_g = (uint8_t)(_g*255.0f);
|
||||
@ -53,7 +53,7 @@ namespace etk
|
||||
m_a = (uint8_t)(_a*255.0f);
|
||||
}
|
||||
|
||||
template<> void Color<float>::Set(float _r, float _g, float _b, float _a)
|
||||
template<> void Color<float>::set(float _r, float _g, float _b, float _a)
|
||||
{
|
||||
m_r = _r;
|
||||
m_g = _g;
|
||||
@ -61,7 +61,7 @@ namespace etk
|
||||
m_a = _a;
|
||||
}
|
||||
|
||||
template<> void Color<uint8_t>::Set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
|
||||
template<> void Color<uint8_t>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
|
||||
{
|
||||
m_r = _r;
|
||||
m_g = _g;
|
||||
@ -69,7 +69,7 @@ namespace etk
|
||||
m_a = _a;
|
||||
}
|
||||
|
||||
template<> void Color<float>::Set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
|
||||
template<> void Color<float>::set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
|
||||
{
|
||||
m_r = ((float)_r)/255.0f;
|
||||
m_g = ((float)_g)/255.0f;
|
||||
@ -77,7 +77,7 @@ namespace etk
|
||||
m_a = ((float)_a)/255.0f;
|
||||
}
|
||||
|
||||
template<> uint32_t Color<uint8_t>::Get(void) const
|
||||
template<> uint32_t Color<uint8_t>::get(void) const
|
||||
{
|
||||
return (((uint32_t)m_r)<<24)
|
||||
+ (((uint32_t)m_g)<<16)
|
||||
@ -85,9 +85,9 @@ namespace etk
|
||||
+ (uint32_t)m_a;
|
||||
}
|
||||
|
||||
template<> uint32_t Color<float>::Get(void) const
|
||||
template<> uint32_t Color<float>::get(void) const
|
||||
{
|
||||
return Color<uint8_t>(*this).Get();
|
||||
return Color<uint8_t>(*this).get();
|
||||
}
|
||||
|
||||
template<> Color<uint8_t>::Color(const etk::UString& _input) :
|
||||
@ -180,10 +180,10 @@ namespace etk
|
||||
} else {
|
||||
bool findIt = false;
|
||||
// direct named color ...
|
||||
for (esize_t iii=0; iii<GetColorSize(); iii++) {
|
||||
if (strnCmpNoCase(GetColorList()[iii].colorName, inputData, strlen(GetColorList()[iii].colorName)) == true) {
|
||||
for (esize_t iii=0; iii<getColorSize(); iii++) {
|
||||
if (strnCmpNoCase(getColorList()[iii].colorName, inputData, strlen(getColorList()[iii].colorName)) == true) {
|
||||
findIt = true;
|
||||
*this = GetColorList()[iii].color;
|
||||
*this = getColorList()[iii].color;
|
||||
// stop searching
|
||||
break;
|
||||
}
|
||||
@ -205,7 +205,7 @@ namespace etk
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<uint8_t>& _obj)
|
||||
{
|
||||
_os << _obj.GetString();
|
||||
_os << _obj.getString();
|
||||
return _os;
|
||||
}
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<float>& _obj)
|
||||
@ -526,12 +526,12 @@ static const colorList_ts listOfColor[] = {
|
||||
{ "YellowGreen", etk::color::yellowGreen}
|
||||
};
|
||||
|
||||
static const colorList_ts* GetColorList(void)
|
||||
static const colorList_ts* getColorList(void)
|
||||
{
|
||||
return listOfColor;
|
||||
}
|
||||
|
||||
static esize_t GetColorSize(void)
|
||||
static esize_t getColorSize(void)
|
||||
{
|
||||
static const esize_t tmpp = sizeof(listOfColor) / sizeof(colorList_ts);
|
||||
return tmpp;
|
||||
|
36
etk/Color.h
36
etk/Color.h
@ -21,19 +21,19 @@ namespace etk {
|
||||
MY_TYPE m_a;
|
||||
public :
|
||||
Color(void) { };
|
||||
Color(double _r, double _g, double _b, double _a=255) { Set((float)_r, (float)_g, (float)_b, (float)_a); };
|
||||
Color(float _r, float _g, float _b, float _a=255) { Set(_r, _g, _b, _a); };
|
||||
Color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255) { Set(_r, _g, _b, _a); };
|
||||
Color(int _r, int _g, int _b, int _a=255) { Set(_r, _g, _b, _a); };
|
||||
Color(double _r, double _g, double _b, double _a=255) { set((float)_r, (float)_g, (float)_b, (float)_a); };
|
||||
Color(float _r, float _g, float _b, float _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(int _r, int _g, int _b, int _a=255) { set(_r, _g, _b, _a); };
|
||||
Color(uint32_t _input)
|
||||
{
|
||||
Set((uint8_t)((_input&0xFF000000)>>24),
|
||||
set((uint8_t)((_input&0xFF000000)>>24),
|
||||
(uint8_t)((_input&0x00FF0000)>>16),
|
||||
(uint8_t)((_input&0x0000FF00)>>8),
|
||||
(uint8_t)((_input&0x000000FF)));
|
||||
};
|
||||
Color(const etk::Color<float>& _obj) { Set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
|
||||
Color(const etk::Color<uint8_t>& _obj) { Set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
|
||||
Color(const etk::Color<float>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
|
||||
Color(const etk::Color<uint8_t>& _obj) { set(_obj.r(), _obj.g(), _obj.b(), _obj.a()); };
|
||||
Color(const etk::UString& _input);
|
||||
~Color(void) { };
|
||||
Color<MY_TYPE>& operator=(const etk::Color<MY_TYPE>& _input)
|
||||
@ -64,26 +64,26 @@ namespace etk {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
uint32_t Get(void) const;
|
||||
void Set(float _r, float _g, float _b, float _a=255);
|
||||
void Set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255);
|
||||
void Set(int _r, int _g, int _b, int _a=255)
|
||||
uint32_t get(void) const;
|
||||
void set(float _r, float _g, float _b, float _a=255);
|
||||
void set(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a=255);
|
||||
void set(int _r, int _g, int _b, int _a=255)
|
||||
{
|
||||
Set((uint8_t)(etk_avg(0,_r,255)),
|
||||
set((uint8_t)(etk_avg(0,_r,255)),
|
||||
(uint8_t)(etk_avg(0,_g,255)),
|
||||
(uint8_t)(etk_avg(0,_b,255)),
|
||||
(uint8_t)(etk_avg(0,_a,255)) );
|
||||
}
|
||||
etk::UString GetHexString(void) const { return etk::UString(Get(), etk::UString::printModeHexadecimal, true); };
|
||||
etk::UString GetString(void) const { return etk::UString("#") + etk::UString(Get(), etk::UString::printModeHexadecimal); };
|
||||
etk::UString getHexString(void) const { return etk::UString(get(), etk::UString::printModeHexadecimal, true); };
|
||||
etk::UString getString(void) const { return etk::UString("#") + etk::UString(get(), etk::UString::printModeHexadecimal); };
|
||||
MY_TYPE r(void) const { return m_r; };
|
||||
MY_TYPE g(void) const { return m_g; };
|
||||
MY_TYPE b(void) const { return m_b; };
|
||||
MY_TYPE a(void) const { return m_a; };
|
||||
void SetR(MY_TYPE _r) { m_r=_r; };
|
||||
void SetG(MY_TYPE _g) { m_g=_g; };
|
||||
void SetB(MY_TYPE _b) { m_b=_b; };
|
||||
void SetA(MY_TYPE _a) { m_a=_a; };
|
||||
void setR(MY_TYPE _r) { m_r=_r; };
|
||||
void setG(MY_TYPE _g) { m_g=_g; };
|
||||
void setB(MY_TYPE _b) { m_b=_b; };
|
||||
void setA(MY_TYPE _a) { m_a=_a; };
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout &_os, const Color<uint8_t>& _obj);
|
||||
etk::CCout& operator <<(etk::CCout &_os, const Color<float>& _obj);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define FUNCTION_NAME_SIZE (70)
|
||||
|
||||
void TOOLS_DisplayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName)
|
||||
void debug::displayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName)
|
||||
{
|
||||
char tmpName[FUNCTION_NAME_SIZE] = "";
|
||||
|
||||
@ -39,7 +39,7 @@ void TOOLS_DisplayFuncName(int32_t _ligne, const char* _className, const char* _
|
||||
etk::cout << tmpName;
|
||||
}
|
||||
|
||||
void TOOLS_DisplayTime(void)
|
||||
void debug::displayTime(void)
|
||||
{
|
||||
char tmpdata[50];
|
||||
#ifdef __TARGET_OS__Android
|
||||
@ -62,7 +62,7 @@ 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) {
|
||||
void debug::setGeneralLevel(etk::logLevel_te _ccc) {
|
||||
g_requestedLevel = _ccc;
|
||||
}
|
||||
|
||||
|
87
etk/Debug.h
87
etk/Debug.h
@ -12,78 +12,79 @@
|
||||
#include <etk/types.h>
|
||||
#include <etk/Stream.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);
|
||||
|
||||
namespace debug {
|
||||
// Log Message System For EDN
|
||||
void displayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName);
|
||||
void displayTime(void);
|
||||
void setGeneralLevel(etk::logLevel_te _ccc);
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ (NULL)
|
||||
#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_DBG_COMMON(libName,info,data) do { \
|
||||
if (info <= g_requestedLevel) { \
|
||||
etk::cout << etk::cstart << info; \
|
||||
debug::displayTime(); \
|
||||
debug::displayFuncName(__LINE__, __class__, __func__, libName); \
|
||||
etk::cout << data; \
|
||||
etk::cout <<etk::endl; \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
|
||||
#define ETK_CRITICAL(libName, data) do { \
|
||||
ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data); \
|
||||
etk::DisplayBacktrace(); \
|
||||
}while(0)
|
||||
#define ETK_CRITICAL(libName,data) do { \
|
||||
ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data); \
|
||||
etk::displayBacktrace(); \
|
||||
}while(0)
|
||||
|
||||
#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)
|
||||
# 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)
|
||||
# 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)
|
||||
# define ETK_INFO(libName,data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_INFO, data)
|
||||
#else
|
||||
# define ETK_INFO(libName, data) do {}while(0)
|
||||
# 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)
|
||||
# define ETK_DEBUG(libName,data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_DEBUG, data)
|
||||
#else
|
||||
# define ETK_DEBUG(libName, data) do {}while(0)
|
||||
# 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)
|
||||
# define ETK_VERBOSE(libName,data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_VERBOSE, data)
|
||||
#else
|
||||
# define ETK_VERBOSE(libName, data) do {}while(0)
|
||||
# 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)
|
||||
#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)
|
||||
# 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)
|
||||
# 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)
|
||||
# define ETK_CHECK_INOUT(libName,cond) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define ETK_TODO(libName, data) ETK_INFO(libName, "TODO : " << data)
|
||||
#define ETK_TODO(libName,data) ETK_INFO(libName, "TODO : " << data)
|
||||
|
||||
#endif
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
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)
|
||||
#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
|
||||
|
||||
|
68
etk/Hach.h
68
etk/Hach.h
@ -15,7 +15,7 @@
|
||||
#include <etk/UString.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "etk::Hash"
|
||||
#define __class__ "etk::Hash"
|
||||
|
||||
|
||||
namespace etk
|
||||
@ -45,29 +45,29 @@ namespace etk
|
||||
}
|
||||
~Hash(void)
|
||||
{
|
||||
Clear();
|
||||
clear();
|
||||
}
|
||||
/**
|
||||
* @brief Remove all entry in the Hash table
|
||||
*/
|
||||
void Clear(void)
|
||||
void clear(void)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for (int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
if (m_data[iii] != NULL) {
|
||||
delete(m_data[iii]);
|
||||
m_data[iii]=NULL;
|
||||
}
|
||||
}
|
||||
m_data.Clear();
|
||||
m_data.clear();
|
||||
}
|
||||
/**
|
||||
* @brief Get a current element ID in the Hash table
|
||||
* @param[in] _key Name of the hash requested
|
||||
* @return Id of the element in the table or -1 of it does not existed
|
||||
*/
|
||||
int64_t GetId(const etk::UString& _key) const
|
||||
int64_t getId(const etk::UString& _key) const
|
||||
{
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for (int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
if (m_data[iii] != NULL) {
|
||||
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
|
||||
if (m_data[iii]->m_key == _key) {
|
||||
@ -83,9 +83,9 @@ namespace etk
|
||||
* @param[in] _key Name of the hash requested
|
||||
* @return true if the element exist
|
||||
*/
|
||||
bool Exist(const etk::UString& _name) const
|
||||
bool exist(const etk::UString& _name) const
|
||||
{
|
||||
int64_t elementId = GetId(_name);
|
||||
int64_t elementId = getId(_name);
|
||||
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
|
||||
if (elementId<0) {
|
||||
//TK_INFO(" ==> return false" );
|
||||
@ -99,10 +99,10 @@ namespace etk
|
||||
* @param[in] _key Name of the hash requested
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
MY_TYPE& Get(const etk::UString& _key) const
|
||||
MY_TYPE& get(const etk::UString& _key) const
|
||||
{
|
||||
static MY_TYPE g_error;
|
||||
int64_t elementId = GetId(_key);
|
||||
int64_t elementId = getId(_key);
|
||||
if (elementId<0) {
|
||||
TK_ERROR("try to acces at an unexistant hash element : " << _key);
|
||||
return g_error;
|
||||
@ -116,84 +116,84 @@ namespace etk
|
||||
*/
|
||||
MY_TYPE& operator[] (const etk::UString& _key)
|
||||
{
|
||||
return Get(_key);
|
||||
return get(_key);
|
||||
}
|
||||
const MY_TYPE& operator[] (const etk::UString& _key) const
|
||||
{
|
||||
return Get(_key);
|
||||
return get(_key);
|
||||
}
|
||||
|
||||
void Add(const etk::UString& _key, const MY_TYPE& _value)
|
||||
void add(const etk::UString& _key, const MY_TYPE& _value)
|
||||
{
|
||||
int64_t elementId = GetId(_key);
|
||||
int64_t elementId = getId(_key);
|
||||
if (elementId <0) {
|
||||
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
|
||||
if (NULL == tmp) {
|
||||
TK_ERROR("allocation error in Hash table : '" << _key << "'");
|
||||
return;
|
||||
}
|
||||
m_data.PushBack(tmp);
|
||||
m_data.pushBack(tmp);
|
||||
return;
|
||||
}
|
||||
m_data[elementId]->m_value = _value;
|
||||
}
|
||||
void Set(const etk::UString& _key, const MY_TYPE& _value)
|
||||
void set(const etk::UString& _key, const MY_TYPE& _value)
|
||||
{
|
||||
Add(_key, _value);
|
||||
add(_key, _value);
|
||||
}
|
||||
void Remove(const etk::UString& _key)
|
||||
void remove(const etk::UString& _key)
|
||||
{
|
||||
int64_t elementId = GetId(_key);
|
||||
int64_t elementId = getId(_key);
|
||||
if (elementId <0) {
|
||||
//nothing to do ==> not existed
|
||||
return;
|
||||
}
|
||||
delete(m_data[elementId]);
|
||||
m_data[elementId] = NULL;
|
||||
m_data.Remove(elementId);
|
||||
m_data.remove(elementId);
|
||||
}
|
||||
/**
|
||||
* @brief Get the number of element in the hash table
|
||||
* @return number of elements
|
||||
*/
|
||||
esize_t Size(void) const
|
||||
esize_t size(void) const
|
||||
{
|
||||
return m_data.Size();
|
||||
return m_data.size();
|
||||
}
|
||||
MY_TYPE& operator[] (esize_t _pos)
|
||||
{
|
||||
return GetValue(_pos);
|
||||
return getValue(_pos);
|
||||
}
|
||||
const MY_TYPE& operator[] (esize_t _pos) const
|
||||
{
|
||||
return GetValue(_pos);
|
||||
return getValue(_pos);
|
||||
}
|
||||
const etk::UString& GetKey(esize_t _pos) const
|
||||
const etk::UString& getKey(esize_t _pos) const
|
||||
{
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
if(_pos>m_data.Size()){
|
||||
TK_CRITICAL("[CRITICAL] Access to an unexistant data in hach : " << _pos << "/ " << m_data.Size());
|
||||
if(_pos>m_data.size()){
|
||||
TK_CRITICAL("Access to an unexistant data in hach : " << _pos << "/ " << m_data.size());
|
||||
}
|
||||
#endif
|
||||
return m_data[_pos]->m_key;
|
||||
}
|
||||
const MY_TYPE& GetValue(esize_t _pos) const
|
||||
const MY_TYPE& getValue(esize_t _pos) const
|
||||
{
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
if(_pos>m_data.Size()){
|
||||
TK_CRITICAL("[CRITICAL] Access to an unexistant data in hach : " << _pos << "/ " << m_data.Size());
|
||||
if(_pos>m_data.size()){
|
||||
TK_CRITICAL("Access to an unexistant data in hach : " << _pos << "/ " << m_data.size());
|
||||
}
|
||||
#endif
|
||||
return m_data[_pos]->m_value;
|
||||
}
|
||||
MY_TYPE& GetValue(esize_t _pos)
|
||||
MY_TYPE& getValue(esize_t _pos)
|
||||
{
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
if(_pos>m_data.Size()){
|
||||
TK_CRITICAL("[CRITICAL] Access to an unexistant data in hach : " << _pos << "/ " << m_data.Size());
|
||||
if(_pos>m_data.size()){
|
||||
TK_CRITICAL("Access to an unexistant data in hach : " << _pos << "/ " << m_data.size());
|
||||
}
|
||||
#endif
|
||||
return m_data[_pos]->m_value;
|
||||
|
@ -18,8 +18,8 @@ namespace etk
|
||||
template<class MY_TYPE=int32_t> class MessageFifo
|
||||
{
|
||||
private :
|
||||
etk::Mutex m_mutex;
|
||||
etk::Semaphore m_semaphore;
|
||||
etk::Mutex m_mutex;
|
||||
etk::Semaphore m_semaphore;
|
||||
etk::Vector<MY_TYPE> m_data;
|
||||
public :
|
||||
MessageFifo(void)
|
||||
@ -31,72 +31,72 @@ namespace etk
|
||||
// nothing to do ...
|
||||
};
|
||||
|
||||
bool Wait(MY_TYPE &_data)
|
||||
bool wait(MY_TYPE &_data)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.Size()) {
|
||||
m_mutex.UnLock();
|
||||
m_semaphore.Wait();
|
||||
m_mutex.Lock();
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
m_semaphore.wait();
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.Size()) {
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.Erase(0);
|
||||
m_data.erase(0);
|
||||
// remove lock
|
||||
m_mutex.UnLock();
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
bool Wait(MY_TYPE &_data, uint32_t _timeOutInUs)
|
||||
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_mutex.lock();
|
||||
// Check if data is not previously here
|
||||
while(0==m_data.Size()) {
|
||||
m_mutex.UnLock();
|
||||
if (false == m_semaphore.Wait(_timeOutInUs)) {
|
||||
while(0==m_data.size()) {
|
||||
m_mutex.unLock();
|
||||
if (false == m_semaphore.wait(_timeOutInUs)) {
|
||||
return false;
|
||||
}
|
||||
m_mutex.Lock();
|
||||
m_mutex.lock();
|
||||
}
|
||||
// End Waiting message :
|
||||
if (0<m_data.Size()) {
|
||||
if (0<m_data.size()) {
|
||||
// copy element :
|
||||
_data = m_data[0];
|
||||
// remove element :
|
||||
m_data.Erase(0);
|
||||
m_data.erase(0);
|
||||
// remove lock
|
||||
m_mutex.UnLock();
|
||||
m_mutex.unLock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
int32_t Count(void)
|
||||
int32_t count(void)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
int32_t nbElement = m_data.Size();
|
||||
m_mutex.UnLock();
|
||||
m_mutex.lock();
|
||||
int32_t nbElement = m_data.size();
|
||||
m_mutex.unLock();
|
||||
return nbElement;
|
||||
};
|
||||
void Post(MY_TYPE &_data)
|
||||
void post(MY_TYPE &_data)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_data.PushBack(_data);
|
||||
m_semaphore.Post();
|
||||
m_mutex.UnLock();
|
||||
m_mutex.lock();
|
||||
m_data.pushBack(_data);
|
||||
m_semaphore.post();
|
||||
m_mutex.unLock();
|
||||
};
|
||||
void Clean(void)
|
||||
void clean(void)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_mutex.lock();
|
||||
// remove data
|
||||
m_data.Clear();
|
||||
m_mutex.UnLock();
|
||||
m_data.clear();
|
||||
m_mutex.unLock();
|
||||
// remove semaphore
|
||||
m_semaphore.Wait(0);
|
||||
m_semaphore.wait(0);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ etk::BaseNoise::BaseNoise(ivec2 _size, float _min, float _max) :
|
||||
m_data(_size.x()*_size.y()),
|
||||
m_size(_size)
|
||||
{
|
||||
m_data.ReSize(_size.x()*_size.y(), 0);
|
||||
m_data.reSize(_size.x()*_size.y(), 0);
|
||||
|
||||
for(int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
|
||||
m_data[iii] = etk::tool::frand(_min, _max);
|
||||
@ -33,7 +33,7 @@ etk::BaseNoise::~BaseNoise(void)
|
||||
|
||||
}
|
||||
|
||||
float etk::BaseNoise::Get(int32_t _x, int32_t _y) const
|
||||
float etk::BaseNoise::get(int32_t _x, int32_t _y) const
|
||||
{
|
||||
// We increment of the size to prevent the <0 result due to the "%" methode ...
|
||||
_x += m_size.x();
|
||||
@ -59,10 +59,10 @@ float etk::Noise::smoothNoise(float _x, float _y, const etk::BaseNoise& _noise)
|
||||
|
||||
//smooth the noise with bilinear interpolation
|
||||
float value = 0.0f;
|
||||
value += fractX * fractY * _noise.Get(x1,y1);
|
||||
value += fractX * (1 - fractY) * _noise.Get(x1,y2);
|
||||
value += (1 - fractX) * fractY * _noise.Get(x2,y1);
|
||||
value += (1 - fractX) * (1 - fractY) * _noise.Get(x2,y2);
|
||||
value += fractX * fractY * _noise.get(x1,y1);
|
||||
value += fractX * (1 - fractY) * _noise.get(x1,y2);
|
||||
value += (1 - fractX) * fractY * _noise.get(x2,y1);
|
||||
value += (1 - fractX) * (1 - fractY) * _noise.get(x2,y2);
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -85,7 +85,7 @@ float etk::Noise::turbulenceNoSmooth(float _x, float _y, float _size, const etk:
|
||||
float value = 0.0f;
|
||||
float initialSize = _size;
|
||||
while(1<=_size) {
|
||||
value += _noise.Get(_x / _size, _y / _size) * _size;
|
||||
value += _noise.get(_x / _size, _y / _size) * _size;
|
||||
_size *= 0.5f;
|
||||
}
|
||||
return(0.5f * value / initialSize);
|
||||
@ -98,7 +98,7 @@ etk::Noise::Noise(noise_te _type, ivec2 _size, int32_t _depth) :
|
||||
m_size(_size),
|
||||
m_type(_type)
|
||||
{
|
||||
m_data.ReSize(_size.x()*_size.y(), 0);
|
||||
m_data.reSize(_size.x()*_size.y(), 0);
|
||||
switch(m_type) {
|
||||
default:
|
||||
case etk::Noise::NOISE_BASE:
|
||||
@ -106,7 +106,7 @@ etk::Noise::Noise(noise_te _type, ivec2 _size, int32_t _depth) :
|
||||
etk::BaseNoise myNoise(ivec2(m_size.x()/_depth,m_size.y()/_depth),0.0f,1.0f);
|
||||
for(int32_t iii=0; iii<m_size.y(); iii++) {
|
||||
for(int32_t jjj=0; jjj<m_size.x(); jjj++) {
|
||||
m_data[iii+jjj*m_size.x()] = myNoise.Get(iii,jjj);
|
||||
m_data[iii+jjj*m_size.x()] = myNoise.get(iii,jjj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,7 @@ etk::Noise::~Noise(void)
|
||||
|
||||
}
|
||||
|
||||
float etk::Noise::Get(int32_t _x, int32_t _y) const
|
||||
float etk::Noise::get(int32_t _x, int32_t _y) const
|
||||
{
|
||||
// We increment of the size to prevent the <0 result due to the "%" methode ...
|
||||
_x += m_size.x();
|
||||
|
@ -22,7 +22,7 @@ namespace etk {
|
||||
public:
|
||||
BaseNoise(ivec2 _size, float _min, float _max);
|
||||
~BaseNoise(void);
|
||||
float Get(int32_t _x, int32_t _y) const;
|
||||
float get(int32_t _x, int32_t _y) const;
|
||||
};
|
||||
class Noise
|
||||
{
|
||||
@ -46,7 +46,7 @@ namespace etk {
|
||||
public:
|
||||
Noise(noise_te _type, ivec2 _size, int32_t _depth);
|
||||
~Noise(void);
|
||||
float Get(int32_t _x, int32_t _y) const;
|
||||
float get(int32_t _x, int32_t _y) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -64,11 +64,11 @@ const etk::convertionTable_ts etk::constConvertionTable[] = {
|
||||
};
|
||||
const esize_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ;
|
||||
|
||||
void etk::DisplayElem(const etk::Vector<etk::UniChar>& _data, esize_t _start, esize_t _stop)
|
||||
void etk::displayElem(const etk::Vector<etk::UniChar>& _data, esize_t _start, esize_t _stop)
|
||||
{
|
||||
etk::cout<< ETK_BASH_COLOR_NORMAL;
|
||||
for (esize_t iii=_start; iii<_data.Size() && iii<_stop ; iii++) {
|
||||
switch(_data[iii].Get())
|
||||
for (esize_t iii=_start; iii<_data.size() && iii<_stop ; iii++) {
|
||||
switch(_data[iii].get())
|
||||
{
|
||||
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;
|
||||
@ -125,9 +125,9 @@ char * etk::levelSpace(uint32_t _level)
|
||||
}
|
||||
|
||||
|
||||
esize_t etk::GetLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
esize_t etk::getLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
{
|
||||
if (_startPos>=_data.Size()){
|
||||
if (_startPos>=_data.size()){
|
||||
return 0;
|
||||
}
|
||||
esize_t pos = _startPos;
|
||||
@ -138,7 +138,7 @@ esize_t etk::GetLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t
|
||||
return 0;
|
||||
}
|
||||
// find size ...
|
||||
while (pos < _data.Size() ) {
|
||||
while (pos < _data.size() ) {
|
||||
if(_data[pos] == REGEXP_OPCODE_PTHESE_IN) {
|
||||
// find a sub section :
|
||||
nbOpen++;
|
||||
@ -166,7 +166,7 @@ esize_t etk::GetLenOfPTheseElem(const etk::Vector<etk::UniChar>& _data, esize_t
|
||||
return pos - _startPos;
|
||||
}
|
||||
|
||||
esize_t etk::GetLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
esize_t etk::getLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
{
|
||||
esize_t pos = _startPos;
|
||||
int32_t nbOpen = 0;
|
||||
@ -180,7 +180,7 @@ esize_t etk::GetLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _sta
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < _data.Size() ) {
|
||||
while (pos < _data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) {
|
||||
// find a sub section :
|
||||
nbOpen++;
|
||||
@ -208,7 +208,7 @@ esize_t etk::GetLenOfPThese(const etk::Vector<etk::UniChar>& _data, esize_t _sta
|
||||
}
|
||||
|
||||
|
||||
esize_t etk::GetLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
esize_t etk::getLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
{
|
||||
esize_t pos = _startPos;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
@ -221,7 +221,7 @@ esize_t etk::GetLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _st
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < _data.Size() ) {
|
||||
while (pos < _data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) {
|
||||
// Find the end of the [...]
|
||||
// just return the size inside
|
||||
@ -233,7 +233,7 @@ esize_t etk::GetLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _st
|
||||
return sizeInside;
|
||||
} else if( _data[pos] != REGEXP_OPCODE_TO
|
||||
&& _data[pos] > 0xFF ) {
|
||||
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos].Get() << "'");
|
||||
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos].get() << "'");
|
||||
return 0;
|
||||
}
|
||||
pos++;
|
||||
@ -242,7 +242,7 @@ esize_t etk::GetLenOfBracket(const etk::Vector<etk::UniChar>& _data, esize_t _st
|
||||
}
|
||||
|
||||
|
||||
esize_t etk::GetLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
esize_t etk::getLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
{
|
||||
int32_t pos = _startPos;
|
||||
// special case of the (...) or | ==> we search '|' or ')'
|
||||
@ -255,7 +255,7 @@ esize_t etk::GetLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _star
|
||||
}
|
||||
pos++;
|
||||
// find size ...
|
||||
while (pos < _data.Size() ) {
|
||||
while (pos < _data.size() ) {
|
||||
if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) {
|
||||
// Find the end of the [...]
|
||||
// just return the size inside
|
||||
@ -268,7 +268,7 @@ esize_t etk::GetLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _star
|
||||
} else if( _data[pos] != ','
|
||||
&& ( _data[pos] < '0'
|
||||
|| _data[pos] > '9') ) {
|
||||
TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos].Get() << "'");
|
||||
TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos].get() << "'");
|
||||
return 0;
|
||||
}
|
||||
pos++;
|
||||
@ -277,13 +277,13 @@ esize_t etk::GetLenOfBrace(const etk::Vector<etk::UniChar>& _data, esize_t _star
|
||||
}
|
||||
|
||||
|
||||
esize_t etk::GetLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
esize_t etk::getLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _startPos)
|
||||
{
|
||||
esize_t pos = _startPos;
|
||||
|
||||
// find size ...
|
||||
while (pos < _data.Size() ) {
|
||||
switch(_data[pos].Get())
|
||||
while (pos < _data.size() ) {
|
||||
switch(_data[pos].get())
|
||||
{
|
||||
case REGEXP_OPCODE_PTHESE_IN:
|
||||
case REGEXP_OPCODE_PTHESE_OUT:
|
||||
@ -329,7 +329,7 @@ esize_t etk::GetLenOfNormal(const etk::Vector<etk::UniChar>& _data, esize_t _sta
|
||||
}
|
||||
|
||||
|
||||
bool etk::ParseBrace(const etk::Vector<etk::UniChar>& _data, uint32_t& _min, uint32_t& _max)
|
||||
bool etk::parseBrace(const etk::Vector<etk::UniChar>& _data, uint32_t& _min, uint32_t& _max)
|
||||
{
|
||||
//TK_INFO("parse {...} in "; DisplayElem(data); );
|
||||
esize_t k=0;
|
||||
@ -337,34 +337,34 @@ bool etk::ParseBrace(const etk::Vector<etk::UniChar>& _data, uint32_t& _min, uin
|
||||
int32_t firstElement = 0;
|
||||
int32_t SecondElement = 0;
|
||||
|
||||
while(k<_data.Size()) {
|
||||
while(k<_data.size()) {
|
||||
if (_data[k]==',') {
|
||||
k++;
|
||||
break;
|
||||
} if (_data[k]=='}') {
|
||||
SecondElement = firstElement;
|
||||
goto allIsSet;
|
||||
} else if(true==_data[k].IsInteger()) {
|
||||
} else if(true==_data[k].isInteger()) {
|
||||
firstElement *=10;
|
||||
firstElement += _data[k].ToInt32();
|
||||
firstElement += _data[k].toInt32();
|
||||
} else {
|
||||
TK_ERROR("Can not parse this element " << (char)_data[k].Get() << " at pos " << k);
|
||||
TK_ERROR("Can not parse this element " << (char)_data[k].get() << " at pos " << k);
|
||||
return false;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
if (k==_data.Size()) {
|
||||
if (k==_data.size()) {
|
||||
SecondElement = firstElement;
|
||||
}
|
||||
while(k<_data.Size()) {
|
||||
while(k<_data.size()) {
|
||||
if (_data[k]==',') {
|
||||
TK_ERROR("Can not find a second , in {} at pos " << k);
|
||||
return false;
|
||||
} if (_data[k]=='}') {
|
||||
goto allIsSet;
|
||||
} else if (true==_data[k].IsInteger()) {
|
||||
} else if (true==_data[k].isInteger()) {
|
||||
SecondElement *=10;
|
||||
SecondElement += _data[k].ToInt32();
|
||||
SecondElement += _data[k].toInt32();
|
||||
} else {
|
||||
TK_ERROR("Can not parse this element " << _data[k] << " at pos " << k);
|
||||
return false;
|
||||
|
424
etk/RegExp.h
424
etk/RegExp.h
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
#include <cxxabi.h>
|
||||
#include <dlfcn.h>
|
||||
#define MAX_DEPTH (256)
|
||||
void etk::DisplayBacktrace(void)
|
||||
void etk::displayBacktrace(void)
|
||||
{
|
||||
// retrieve call-stack
|
||||
void * trace[MAX_DEPTH];
|
||||
@ -42,7 +42,7 @@
|
||||
assert(false);
|
||||
}
|
||||
#else
|
||||
void etk::DisplayBacktrace(void)
|
||||
void etk::displayBacktrace(void)
|
||||
{
|
||||
#if DEBUG_LEVEL > 2
|
||||
assert(false);
|
||||
@ -152,7 +152,7 @@ etk::CCout::~CCout()
|
||||
etk::CCout& etk::CCout::operator << (const etk::UniChar& _t)
|
||||
{
|
||||
char output[5];
|
||||
_t.GetUtf8(output);
|
||||
_t.getUtf8(output);
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
@ -270,7 +270,7 @@ etk::CCout& etk::CCout::operator << (bool _t)
|
||||
|
||||
etk::CCout& etk::CCout::operator << (CStart _ccc)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_mutex.lock();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ etk::CCout& etk::CCout::operator << (etk::CEndl _t)
|
||||
printf("%s", m_tmpChar);
|
||||
#endif
|
||||
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
|
||||
m_mutex.UnLock();
|
||||
m_mutex.unLock();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace etk
|
||||
*/
|
||||
etk::CCout& operator <<(etk::CCout &_os, const etk::logLevel_te _obj);
|
||||
|
||||
void DisplayBacktrace(void);
|
||||
void displayBacktrace(void);
|
||||
};
|
||||
|
||||
//regular colors
|
||||
|
494
etk/UString.cpp
494
etk/UString.cpp
File diff suppressed because it is too large
Load Diff
@ -43,14 +43,14 @@ namespace etk
|
||||
UString(const char* _data, unicode::charset_te _inputCharset);
|
||||
UString(const float _inputData);
|
||||
UString(const double _inputData);
|
||||
UString(const int8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set(_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { Set(_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((int64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set(_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set((uint64_t)_inputData, _mode, _preset, _leadingZero); };
|
||||
UString(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0) { set(_inputData, _mode, _preset, _leadingZero); };
|
||||
// multiple element add
|
||||
UString(const etk::UniChar* _inputData, int32_t _len = -1);
|
||||
UString(const char* _inputData, int32_t _len = -1);
|
||||
@ -58,16 +58,16 @@ namespace etk
|
||||
UString(const etk::Vector<int8_t>& _inputData);
|
||||
UString(const etk::Vector<etk::UniChar>& _inputData);
|
||||
// generic setter
|
||||
void Set(const etk::UniChar* _inputData, int32_t _len=-1);
|
||||
void Set(const char* _inputData, int32_t _len=-1);
|
||||
void Set(const etk::Vector<char>& _inputData);
|
||||
void Set(const etk::Vector<int8_t>& _inputData);
|
||||
void Set(const etk::Vector<etk::UniChar>& _inputData);
|
||||
void set(const etk::UniChar* _inputData, int32_t _len=-1);
|
||||
void set(const char* _inputData, int32_t _len=-1);
|
||||
void set(const etk::Vector<char>& _inputData);
|
||||
void set(const etk::Vector<int8_t>& _inputData);
|
||||
void set(const etk::Vector<etk::UniChar>& _inputData);
|
||||
private:
|
||||
void SetNumber(bool _negative, const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset, int32_t _leadingZero);
|
||||
void setNumber(bool _negative, const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset, int32_t _leadingZero);
|
||||
public:
|
||||
void Set(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0);
|
||||
void Set(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0);
|
||||
void set(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0);
|
||||
void set(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false, int32_t _leadingZero=0);
|
||||
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
@ -77,7 +77,7 @@ namespace etk
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const etk::UString& _obj) const;
|
||||
bool CompareNoCase(const etk::UString& _obj) const;
|
||||
bool compareNoCase(const etk::UString& _obj) const;
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
@ -128,48 +128,48 @@ namespace etk
|
||||
* toolbox
|
||||
*****************************************************/
|
||||
// Start With ...
|
||||
bool StartWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
bool startWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
// End With ...
|
||||
bool EndWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
bool endWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
// Find element
|
||||
int32_t FindForward(const etk::UniChar _data, int32_t _startPos=0) const;
|
||||
int32_t FindBack(const etk::UniChar _data, int32_t _startPos=0x7FFFFFFF) const;
|
||||
int32_t findForward(const etk::UniChar _data, int32_t _startPos=0) const;
|
||||
int32_t findBack(const etk::UniChar _data, int32_t _startPos=0x7FFFFFFF) const;
|
||||
|
||||
bool IsEmpty(void) const;
|
||||
int32_t Size(void) 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 etk::UniChar* _inputData);
|
||||
void Add(int32_t _currentID, const etk::UniChar _inputData);
|
||||
void Remove(int32_t _currentID, int32_t _len);
|
||||
void Clear(void);
|
||||
void Append(const etk::UniChar& _inputData);
|
||||
void add(int32_t _currentID, const char* _inputData);
|
||||
void add(int32_t _currentID, const etk::UniChar* _inputData);
|
||||
void add(int32_t _currentID, const etk::UniChar _inputData);
|
||||
void remove(int32_t _currentID, int32_t _len);
|
||||
void clear(void);
|
||||
void append(const etk::UniChar& _inputData);
|
||||
|
||||
/**
|
||||
* @brief Split a string in multiple separate by a specific char
|
||||
* @param[in] _val Separate value of the string
|
||||
* @return The list of all sthe string splited.
|
||||
*/
|
||||
etk::Vector<etk::UString> Split(const etk::UniChar& _val);
|
||||
etk::Vector<etk::UString> split(const etk::UniChar& _val);
|
||||
/**
|
||||
* @brief Replace a char with an other
|
||||
* @param[in] _out element to replace.
|
||||
* @param[in] _in Element to set.
|
||||
*/
|
||||
void Replace(const etk::UniChar& _out, const etk::UniChar& _in);
|
||||
void replace(const etk::UniChar& _out, const etk::UniChar& _in);
|
||||
|
||||
etk::Vector<etk::UniChar> GetVector(void);
|
||||
etk::Vector<etk::UniChar> getVector(void);
|
||||
etk::UniChar* pointer(void) { return &m_data[0]; };
|
||||
|
||||
etk::Char c_str(void) const;
|
||||
|
||||
void Lower(void);
|
||||
etk::UString ToLower(void) const;
|
||||
void Upper(void);
|
||||
etk::UString ToUpper(void) const;
|
||||
void lower(void);
|
||||
etk::UString toLower(void) const;
|
||||
void upper(void);
|
||||
etk::UString toUpper(void) const;
|
||||
|
||||
/**
|
||||
* @brief transform tab in \t and '\r' in \r
|
||||
@ -178,63 +178,63 @@ namespace etk
|
||||
//etk::UString WrapHidenChar(void) const;
|
||||
|
||||
// Sting operation :
|
||||
etk::UString Extract(int32_t _posStart=0, int32_t _posEnd=0x7FFFFFFF) const;
|
||||
etk::UString ExtractLine(int32_t _pos=0) const;
|
||||
etk::UString extract(int32_t _posStart=0, int32_t _posEnd=0x7FFFFFFF) const;
|
||||
etk::UString extractLine(int32_t _pos=0) const;
|
||||
/**
|
||||
* @brief Transform the current string in an int64_t
|
||||
* @return the requested int
|
||||
*/
|
||||
int64_t ToInt64(void) const;
|
||||
int64_t toInt64(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an int32_t (if the number is higher, then it is limited at the int32_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
int32_t ToInt32(void) const;
|
||||
int32_t toInt32(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an int16_t (if the number is higher, then it is limited at the int16_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
int16_t ToInt16(void) const;
|
||||
int16_t toInt16(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an int8_t (if the number is higher, then it is limited at the int8_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
int8_t ToInt8(void) const;
|
||||
int8_t toInt8(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an uint64_t
|
||||
* @return the requested int
|
||||
*/
|
||||
uint64_t ToUInt64(void) const;
|
||||
uint64_t toUInt64(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an uint32_t (if the number is higher, then it is limited at the uint32_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
uint32_t ToUInt32(void) const;
|
||||
uint32_t toUInt32(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an uint16_t (if the number is higher, then it is limited at the uint16_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
uint16_t ToUInt16(void) const;
|
||||
uint16_t toUInt16(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in an uint8_t (if the number is higher, then it is limited at the uint8_t max)
|
||||
* @return the requested int
|
||||
*/
|
||||
uint8_t ToUInt8(void) const;
|
||||
uint8_t toUInt8(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in a double
|
||||
* @return the requested double
|
||||
*/
|
||||
double ToDouble(void) const;
|
||||
double toDouble(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in a float
|
||||
* @return the requested float
|
||||
*/
|
||||
float ToFloat(void) const;
|
||||
float toFloat(void) const;
|
||||
/**
|
||||
* @brief Transform the current string in a boolean
|
||||
* @return the requested bool
|
||||
*/
|
||||
bool ToBool(void) const;
|
||||
bool toBool(void) const;
|
||||
};
|
||||
|
||||
etk::CCout& operator <<(etk::CCout& _os, const etk::UString& _obj);
|
||||
|
@ -24,7 +24,7 @@ const etk::UniChar etk::UniChar::Delete((const char)8);
|
||||
const etk::UniChar etk::UniChar::Space(' ');
|
||||
const etk::UniChar etk::UniChar::Escape((const char)27);
|
||||
|
||||
void etk::UniChar::Lower(void)
|
||||
void etk::UniChar::lower(void)
|
||||
{
|
||||
if( m_value>=(uint32_t)'A'
|
||||
&& m_value<=(uint32_t)'Z') {
|
||||
@ -32,7 +32,7 @@ void etk::UniChar::Lower(void)
|
||||
}
|
||||
}
|
||||
|
||||
etk::UniChar etk::UniChar::ToLower(void) const
|
||||
etk::UniChar etk::UniChar::toLower(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'A'
|
||||
&& m_value<=(uint32_t)'Z') {
|
||||
@ -41,7 +41,7 @@ etk::UniChar etk::UniChar::ToLower(void) const
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void etk::UniChar::Upper(void)
|
||||
void etk::UniChar::upper(void)
|
||||
{
|
||||
if( m_value>=(uint32_t)'a'
|
||||
&& m_value<=(uint32_t)'z') {
|
||||
@ -49,7 +49,7 @@ void etk::UniChar::Upper(void)
|
||||
}
|
||||
}
|
||||
|
||||
etk::UniChar etk::UniChar::ToUpper(void) const
|
||||
etk::UniChar etk::UniChar::toUpper(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'a'
|
||||
&& m_value<=(uint32_t)'z') {
|
||||
@ -60,13 +60,13 @@ etk::UniChar etk::UniChar::ToUpper(void) const
|
||||
|
||||
|
||||
|
||||
bool etk::UniChar::CompareNoCase(const etk::UniChar& _obj) const
|
||||
bool etk::UniChar::compareNoCase(const etk::UniChar& _obj) const
|
||||
{
|
||||
return ToUpper() == _obj.ToUpper();
|
||||
return toUpper() == _obj.toUpper();
|
||||
}
|
||||
|
||||
|
||||
etk::UniChar etk::UniChar::ChangeOrder(void) const
|
||||
etk::UniChar etk::UniChar::changeOrder(void) const
|
||||
{
|
||||
if (m_value >= 'A' && m_value <= 'Z') {
|
||||
return (m_value - (uint32_t)'A')*2 + 'A';
|
||||
@ -84,7 +84,7 @@ etk::UniChar etk::UniChar::ChangeOrder(void) const
|
||||
}
|
||||
|
||||
|
||||
bool etk::UniChar::IsWhiteChar(void) const
|
||||
bool etk::UniChar::isWhiteChar(void) const
|
||||
{
|
||||
if( m_value == ' '
|
||||
|| m_value == '\t'
|
||||
@ -95,7 +95,7 @@ bool etk::UniChar::IsWhiteChar(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::UniChar::IsInteger(void) const
|
||||
bool etk::UniChar::isInteger(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'0'
|
||||
&& m_value<=(uint32_t)'9') {
|
||||
@ -104,7 +104,7 @@ bool etk::UniChar::IsInteger(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t etk::UniChar::ToInt32(void) const
|
||||
int32_t etk::UniChar::toInt32(void) const
|
||||
{
|
||||
return m_value - (uint32_t)'0';
|
||||
}
|
||||
@ -119,7 +119,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UniChar& _obj)
|
||||
*/
|
||||
|
||||
|
||||
uint32_t etk::UniChar::GetUtf8(void) const
|
||||
uint32_t etk::UniChar::getUtf8(void) const
|
||||
{
|
||||
uint32_t output = 0;
|
||||
if (m_value <= 127) {
|
||||
@ -153,9 +153,9 @@ uint32_t etk::UniChar::GetUtf8(void) const
|
||||
return output;
|
||||
}
|
||||
|
||||
int8_t etk::UniChar::GetUtf8(char _output[5]) const
|
||||
int8_t etk::UniChar::getUtf8(char _output[5]) const
|
||||
{
|
||||
uint32_t value = GetUtf8();
|
||||
uint32_t value = getUtf8();
|
||||
if (0xFF >= value) {
|
||||
_output[0] = (char)value;
|
||||
_output[1] = '\0';
|
||||
@ -203,7 +203,7 @@ etk::Vector<int8_t> etk::UniChar::GetUtf8(void) const
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
uint8_t SizeElement(const char* _data, int32_t _lenMax)
|
||||
uint8_t sizeElement(const char* _data, int32_t _lenMax)
|
||||
{
|
||||
uint8_t size = 0;
|
||||
TK_ASSERT(0 <= _lenMax, "size can not be < 0 ...");
|
||||
@ -235,14 +235,14 @@ uint8_t SizeElement(const char* _data, int32_t _lenMax)
|
||||
}
|
||||
|
||||
|
||||
int8_t etk::UniChar::SetUtf8(const char* _input)
|
||||
int8_t etk::UniChar::setUtf8(const char* _input)
|
||||
{
|
||||
m_value = 0;
|
||||
if (NULL == _input) {
|
||||
return 0;
|
||||
}
|
||||
int32_t len = strlen(_input);
|
||||
len = SizeElement(_input, len);
|
||||
len = sizeElement(_input, len);
|
||||
switch (len) {
|
||||
default:
|
||||
// case 0 : An error occured...
|
||||
@ -269,7 +269,7 @@ int8_t etk::UniChar::SetUtf8(const char* _input)
|
||||
}
|
||||
}
|
||||
|
||||
int8_t etk::UniChar::TheoricUTF8Len(const char _input)
|
||||
int8_t etk::UniChar::theoricUTF8Len(const char _input)
|
||||
{
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
return 1;
|
||||
@ -286,7 +286,7 @@ int8_t etk::UniChar::TheoricUTF8Len(const char _input)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool etk::UniChar::TheoricUTF8First(const char _input)
|
||||
bool etk::UniChar::theoricUTF8First(const char _input)
|
||||
{
|
||||
// When started with the bit 0 then the size is signle element.
|
||||
if((_input&0x80) == 0x00 ) {
|
||||
|
@ -83,7 +83,7 @@ namespace etk
|
||||
{
|
||||
return m_value == _obj.m_value;
|
||||
};
|
||||
bool CompareNoCase(const etk::UniChar& _obj) const;
|
||||
bool compareNoCase(const etk::UniChar& _obj) const;
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
@ -156,41 +156,41 @@ namespace etk
|
||||
* @brief check if the curent element is white or not : '\t' '\n' '\r' ' '
|
||||
* @return tue if it is white char
|
||||
*/
|
||||
bool IsWhiteChar(void) const;
|
||||
bool isWhiteChar(void) const;
|
||||
/**
|
||||
* @brief check if the curent element is number or not
|
||||
* @return tue if it is a number char
|
||||
*/
|
||||
bool IsInteger(void) const;
|
||||
int32_t ToInt32(void) const;
|
||||
bool isInteger(void) const;
|
||||
int32_t toInt32(void) const;
|
||||
|
||||
void Lower(void);
|
||||
UniChar ToLower(void) const;
|
||||
void Upper(void);
|
||||
UniChar ToUpper(void) const;
|
||||
void lower(void);
|
||||
UniChar toLower(void) const;
|
||||
void upper(void);
|
||||
UniChar toUpper(void) const;
|
||||
|
||||
UniChar ChangeOrder(void) const;
|
||||
UniChar changeOrder(void) const;
|
||||
|
||||
uint32_t Get(void) const { return m_value; };
|
||||
void Set(uint32_t _val) { m_value = _val; };
|
||||
uint32_t get(void) const { return m_value; };
|
||||
void set(uint32_t _val) { m_value = _val; };
|
||||
|
||||
uint32_t GetUtf8(void) const;
|
||||
int8_t GetUtf8(char _output[5]) const;
|
||||
uint32_t getUtf8(void) const;
|
||||
int8_t getUtf8(char _output[5]) const;
|
||||
//etk::Vector<int8_t> GetUtf8(void) const;
|
||||
int8_t SetUtf8(const char* _input);
|
||||
int8_t setUtf8(const char* _input);
|
||||
public:
|
||||
/**
|
||||
* @brief Get the size of an utf8 char with his first char.
|
||||
* @param[in] _input Char to parse
|
||||
* @return number of char needed
|
||||
*/
|
||||
static int8_t TheoricUTF8Len(const char _input);
|
||||
static int8_t theoricUTF8Len(const char _input);
|
||||
/**
|
||||
* @brief When parsing a string in a reverse mode, we need to know if we get the first char
|
||||
* @param[in] _input Char to parse.
|
||||
* @return true if it was the first char.
|
||||
*/
|
||||
static bool TheoricUTF8First(const char _input);
|
||||
static bool theoricUTF8First(const char _input);
|
||||
};
|
||||
};
|
||||
|
||||
|
100
etk/Vector.h
100
etk/Vector.h
@ -192,7 +192,7 @@ namespace etk
|
||||
m_size(0),
|
||||
m_allocated(0)
|
||||
{
|
||||
ChangeAllocation(_count);
|
||||
changeAllocation(_count);
|
||||
}
|
||||
/**
|
||||
* @brief Re-copy constructor (copy all needed data)
|
||||
@ -232,7 +232,7 @@ namespace etk
|
||||
* @brief Swap the data of 2 Vectors
|
||||
* @param[in] _obj second vector to swap data.
|
||||
*/
|
||||
void Swap(etk::Vector<MY_TYPE>& _obj)
|
||||
void wwap(etk::Vector<MY_TYPE>& _obj)
|
||||
{
|
||||
// avoid Swap of itself
|
||||
if(this != &_obj) {
|
||||
@ -285,9 +285,9 @@ namespace etk
|
||||
*/
|
||||
Vector& operator+= (const etk::Vector<MY_TYPE> & _obj)
|
||||
{
|
||||
esize_t nbElememt = _obj.Size();
|
||||
esize_t nbElememt = _obj.size();
|
||||
esize_t idx = m_size;
|
||||
Resize(m_size+nbElememt);
|
||||
resize(m_size+nbElememt);
|
||||
if (m_size<=idx) {
|
||||
TK_CRITICAL("allocation error");
|
||||
return *this;
|
||||
@ -303,7 +303,7 @@ namespace etk
|
||||
* @brief Get the number of element in the vector
|
||||
* @return The number requested
|
||||
*/
|
||||
esize_t Size(void) const
|
||||
esize_t size(void) const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
@ -311,10 +311,10 @@ namespace etk
|
||||
* @brief Get the number of element in the vector
|
||||
* @return The number requested
|
||||
*/
|
||||
void ReSize(esize_t _newSize, const MY_TYPE& _basicElement)
|
||||
void reSize(esize_t _newSize, const MY_TYPE& _basicElement)
|
||||
{
|
||||
esize_t idx = m_size;
|
||||
Resize(_newSize);
|
||||
resize(_newSize);
|
||||
if (m_size != _newSize) {
|
||||
TK_CRITICAL("error to resize vector");
|
||||
return;
|
||||
@ -330,7 +330,7 @@ namespace etk
|
||||
* @brief Get the Allocated size in the vector
|
||||
* @return The size of allocation
|
||||
*/
|
||||
esize_t AllocatedSize(void) const
|
||||
esize_t allocatedSize(void) const
|
||||
{
|
||||
return m_allocated;
|
||||
}
|
||||
@ -339,7 +339,7 @@ namespace etk
|
||||
* @param[in] _pos Desired position read
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
MY_TYPE& Get(esize_t _pos)
|
||||
MY_TYPE& get(esize_t _pos)
|
||||
{
|
||||
// NOTE :Do not change log level, this generate error only in debug mode
|
||||
#if DEBUG_LEVEL > 2
|
||||
@ -356,7 +356,7 @@ namespace etk
|
||||
*/
|
||||
MY_TYPE& operator[] (esize_t _pos)
|
||||
{
|
||||
return Get(_pos);
|
||||
return get(_pos);
|
||||
}
|
||||
/**
|
||||
* @brief Get an Element an a special position
|
||||
@ -377,27 +377,27 @@ namespace etk
|
||||
* @brief Add at the First position of the Vector
|
||||
* @param[in] _item Element to add at the end of vector
|
||||
*/
|
||||
void PushFront(const MY_TYPE& _item)
|
||||
void pushFront(const MY_TYPE& _item)
|
||||
{
|
||||
Insert(0, &_item, 1);
|
||||
insert(0, &_item, 1);
|
||||
}
|
||||
/**
|
||||
* @brief Add at the Last position of the Vector
|
||||
* @param[in] _item Pointer on a list of Element to add at the start of vector
|
||||
* @param[in] _nbElement Number of element to add.
|
||||
*/
|
||||
void PushFront(const MY_TYPE * _item, esize_t _nbElement)
|
||||
void pushFront(const MY_TYPE * _item, esize_t _nbElement)
|
||||
{
|
||||
Insert(0, _item, _nbElement);
|
||||
insert(0, _item, _nbElement);
|
||||
}
|
||||
/**
|
||||
* @brief Add at the Last position of the Vector
|
||||
* @param[in] _item Element to add at the end of vector
|
||||
*/
|
||||
void PushBack(const MY_TYPE& _item)
|
||||
void pushBack(const MY_TYPE& _item)
|
||||
{
|
||||
esize_t idx = m_size;
|
||||
Resize(m_size+1);
|
||||
resize(m_size+1);
|
||||
if (idx < m_size) {
|
||||
m_data[idx] = _item;
|
||||
} else {
|
||||
@ -409,13 +409,13 @@ namespace etk
|
||||
* @param[in] _item Pointer on a list of Element to add at the end of vector
|
||||
* @param[in] _nbElement Number of element to add.
|
||||
*/
|
||||
void PushBack(const MY_TYPE * _item, esize_t _nbElement)
|
||||
void pushBack(const MY_TYPE * _item, esize_t _nbElement)
|
||||
{
|
||||
if (NULL == _item) {
|
||||
return;
|
||||
}
|
||||
esize_t idx = m_size;
|
||||
Resize(m_size+_nbElement);
|
||||
resize(m_size+_nbElement);
|
||||
if (idx > m_size) {
|
||||
TK_ERROR("Resize does not work corectly ... not added item");
|
||||
return;
|
||||
@ -427,19 +427,19 @@ namespace etk
|
||||
/**
|
||||
* @brief Remove the last element of the vector
|
||||
*/
|
||||
void PopBack(void)
|
||||
void popBack(void)
|
||||
{
|
||||
if(m_size>0) {
|
||||
Resize(m_size-1);
|
||||
resize(m_size-1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Remove all alement in the current vector
|
||||
*/
|
||||
void Clear(void)
|
||||
void clear(void)
|
||||
{
|
||||
if(m_size>0) {
|
||||
Resize(0);
|
||||
resize(0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -448,16 +448,16 @@ namespace etk
|
||||
* @param[in] _item Pointer on a table of the elements to add.
|
||||
* @param[in] _nbElement Number of element to add in the Vector
|
||||
*/
|
||||
void Insert(esize_t _pos, const MY_TYPE * _item, esize_t _nbElement)
|
||||
void insert(esize_t _pos, const MY_TYPE * _item, esize_t _nbElement)
|
||||
{
|
||||
if (_pos>m_size) {
|
||||
TK_WARNING(" can not insert Element at this position : " << _pos << " > " << m_size << " add it at the end ... ");
|
||||
PushBack(_item, _nbElement);
|
||||
pushBack(_item, _nbElement);
|
||||
return;
|
||||
}
|
||||
esize_t idx = m_size;
|
||||
// Request resize of the current buffer
|
||||
Resize(m_size+_nbElement);
|
||||
resize(m_size+_nbElement);
|
||||
if (idx>=m_size) {
|
||||
TK_ERROR("Resize does not work corectly ... not added item");
|
||||
return;
|
||||
@ -479,16 +479,16 @@ namespace etk
|
||||
* @param[in] _pos Position to add the elements.
|
||||
* @param[in] _item Element to add.
|
||||
*/
|
||||
void Insert(esize_t _pos, const MY_TYPE& _item)
|
||||
void insert(esize_t _pos, const MY_TYPE& _item)
|
||||
{
|
||||
Insert(_pos, &_item, 1);
|
||||
insert(_pos, &_item, 1);
|
||||
}
|
||||
/**
|
||||
* @brief Remove N element
|
||||
* @param[in] _pos Position to remove the data
|
||||
* @param[in] _nbElement number of element to remove
|
||||
*/
|
||||
void EraseLen(esize_t _pos, esize_t _nbElement)
|
||||
void eraseLen(esize_t _pos, esize_t _nbElement)
|
||||
{
|
||||
if (_pos>m_size) {
|
||||
TK_ERROR(" can not Erase Len Element at this position : " << _pos << " > " << m_size);
|
||||
@ -506,30 +506,30 @@ namespace etk
|
||||
}
|
||||
}
|
||||
// Request resize of the current buffer
|
||||
Resize(m_size-_nbElement);
|
||||
resize(m_size-_nbElement);
|
||||
}
|
||||
/**
|
||||
* @brief Remove one element
|
||||
* @param[in] _pos Position to remove the data
|
||||
*/
|
||||
inline void Erase(esize_t _pos)
|
||||
inline void erase(esize_t _pos)
|
||||
{
|
||||
EraseLen(_pos, 1);
|
||||
eraseLen(_pos, 1);
|
||||
}
|
||||
/**
|
||||
* @brief Remove one element
|
||||
* @param[in] _pos Position to remove the data
|
||||
*/
|
||||
inline void Remove(esize_t _pos)
|
||||
inline void remove(esize_t _pos)
|
||||
{
|
||||
EraseLen(_pos, 1);
|
||||
eraseLen(_pos, 1);
|
||||
}
|
||||
/**
|
||||
* @brief Remove N elements
|
||||
* @param[in] _pos Position to remove the data
|
||||
* @param[in] _posEnd Last position number
|
||||
*/
|
||||
void Erase(esize_t _pos, esize_t _posEnd)
|
||||
void erase(esize_t _pos, esize_t _posEnd)
|
||||
{
|
||||
if (_pos>m_size) {
|
||||
TK_ERROR(" can not Erase Element at this position : " << _pos << " > " << m_size);
|
||||
@ -548,7 +548,7 @@ namespace etk
|
||||
}
|
||||
}
|
||||
// Request resize of the current buffer
|
||||
Resize(m_size-nbElement);
|
||||
resize(m_size-nbElement);
|
||||
}
|
||||
/**
|
||||
* @brief extract data between two point :
|
||||
@ -556,23 +556,23 @@ namespace etk
|
||||
* @param[in] _posEnd End position to extract data
|
||||
* @return the extracted vector
|
||||
*/
|
||||
Vector<MY_TYPE> Extract(esize_t _posStart = 0, esize_t _posEnd=0x7FFFFFFF) const
|
||||
Vector<MY_TYPE> extract(esize_t _posStart = 0, esize_t _posEnd=0x7FFFFFFF) const
|
||||
{
|
||||
Vector<MY_TYPE> out;
|
||||
if (_posStart >= Size() ) {
|
||||
if (_posStart >= size() ) {
|
||||
return out;
|
||||
}
|
||||
if (_posEnd >= Size() ) {
|
||||
_posEnd = Size();
|
||||
if (_posEnd >= size() ) {
|
||||
_posEnd = size();
|
||||
}
|
||||
out.PushBack(&m_data[_posStart], _posEnd-_posStart);
|
||||
out.pushBack(&m_data[_posStart], _posEnd-_posStart);
|
||||
return out;
|
||||
}
|
||||
/**
|
||||
* @brief Get the pointer on the sata
|
||||
* @return the type pointer on data
|
||||
*/
|
||||
MY_TYPE* DataPointer(void)
|
||||
MY_TYPE* dataPointer(void)
|
||||
{
|
||||
return &m_data[0];
|
||||
}
|
||||
@ -581,36 +581,36 @@ namespace etk
|
||||
* @param[in] _pos Requested position of the iterator in the vector
|
||||
* @return The Iterator
|
||||
*/
|
||||
Iterator Position(esize_t _pos)
|
||||
Iterator position(esize_t _pos)
|
||||
{
|
||||
return Iterator(this, _pos);
|
||||
return iterator(this, _pos);
|
||||
}
|
||||
/**
|
||||
* @brief Get an Iterator on the start position of the Vector
|
||||
* @return The Iterator
|
||||
*/
|
||||
Iterator Begin(void)
|
||||
Iterator begin(void)
|
||||
{
|
||||
return Position(0);
|
||||
return position(0);
|
||||
}
|
||||
/**
|
||||
* @brief Get an Iterator on the end position of the Vector
|
||||
* @return The Iterator
|
||||
*/
|
||||
Iterator End(void)
|
||||
Iterator end(void)
|
||||
{
|
||||
return Position( Size()-1 );
|
||||
return position( size()-1 );
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief Change the current size of the vector
|
||||
* @param[in] _newSize New requested size of element in the vector
|
||||
*/
|
||||
void Resize(esize_t _newSize)
|
||||
void resize(esize_t _newSize)
|
||||
{
|
||||
// Reallocate memory
|
||||
if (_newSize > m_allocated) {
|
||||
ChangeAllocation(_newSize);
|
||||
changeAllocation(_newSize);
|
||||
}
|
||||
m_size = _newSize;
|
||||
}
|
||||
@ -618,7 +618,7 @@ namespace etk
|
||||
* @brief Change the current allocation to the corect one (depend on the current size)
|
||||
* @param[in] _newSize Minimum number of element needed
|
||||
*/
|
||||
void ChangeAllocation(esize_t _newSize)
|
||||
void changeAllocation(esize_t _newSize)
|
||||
{
|
||||
// set the minimal size to 1
|
||||
if(_newSize == 0) {
|
||||
|
@ -10,32 +10,32 @@
|
||||
#include <etk/archive/Zip.h>
|
||||
#include <etk/DebugInternal.h>
|
||||
|
||||
const etk::Archive::Content& etk::Archive::GetContent(const etk::UString& _key) const
|
||||
const etk::Archive::Content& etk::Archive::getContent(const etk::UString& _key) const
|
||||
{
|
||||
static const etk::Archive::Content g_error;
|
||||
if (m_content.Exist(_key)==false) {
|
||||
if (m_content.exist(_key)==false) {
|
||||
TK_ERROR("File does not exist : " << _key);
|
||||
return g_error;
|
||||
}
|
||||
return m_content[_key];
|
||||
}
|
||||
|
||||
void etk::Archive::Display(void)
|
||||
void etk::Archive::display(void)
|
||||
{
|
||||
for (esize_t iii=0; iii<m_content.Size(); iii++) {
|
||||
esize_t size = m_content.GetValue(iii).GetTheoricSize();
|
||||
esize_t sizeR = m_content.GetValue(iii).Size();
|
||||
TK_INFO(" element : " << m_content.GetKey(iii) << " size=" << size << " allocated=" << sizeR);
|
||||
for (esize_t iii=0; iii<m_content.size(); iii++) {
|
||||
esize_t size = m_content.getValue(iii).getTheoricSize();
|
||||
esize_t sizeR = m_content.getValue(iii).size();
|
||||
TK_INFO(" element : " << m_content.getKey(iii) << " size=" << size << " allocated=" << sizeR);
|
||||
}
|
||||
}
|
||||
|
||||
etk::Archive* etk::Archive::Load(const etk::UString& _fileName)
|
||||
etk::Archive* etk::Archive::load(const etk::UString& _fileName)
|
||||
{
|
||||
etk::Archive* output=NULL;
|
||||
etk::UString tmpName = _fileName.ToLower();
|
||||
etk::UString tmpName = _fileName.toLower();
|
||||
// select the corect Loader :
|
||||
if( true == tmpName.EndWith(".zip")
|
||||
|| true == tmpName.EndWith(".apk") ) {
|
||||
if( true == tmpName.endWith(".zip")
|
||||
|| true == tmpName.endWith(".apk") ) {
|
||||
output = new etk::archive::Zip(_fileName);
|
||||
if (NULL==output) {
|
||||
TK_ERROR("An error occured when load archive : " << _fileName);
|
||||
@ -47,28 +47,28 @@ etk::Archive* etk::Archive::Load(const etk::UString& _fileName)
|
||||
}
|
||||
|
||||
|
||||
void etk::Archive::Open(const etk::UString& _key)
|
||||
void etk::Archive::open(const etk::UString& _key)
|
||||
{
|
||||
if (m_content.Exist(_key)==false) {
|
||||
if (m_content.exist(_key)==false) {
|
||||
TK_ERROR("Try open an unexistant file : '" << _key << "'");
|
||||
return;
|
||||
}
|
||||
if (m_content[_key].GetNumberOfRef()==-1) {
|
||||
LoadFile(m_content.GetId(_key));
|
||||
m_content[_key].IncreaseRef();
|
||||
if (m_content[_key].getNumberOfRef()==-1) {
|
||||
loadFile(m_content.getId(_key));
|
||||
m_content[_key].increaseRef();
|
||||
}
|
||||
m_content[_key].IncreaseRef();
|
||||
m_content[_key].increaseRef();
|
||||
}
|
||||
|
||||
void etk::Archive::Close(const etk::UString& _key)
|
||||
void etk::Archive::close(const etk::UString& _key)
|
||||
{
|
||||
if (m_content.Exist(_key)==false) {
|
||||
if (m_content.exist(_key)==false) {
|
||||
TK_ERROR("Try close an unexistant file : '" << _key << "'");
|
||||
return;
|
||||
}
|
||||
if (m_content[_key].GetNumberOfRef()==0){
|
||||
if (m_content[_key].getNumberOfRef()==0){
|
||||
TK_ERROR("Try close one more time the file : '" << _key << "'");
|
||||
} else {
|
||||
m_content[_key].DecreaseRef();
|
||||
m_content[_key].decreaseRef();
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,20 @@ namespace etk
|
||||
private:
|
||||
int32_t m_link; //!< number of element open on this file
|
||||
public:
|
||||
void IncreaseRef(void) { m_link++; };
|
||||
void DecreaseRef(void) { m_link--; };
|
||||
int32_t GetNumberOfRef(void) const { return m_link; };
|
||||
void increaseRef(void) { m_link++; };
|
||||
void decreaseRef(void) { m_link--; };
|
||||
int32_t getNumberOfRef(void) const { return m_link; };
|
||||
private:
|
||||
esize_t m_theoricSize; //!< number of element open on this file
|
||||
public:
|
||||
esize_t GetTheoricSize(void) const { return m_theoricSize; };
|
||||
esize_t getTheoricSize(void) const { return m_theoricSize; };
|
||||
private:
|
||||
etk::Vector<char> m_data;
|
||||
public:
|
||||
Content(esize_t _basicSize=0) : m_link(-1), m_theoricSize(_basicSize) { };
|
||||
esize_t Size(void) const { return m_data.Size(); };
|
||||
void* Data(void) const { return (void*)&m_data[0]; };
|
||||
etk::Vector<char>& GetDataVector(void) { return m_data; };
|
||||
esize_t size(void) const { return m_data.size(); };
|
||||
void* data(void) const { return (void*)&m_data[0]; };
|
||||
etk::Vector<char>& getDataVector(void) { return m_data; };
|
||||
};
|
||||
public:
|
||||
Archive(const etk::UString& _fileName) : m_fileName(_fileName) { };
|
||||
@ -48,7 +48,7 @@ namespace etk
|
||||
* @brief Get the current file name.
|
||||
* @return the requested file name.
|
||||
*/
|
||||
const etk::UString& GetFileName(void) { return m_fileName; };
|
||||
const etk::UString& getFileName(void) { return m_fileName; };
|
||||
protected:
|
||||
etk::Hash<Content> m_content;
|
||||
public:
|
||||
@ -56,65 +56,65 @@ namespace etk
|
||||
* @brief Get the number of elements
|
||||
* @return nb files in the archive
|
||||
*/
|
||||
esize_t Size(void) const { return m_content.Size(); };
|
||||
esize_t size(void) const { return m_content.size(); };
|
||||
/**
|
||||
* @brief Get the File name of the ID
|
||||
* @param[in] _id id of the element (must be < Size())
|
||||
* @return FileName of the requested id
|
||||
*/
|
||||
const etk::UString& GetName(esize_t _id) const { return m_content.GetKey(_id); };
|
||||
const etk::UString& getName(esize_t _id) const { return m_content.getKey(_id); };
|
||||
/**
|
||||
* @brief Get the File name of the ID
|
||||
* @param[in] _id id of the element (must be < Size())
|
||||
* @return the archive content
|
||||
*/
|
||||
const Content& GetContent(esize_t _id) const { return m_content.GetValue(_id); };
|
||||
const Content& getContent(esize_t _id) const { return m_content.getValue(_id); };
|
||||
/**
|
||||
* @brief Get the File name of the ID
|
||||
* @param[in] _key name of the file
|
||||
* @return FileName of the requested id
|
||||
*/
|
||||
const Content& GetContent(const etk::UString& _key) const;
|
||||
const Content& getContent(const etk::UString& _key) const;
|
||||
/**
|
||||
* @brief Check if a file exist
|
||||
* @param[in] _key Name of the file
|
||||
* @return true if the file is present
|
||||
*/
|
||||
bool Exist(const etk::UString& _key) const { return m_content.Exist(_key); };
|
||||
bool exist(const etk::UString& _key) const { return m_content.exist(_key); };
|
||||
/**
|
||||
* @brief Load the specific file in the memory
|
||||
* @param[in] _key Name of the file
|
||||
*/
|
||||
void Open(const etk::UString& _key);
|
||||
void open(const etk::UString& _key);
|
||||
/**
|
||||
* @brief Un-Load the specific file from the memory
|
||||
* @param[in] _key Name of the file
|
||||
*/
|
||||
void Close(const etk::UString& _key);
|
||||
void close(const etk::UString& _key);
|
||||
/**
|
||||
* @brief Display all Element in the archive
|
||||
*/
|
||||
void Display(void);
|
||||
void display(void);
|
||||
protected:
|
||||
/**
|
||||
* @brief Request the load in memory of the concerned file.
|
||||
* @param[in] _id Id of the file to load.
|
||||
*/
|
||||
virtual void LoadFile(int32_t _id) { };
|
||||
virtual void loadFile(int32_t _id) { };
|
||||
public:
|
||||
/**
|
||||
* @brief Load an Achive with a specific name.
|
||||
* @param[in] _fileName File name of the specific archive.
|
||||
* @return A pointer an the specified archive, the user might delete it.
|
||||
*/
|
||||
static Archive* Load(const etk::UString& _fileName);
|
||||
static Archive* load(const etk::UString& _fileName);
|
||||
|
||||
/**
|
||||
* @brief Create an Achive with a specific name.
|
||||
* @param[in] _fileName File name of the specific archive.
|
||||
* @return A pointer an the specified archive. it is empty due to the fact of create a new archive file.
|
||||
*/
|
||||
//Archive* Create(const etk::UString& _fileName);
|
||||
//Archive* create(const etk::UString& _fileName);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
@ -37,7 +37,7 @@ etk::archive::Zip::Zip(const etk::UString& _fileName) :
|
||||
if(tmpFileName[strlen(tmpFileName) - 1] == '/' ) {
|
||||
// find directory ...
|
||||
} else {
|
||||
m_content.Add(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size));
|
||||
m_content.add(tmpFileName, etk::Archive::Content(tmpFileInfo.uncompressed_size));
|
||||
}
|
||||
/* Go the the next entry listed in the zip file. */
|
||||
if((iii+1) < m_info.number_entry) {
|
||||
@ -57,9 +57,9 @@ etk::archive::Zip::~Zip(void)
|
||||
};
|
||||
};
|
||||
|
||||
void etk::archive::Zip::LoadFile(int32_t _id)
|
||||
void etk::archive::Zip::loadFile(int32_t _id)
|
||||
{
|
||||
etk::UString fileNameRequested = m_content.GetKey(_id);
|
||||
etk::UString fileNameRequested = m_content.getKey(_id);
|
||||
TK_VERBOSE("Real load file : " << _id << " = '" << fileNameRequested << "'");
|
||||
|
||||
unzGoToFirstFile(m_ctx);
|
||||
@ -81,15 +81,15 @@ void etk::archive::Zip::LoadFile(int32_t _id)
|
||||
}
|
||||
int error = UNZ_OK;
|
||||
// request the resize of the data :
|
||||
m_content.GetValue(_id).GetDataVector().ReSize(m_content.GetValue(_id).GetTheoricSize(), 0);
|
||||
void* data = m_content.GetValue(_id).Data();
|
||||
m_content.getValue(_id).getDataVector().reSize(m_content.getValue(_id).getTheoricSize(), 0);
|
||||
void* data = m_content.getValue(_id).data();
|
||||
if(NULL == data) {
|
||||
TK_ERROR("Allocation error...");
|
||||
return;
|
||||
}
|
||||
/* read the file */
|
||||
do {
|
||||
error = unzReadCurrentFile(m_ctx, data, m_content.GetValue(_id).GetTheoricSize());
|
||||
error = unzReadCurrentFile(m_ctx, data, m_content.getValue(_id).getTheoricSize());
|
||||
if ( error < 0 ) {
|
||||
TK_ERROR("Could not read file '" << tmpFileName << "' into the zip file '" << m_fileName << "': " << error);
|
||||
unzCloseCurrentFile(m_ctx);
|
||||
|
@ -27,7 +27,7 @@ namespace etk
|
||||
Zip(const etk::UString& _fileName);
|
||||
virtual ~Zip(void);
|
||||
protected: // herited functions :
|
||||
virtual void LoadFile(int32_t _id);
|
||||
virtual void loadFile(int32_t _id);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ namespace etk
|
||||
const Matrix<T>& operator= (T& value)
|
||||
{
|
||||
// set data :
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for (int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
m_data = value;
|
||||
}
|
||||
return *this;
|
||||
@ -150,7 +150,7 @@ namespace etk
|
||||
m_data = tmpMatrix.m_data;
|
||||
} else {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_data.Size(); iii++) {
|
||||
for (int32_t iii=0; iii< m_data.size(); iii++) {
|
||||
m_data[iii] += obj.m_data[iii];
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ namespace etk
|
||||
m_data = tmpMatrix.m_data;
|
||||
} else {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_data.Size(); iii++) {
|
||||
for (int32_t iii=0; iii< m_data.size(); iii++) {
|
||||
m_data[iii] -= obj.m_data[iii];
|
||||
}
|
||||
}
|
||||
@ -268,7 +268,7 @@ namespace etk
|
||||
* @ brief Transpose Matrix
|
||||
* @ return the transpose matrix
|
||||
*/
|
||||
Matrix<T> Transpose(void)
|
||||
Matrix<T> transpose(void)
|
||||
{
|
||||
// create a matrix with the inverted size
|
||||
Matrix<T> tmpMatrix(m_size.x, m_size.y);
|
||||
@ -284,7 +284,7 @@ namespace etk
|
||||
* @ param[in] obj The convolution operator
|
||||
* @ return the value of the convolution
|
||||
*/
|
||||
Matrix<T>& Convolution(Matrix<T>& obj)
|
||||
Matrix<T>& convolution(Matrix<T>& obj)
|
||||
{
|
||||
Matrix<T> tmppp(1,1);
|
||||
// TODO : ...
|
||||
@ -295,11 +295,11 @@ namespace etk
|
||||
* @ param[in] decalage The power of 2 of the division
|
||||
* @ return the result
|
||||
*/
|
||||
Matrix<T>& Fix(int32_t decalage)
|
||||
Matrix<T>& fix(int32_t decalage)
|
||||
{
|
||||
Matrix<T> tmppp(m_size);
|
||||
T tmpVal = 0;
|
||||
for(int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
tmpVal = m_data[iii];
|
||||
if (tmpVal < 0 && (tmpVal & ~(~0 << decalage))) {
|
||||
tmpVal = tmpVal >> decalage;
|
||||
@ -316,10 +316,10 @@ namespace etk
|
||||
* @ param[in] decalage The power of 2 of the division
|
||||
* @ return the result
|
||||
*/
|
||||
Matrix<T>& Round(int32_t decalage)
|
||||
Matrix<T>& round(int32_t decalage)
|
||||
{
|
||||
Matrix<T> tmppp(m_size);
|
||||
for(int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
tmppp.m_data[iii] = ( m_data[iii]+(1<<(decalage-1)) ) >> decalage;
|
||||
}
|
||||
return tmppp;
|
||||
@ -329,7 +329,7 @@ namespace etk
|
||||
* @ param[in] size new output size
|
||||
* @ return Te resied matrix
|
||||
*/
|
||||
Matrix<T>& Resize(etk::Vector2D<int32_t> size)
|
||||
Matrix<T>& resize(etk::Vector2D<int32_t> size)
|
||||
{
|
||||
Matrix<T> tmppp(size);
|
||||
for(int32_t iii=0; iii<m_data.m_size.x && iii<tmppp.m_size.x; iii++) {
|
||||
@ -347,7 +347,7 @@ namespace etk
|
||||
* @param[in] q List pointer of y
|
||||
* @return the new matrix
|
||||
*/
|
||||
Matrix<T>& Select(int32_t np, int32_t *p, int32_t nq, int32_t *q)
|
||||
Matrix<T>& select(int32_t np, int32_t *p, int32_t nq, int32_t *q)
|
||||
{
|
||||
if (np < 1 || nq < 1) {
|
||||
TK_WARNING("bad index array sizes");
|
||||
@ -379,7 +379,7 @@ namespace etk
|
||||
* x x x x x
|
||||
* </pre>
|
||||
*/
|
||||
void ClearUpperTriangle(void)
|
||||
void clearUpperTriangle(void)
|
||||
{
|
||||
if (m_size.x != m_size.y) {
|
||||
TK_WARNING("better to do with square Matrix");
|
||||
@ -400,7 +400,7 @@ namespace etk
|
||||
* 0 0 0 0 x
|
||||
* </pre>
|
||||
*/
|
||||
void ClearLowerTriangle(void)
|
||||
void clearLowerTriangle(void)
|
||||
{
|
||||
if (m_size.x != m_size.y) {
|
||||
TK_WARNING("better to do with square Matrix");
|
||||
@ -415,9 +415,9 @@ namespace etk
|
||||
* @brief Generate a compleate random Matrix.
|
||||
* @param[in] range The min/max value of the random Generation [-range..range].
|
||||
*/
|
||||
void MakeRandom(float range)
|
||||
void makeRandom(float range)
|
||||
{
|
||||
for(int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
m_data[iii] = (T)etk::tool::frand(-range, range);
|
||||
}
|
||||
};
|
||||
@ -426,13 +426,13 @@ namespace etk
|
||||
* @param[in] input The compared Matix.
|
||||
* @return The absolute max value.
|
||||
*/
|
||||
T MaxDifference(const Matrix<T>& input)
|
||||
T maxDifference(const Matrix<T>& input)
|
||||
{
|
||||
if (m_size != input.m_size)
|
||||
TK_WARNING("better to do with same size Matrix");
|
||||
}
|
||||
T max = 0;
|
||||
for(int32_t iii=0; iii<m_data.Size() && iii<input.m_data.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<m_data.size() && iii<input.m_data.size(); iii++) {
|
||||
T diff = m_data[iii] - input.m_data[iii];
|
||||
if (diff<0) {
|
||||
diff = -diff;
|
||||
@ -446,7 +446,7 @@ namespace etk
|
||||
/**
|
||||
* @brief Clear all the matrix.
|
||||
*/
|
||||
void Clear(void)
|
||||
void clear(void)
|
||||
{
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_size.x*m_size.y; iii++) {
|
||||
@ -456,7 +456,7 @@ namespace etk
|
||||
/**
|
||||
* @brief Set the diagonal at 1
|
||||
*/
|
||||
void Identity(void)
|
||||
void identity(void)
|
||||
{
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< etk_min(m_size.x, m_size.y); iii++) {
|
||||
@ -466,16 +466,16 @@ namespace etk
|
||||
/**
|
||||
* @brief Clear and set the diagonal at 1
|
||||
*/
|
||||
void Eye(void)
|
||||
void eye(void)
|
||||
{
|
||||
Clear();
|
||||
Identity();
|
||||
clear();
|
||||
identity();
|
||||
};
|
||||
/**
|
||||
* @brief Get the size of the current Matrix.
|
||||
* @return Dimention of the matrix
|
||||
*/
|
||||
Vector2D<int32_t> Size(void)
|
||||
Vector2D<int32_t> size(void)
|
||||
{
|
||||
return m_size;
|
||||
};
|
||||
|
@ -12,13 +12,13 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
void etk::Matrix4::Rotate(const vec3& vect, float angleRad)
|
||||
void etk::Matrix4::rotate(const vec3& vect, float angleRad)
|
||||
{
|
||||
etk::Matrix4 tmpMat = etk::matRotate(vect, angleRad);
|
||||
*this *= tmpMat;
|
||||
}
|
||||
|
||||
void etk::Matrix4::Translate(const vec3& vect)
|
||||
void etk::Matrix4::translate(const vec3& vect)
|
||||
{
|
||||
etk::Matrix4 tmpMat = etk::matTranslate(vect);
|
||||
*this *= tmpMat;
|
||||
@ -91,7 +91,7 @@ etk::Matrix4 etk::matTranslate(vec3 vect)
|
||||
etk::Matrix4 etk::matScale(vec3 vect)
|
||||
{
|
||||
etk::Matrix4 tmp;
|
||||
tmp.Scale(vect);
|
||||
tmp.scale(vect);
|
||||
/*
|
||||
// set scale :
|
||||
tmp.m_mat[0] = vect.x;
|
||||
@ -167,7 +167,7 @@ etk::Matrix4 etk::matLookAt(vec3 eye,
|
||||
|
||||
|
||||
|
||||
float etk::Matrix4::CoFactor(int32_t row, int32_t col) const
|
||||
float etk::Matrix4::coFactor(int32_t row, int32_t col) const
|
||||
{
|
||||
return ( ( m_mat[((row+1)&3)*4 + ((col+1)&3)] * m_mat[((row+2)&3)*4 + ((col+2)&3)] * m_mat[((row+3)&3)*4 + ((col+3)&3)]
|
||||
+ m_mat[((row+1)&3)*4 + ((col+2)&3)] * m_mat[((row+2)&3)*4 + ((col+3)&3)] * m_mat[((row+3)&3)*4 + ((col+1)&3)]
|
||||
@ -179,40 +179,40 @@ float etk::Matrix4::CoFactor(int32_t row, int32_t col) const
|
||||
}
|
||||
|
||||
|
||||
float etk::Matrix4::Determinant() const
|
||||
float etk::Matrix4::determinant() const
|
||||
{
|
||||
return m_mat[0] * CoFactor(0, 0) +
|
||||
m_mat[1] * CoFactor(0, 1) +
|
||||
m_mat[2] * CoFactor(0, 2) +
|
||||
m_mat[3] * CoFactor(0, 3);
|
||||
return m_mat[0] * coFactor(0, 0) +
|
||||
m_mat[1] * coFactor(0, 1) +
|
||||
m_mat[2] * coFactor(0, 2) +
|
||||
m_mat[3] * coFactor(0, 3);
|
||||
}
|
||||
|
||||
|
||||
etk::Matrix4 etk::Matrix4::Invert()
|
||||
etk::Matrix4 etk::Matrix4::invert()
|
||||
{
|
||||
float det = Determinant();
|
||||
float det = determinant();
|
||||
if(fabsf(det) < (1.0e-7f)) {
|
||||
// The matrix is not invertible! Singular case!
|
||||
return *this;
|
||||
}
|
||||
etk::Matrix4 temp;
|
||||
float iDet = 1.0f / det;
|
||||
temp.m_mat[0] = CoFactor(0,0) * iDet;
|
||||
temp.m_mat[1] = CoFactor(0,1) * iDet;
|
||||
temp.m_mat[2] = CoFactor(0,2) * iDet;
|
||||
temp.m_mat[3] = CoFactor(0,3) * iDet;
|
||||
temp.m_mat[4] = CoFactor(1,0) * iDet;
|
||||
temp.m_mat[5] = CoFactor(1,1) * iDet;
|
||||
temp.m_mat[6] = CoFactor(1,2) * iDet;
|
||||
temp.m_mat[7] = CoFactor(1,3) * iDet;
|
||||
temp.m_mat[8] = CoFactor(2,0) * iDet;
|
||||
temp.m_mat[9] = CoFactor(2,1) * iDet;
|
||||
temp.m_mat[10] = CoFactor(2,2) * iDet;
|
||||
temp.m_mat[11] = CoFactor(2,3) * iDet;
|
||||
temp.m_mat[12] = CoFactor(3,0) * iDet;
|
||||
temp.m_mat[13] = CoFactor(3,1) * iDet;
|
||||
temp.m_mat[14] = CoFactor(3,2) * iDet;
|
||||
temp.m_mat[15] = CoFactor(3,3) * iDet;
|
||||
temp.m_mat[0] = coFactor(0,0) * iDet;
|
||||
temp.m_mat[1] = coFactor(0,1) * iDet;
|
||||
temp.m_mat[2] = coFactor(0,2) * iDet;
|
||||
temp.m_mat[3] = coFactor(0,3) * iDet;
|
||||
temp.m_mat[4] = coFactor(1,0) * iDet;
|
||||
temp.m_mat[5] = coFactor(1,1) * iDet;
|
||||
temp.m_mat[6] = coFactor(1,2) * iDet;
|
||||
temp.m_mat[7] = coFactor(1,3) * iDet;
|
||||
temp.m_mat[8] = coFactor(2,0) * iDet;
|
||||
temp.m_mat[9] = coFactor(2,1) * iDet;
|
||||
temp.m_mat[10] = coFactor(2,2) * iDet;
|
||||
temp.m_mat[11] = coFactor(2,3) * iDet;
|
||||
temp.m_mat[12] = coFactor(3,0) * iDet;
|
||||
temp.m_mat[13] = coFactor(3,1) * iDet;
|
||||
temp.m_mat[14] = coFactor(3,2) * iDet;
|
||||
temp.m_mat[15] = coFactor(3,3) * iDet;
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace etk
|
||||
{
|
||||
public:
|
||||
float m_mat[4*4];
|
||||
void Identity(void) {
|
||||
void identity(void) {
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
m_mat[iii] = 0;
|
||||
}
|
||||
@ -35,7 +35,7 @@ namespace etk
|
||||
* Constructor
|
||||
*****************************************************/
|
||||
Matrix4(void) {
|
||||
Identity();
|
||||
identity();
|
||||
}
|
||||
Matrix4(const Matrix4& obj) {
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
@ -65,7 +65,7 @@ namespace etk
|
||||
}
|
||||
Matrix4(float * obj) {
|
||||
if (NULL == obj) {
|
||||
Identity();
|
||||
identity();
|
||||
return;
|
||||
}
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
@ -186,7 +186,7 @@ namespace etk
|
||||
/*****************************************************
|
||||
* other basic function :
|
||||
*****************************************************/
|
||||
void Transpose(void)
|
||||
void transpose(void)
|
||||
{
|
||||
float tmpVal = m_mat[1];
|
||||
m_mat[1] = m_mat[4];
|
||||
@ -212,11 +212,11 @@ namespace etk
|
||||
m_mat[11] = m_mat[14];
|
||||
m_mat[14] = tmpVal;
|
||||
}
|
||||
void Scale(const vec3& p)
|
||||
void scale(const vec3& p)
|
||||
{
|
||||
Scale(p.x(), p.y(), p.z());
|
||||
scale(p.x(), p.y(), p.z());
|
||||
}
|
||||
void Scale(float sx, float sy, float sz)
|
||||
void scale(float sx, float sy, float sz)
|
||||
{
|
||||
m_mat[0] *= sx; m_mat[1] *= sy; m_mat[2] *= sz;
|
||||
m_mat[4] *= sx; m_mat[5] *= sy; m_mat[6] *= sz;
|
||||
@ -227,30 +227,30 @@ namespace etk
|
||||
* @param[in] vect vector to apply the angle.
|
||||
* @param[in] angleRad angle to apply.
|
||||
*/
|
||||
void Rotate(const vec3& vect, float angleRad=0.0);
|
||||
void rotate(const vec3& vect, float angleRad=0.0);
|
||||
/**
|
||||
* @brief Makes a translation of the matrix
|
||||
* @param[in] vect Translation to apply.
|
||||
*/
|
||||
void Translate(const vec3& vect);
|
||||
void translate(const vec3& vect);
|
||||
/**
|
||||
* @brief Computes a cofactor. Used for matrix inversion.
|
||||
* @param[in] row Id of raw.
|
||||
* @param[in] col Id of colomn.
|
||||
* @return the coFactorValue.
|
||||
*/
|
||||
float CoFactor(int32_t row, int32_t col) const;
|
||||
float coFactor(int32_t row, int32_t col) const;
|
||||
/**
|
||||
* @brief Computes the determinant of the matrix.
|
||||
* @return The determinent Value.
|
||||
*/
|
||||
float Determinant(void) const;
|
||||
float determinant(void) const;
|
||||
/**
|
||||
* @brief Inverts the matrix.
|
||||
* @note The determinant must be != 0, otherwithe the matrix can't be inverted.
|
||||
* @return The inverted matrix.
|
||||
*/
|
||||
Matrix4 Invert(void);
|
||||
Matrix4 invert(void);
|
||||
};
|
||||
Matrix4 matFrustum(float xmin, float xmax, float ymin, float ymax, float zNear, float zFar);
|
||||
Matrix4 matPerspective(float foxy, float aspect, float zNear, float zFar);
|
||||
|
@ -55,7 +55,7 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
void SetNormal(const etk::Vector3D<T>& obj)
|
||||
void setNormal(const etk::Vector3D<T>& obj)
|
||||
{
|
||||
m_normal=obj;
|
||||
};
|
||||
@ -65,7 +65,7 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
void SetIntercept(float _intercept)
|
||||
void setIntercept(float _intercept)
|
||||
{
|
||||
m_intercept=_intercept;
|
||||
};
|
||||
@ -75,13 +75,13 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
void SetFromPoints(const etk::Vector3D<T> & p0,
|
||||
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);
|
||||
m_normal=(p1-p0).crossProduct(p2-p0);
|
||||
m_normal.normalize();
|
||||
calculateIntercept(p0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -89,9 +89,9 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
void CalculateIntercept(const etk::Vector3D<T>& pointOnPlane)
|
||||
void calculateIntercept(const etk::Vector3D<T>& pointOnPlane)
|
||||
{
|
||||
m_intercept=-m_normal.DotProduct(pointOnPlane);
|
||||
m_intercept=-m_normal.dotProduct(pointOnPlane);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,9 +99,9 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
void Normalize(void)
|
||||
void normalize(void)
|
||||
{
|
||||
float normalLength=m_normal.GetLength();
|
||||
float normalLength=m_normal.getLength();
|
||||
m_normal/=normalLength;
|
||||
m_intercept/=normalLength;
|
||||
};
|
||||
@ -111,7 +111,7 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
etk::Vector3D<T> GetNormal(void)
|
||||
etk::Vector3D<T> getNormal(void)
|
||||
{
|
||||
return m_normal;
|
||||
};
|
||||
@ -121,7 +121,7 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
float GetIntercept()
|
||||
float getIntercept()
|
||||
{
|
||||
return m_intercept;
|
||||
}
|
||||
@ -132,20 +132,20 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
bool Intersect3(const Plane<T>& p2,
|
||||
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));
|
||||
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;
|
||||
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);
|
||||
|
||||
@ -157,7 +157,7 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
float GetDistance(const etk::Vector3D<T> & point) const
|
||||
float getDistance(const etk::Vector3D<T> & point) const
|
||||
{
|
||||
return point.x*m_normal.x
|
||||
+ point.y*m_normal.y
|
||||
@ -170,11 +170,11 @@ namespace etk {
|
||||
* @param[in,out]
|
||||
* @return
|
||||
*/
|
||||
Plane<T> LinearInterpolate(const Plane<T> & p2, float factor)
|
||||
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_normal.normalize();
|
||||
result.m_intercept=m_intercept*(1.0f-factor) + p2.m_intercept*factor;
|
||||
return result;
|
||||
};
|
||||
|
@ -68,22 +68,22 @@ namespace etk
|
||||
m_floats[1] = false;
|
||||
// copy to permit to modify it :
|
||||
etk::UString tmpStr = _str;
|
||||
if (_str.StartWith("(")) {
|
||||
tmpStr.Remove(0,1);
|
||||
if (_str.startWith("(")) {
|
||||
tmpStr.remove(0,1);
|
||||
}
|
||||
if (tmpStr.EndWith(")")) {
|
||||
tmpStr.Remove(tmpStr.Size()-1,1);
|
||||
if (tmpStr.endWith(")")) {
|
||||
tmpStr.remove(tmpStr.size()-1,1);
|
||||
}
|
||||
int32_t posComa = tmpStr.FindForward(',');
|
||||
int32_t posComa = tmpStr.findForward(',');
|
||||
if (posComa <= 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = tmpStr.ToBool();
|
||||
m_floats[0] = tmpStr.toBool();
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = tmpStr.Extract(0,posComa).ToBool();
|
||||
tmpStr.Remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.ToBool();
|
||||
m_floats[0] = tmpStr.extract(0,posComa).toBool();
|
||||
tmpStr.remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.toBool();
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -105,23 +105,23 @@ namespace etk
|
||||
m_floats[1] = 0;
|
||||
// copy to permit to modify it :
|
||||
etk::UString tmpStr = _str;
|
||||
if (_str.StartWith("(")) {
|
||||
tmpStr.Remove(0,1);
|
||||
if (_str.startWith("(")) {
|
||||
tmpStr.remove(0,1);
|
||||
}
|
||||
if (tmpStr.EndWith(")")) {
|
||||
tmpStr.Remove(tmpStr.Size()-1,1);
|
||||
if (tmpStr.endWith(")")) {
|
||||
tmpStr.remove(tmpStr.size()-1,1);
|
||||
}
|
||||
|
||||
int32_t posComa = tmpStr.FindForward(',');
|
||||
int32_t posComa = tmpStr.findForward(',');
|
||||
if (posComa <= 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = tmpStr.ToInt32();
|
||||
m_floats[0] = tmpStr.toInt32();
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = tmpStr.Extract(0,posComa).ToInt32();
|
||||
tmpStr.Remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.ToInt32();
|
||||
m_floats[0] = tmpStr.extract(0,posComa).toInt32();
|
||||
tmpStr.remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.toInt32();
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -143,22 +143,22 @@ namespace etk
|
||||
m_floats[1] = 0;
|
||||
// copy to permit to modify it :
|
||||
etk::UString tmpStr = _str;
|
||||
if (_str.StartWith("(")) {
|
||||
tmpStr.Remove(0,1);
|
||||
if (_str.startWith("(")) {
|
||||
tmpStr.remove(0,1);
|
||||
}
|
||||
if (tmpStr.EndWith(")")) {
|
||||
tmpStr.Remove(tmpStr.Size()-1,1);
|
||||
if (tmpStr.endWith(")")) {
|
||||
tmpStr.remove(tmpStr.size()-1,1);
|
||||
}
|
||||
int32_t posComa = tmpStr.FindForward(',');
|
||||
int32_t posComa = tmpStr.findForward(',');
|
||||
if (posComa <= 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = tmpStr.ToUInt32();
|
||||
m_floats[0] = tmpStr.toUInt32();
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = tmpStr.Extract(0,posComa).ToUInt32();
|
||||
tmpStr.Remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.ToUInt32();
|
||||
m_floats[0] = tmpStr.extract(0,posComa).toUInt32();
|
||||
tmpStr.remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.toUInt32();
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -180,22 +180,22 @@ namespace etk
|
||||
m_floats[1] = 0;
|
||||
// copy to permit to modify it :
|
||||
etk::UString tmpStr = _str;
|
||||
if (_str.StartWith("(")) {
|
||||
tmpStr.Remove(0,1);
|
||||
if (_str.startWith("(")) {
|
||||
tmpStr.remove(0,1);
|
||||
}
|
||||
if (tmpStr.EndWith(")")) {
|
||||
tmpStr.Remove(tmpStr.Size()-1,1);
|
||||
if (tmpStr.endWith(")")) {
|
||||
tmpStr.remove(tmpStr.size()-1,1);
|
||||
}
|
||||
int32_t posComa = tmpStr.FindForward(',');
|
||||
int32_t posComa = tmpStr.findForward(',');
|
||||
if (posComa <= 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = tmpStr.ToFloat();
|
||||
m_floats[0] = tmpStr.toFloat();
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = tmpStr.Extract(0,posComa).ToFloat();
|
||||
tmpStr.Remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.ToFloat();
|
||||
m_floats[0] = tmpStr.extract(0,posComa).toFloat();
|
||||
tmpStr.remove(0,posComa+1);
|
||||
m_floats[1] = tmpStr.toFloat();
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
136
etk/os/FSNode.h
136
etk/os/FSNode.h
@ -22,11 +22,11 @@
|
||||
|
||||
namespace etk
|
||||
{
|
||||
void SetArgZero(const etk::UString& _val);
|
||||
void setArgZero(const etk::UString& _val);
|
||||
/**
|
||||
* List of Type that a node can have (this wrap some type that not exist on Windows)
|
||||
*/
|
||||
typedef enum {
|
||||
enum typeNode {
|
||||
FSN_UNKNOW, //!< Type of the node is not known
|
||||
FSN_BLOCK, //!< The node is a block aceess device (Not availlable on Windows)
|
||||
FSN_CHARACTER, //!< The node is a Char device type (Not availlable on Windows)
|
||||
@ -35,17 +35,17 @@ namespace etk
|
||||
FSN_LINK, //!< The node is a Link
|
||||
FSN_FILE, //!< The node is a File
|
||||
FSN_SOCKET, //!< The node is a socket
|
||||
} typeNode_te;
|
||||
};
|
||||
|
||||
etk::CCout& operator <<(etk::CCout &_os, const etk::typeNode_te &_obj);
|
||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::typeNode &_obj);
|
||||
|
||||
typedef enum {
|
||||
enum seekNode{
|
||||
FSN_SEEK_START,
|
||||
FSN_SEEK_END,
|
||||
FSN_SEEK_CURRENT,
|
||||
} seekNode_te;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
enum FSNType {
|
||||
FSN_TYPE_UNKNOW,
|
||||
// user might done abstraction ==> acces of the sdcard when possible ...
|
||||
FSN_TYPE_DIRECT,
|
||||
@ -85,9 +85,9 @@ namespace etk
|
||||
// - 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);
|
||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::FSNType &_obj);
|
||||
|
||||
/*
|
||||
note : The filename can be
|
||||
@ -125,8 +125,8 @@ namespace etk
|
||||
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
|
||||
enum FSNType m_type; //!< the Type of data requested by the User
|
||||
enum typeNode 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; //!< When reading file, this is the Real pointer access
|
||||
@ -150,16 +150,16 @@ namespace etk
|
||||
/**
|
||||
* @brief Internal methode that create the internal Real system name (transform DATA: HOME: DATA:GUI: in the real name of the files)
|
||||
*/
|
||||
void GenerateFileSystemPath(void);
|
||||
void generateFileSystemPath(void);
|
||||
/**
|
||||
* @brief Update the internal data of the right type, and times
|
||||
*/
|
||||
void UpdateFileSystemProperty(void);
|
||||
void updateFileSystemProperty(void);
|
||||
/**
|
||||
* @brief Common set name of the Node (if the user decide to change the node selection
|
||||
* @param[in] _newName Name of the Node
|
||||
*/
|
||||
void PrivateSetName(const etk::UString& _newName);
|
||||
void privateSetName(const etk::UString& _newName);
|
||||
private:
|
||||
#ifdef __TARGET_OS__Android
|
||||
/**
|
||||
@ -167,7 +167,7 @@ namespace etk
|
||||
* @return true : Load is OK
|
||||
* @return false : An error Occured
|
||||
*/
|
||||
bool LoadDataZip(void);
|
||||
bool loadDataZip(void);
|
||||
const etk::Archive::Content* m_zipContent;
|
||||
int32_t m_zipReadingOffset;
|
||||
#endif
|
||||
@ -177,119 +177,119 @@ namespace etk
|
||||
* @return true : The node existed.
|
||||
* @return false : The node does not exist.
|
||||
*/
|
||||
bool Exist(void) const { return (m_typeNode!=etk::FSN_UNKNOW); };
|
||||
bool exist(void) const { return (m_typeNode!=etk::FSN_UNKNOW); };
|
||||
/**
|
||||
* @brief Get the node type
|
||||
* @return the requested type, FSN_UNKNOW if it does not existed
|
||||
*/
|
||||
typeNode_te GetNodeType(void) const { return m_typeNode; };
|
||||
enum typeNode getNodeType(void) const { return m_typeNode; };
|
||||
/**
|
||||
* @brief Get the node Right
|
||||
* @return the requested right
|
||||
*/
|
||||
etk::FSNodeRight GetRight(void) const { return m_rights; };
|
||||
etk::FSNodeRight getRight(void) const { return m_rights; };
|
||||
/**
|
||||
* @brief Set the specific right of the node
|
||||
* @param[in] _newRight new right to set
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool SetRight(etk::FSNodeRight _newRight);
|
||||
bool setRight(etk::FSNodeRight _newRight);
|
||||
/**
|
||||
* @brief Change the Node seeing (not rename the node, for this @ref Move)
|
||||
* @param[in] _newName New node name to show
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
void SetName(const etk::UString& _newName);
|
||||
void setName(const etk::UString& _newName);
|
||||
/**
|
||||
* @brief Get the Generate FileSystem name
|
||||
* @return the requested filename
|
||||
*/
|
||||
etk::UString GetFileSystemName(void) const;
|
||||
etk::UString getFileSystemName(void) const;
|
||||
/**
|
||||
* @brief Get the current folder of the Node. (file system name)
|
||||
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
|
||||
* @note Auto remove of ../../../ and //
|
||||
*/
|
||||
etk::UString GetNameFolder(void) const;
|
||||
etk::UString getNameFolder(void) const;
|
||||
/**
|
||||
* @brief Get the current compleate node name (file system name)
|
||||
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
|
||||
* @note Auto remove of ../../../ and //
|
||||
*/
|
||||
etk::UString GetName(void) const;
|
||||
etk::UString getName(void) const;
|
||||
/**
|
||||
* @brief Get the file or current folder name (if it was a folder)
|
||||
* @return the name of the node (like myFile.kkk)
|
||||
*/
|
||||
etk::UString GetNameFile(void) const;
|
||||
etk::UString getNameFile(void) const;
|
||||
/**
|
||||
* @brief Get the current folder of the Node.
|
||||
* @return the common name define (like DATA:xxxxx/xxxxx/)
|
||||
* @note Auto remove of ../../../ and //
|
||||
*/
|
||||
etk::UString GetRelativeFolder(void) const;
|
||||
etk::UString getRelativeFolder(void) const;
|
||||
/**
|
||||
* @brief update the Time of the file with the current time
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool Touch(void);
|
||||
bool touch(void);
|
||||
/**
|
||||
* @brief Move the Node at a new path
|
||||
* @param[in] _path The new path
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool Move(const etk::UString& _path);
|
||||
bool move(const etk::UString& _path);
|
||||
/**
|
||||
* @brief Get the node type (DATA/DIRECT...)
|
||||
* @return the requested type
|
||||
*/
|
||||
FSNType_te GetTypeAccess(void) const { return m_type; };
|
||||
enum FSNType getTypeAccess(void) const { return m_type; };
|
||||
/**
|
||||
* @brief Remove the current node ( if folder, this remove all subfolder but not the Link subfolder)
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool Remove(void);
|
||||
bool remove(void);
|
||||
/**
|
||||
* @brief Get the creating time of the File
|
||||
* @return The time requested
|
||||
*/
|
||||
uint64_t TimeCreated(void) const;
|
||||
uint64_t timeCreated(void) const;
|
||||
/**
|
||||
* @brief Get the creating time of the File
|
||||
* @return The time requested (in string)
|
||||
*/
|
||||
etk::UString TimeCreatedString(void) const;
|
||||
etk::UString timeCreatedString(void) const;
|
||||
/**
|
||||
* @brief Get the modifying time of the File
|
||||
* @return The time requested
|
||||
*/
|
||||
uint64_t TimeModified(void) const;
|
||||
uint64_t timeModified(void) const;
|
||||
/**
|
||||
* @brief Get the modifying time of the File
|
||||
* @return The time requested (in string)
|
||||
*/
|
||||
etk::UString TimeModifiedString(void) const;
|
||||
etk::UString timeModifiedString(void) const;
|
||||
/**
|
||||
* @brief Get the Accessed time of the File
|
||||
* @return The time requested
|
||||
*/
|
||||
uint64_t TimeAccessed(void) const;
|
||||
uint64_t timeAccessed(void) const;
|
||||
/**
|
||||
* @brief Get the Accessed time of the File
|
||||
* @return The time requested (in string)
|
||||
*/
|
||||
etk::UString TimeAccessedString(void) const;
|
||||
etk::UString timeAccessedString(void) const;
|
||||
/**
|
||||
* @brief copy the other FSnode ==> for vector
|
||||
* @param[in] _obj input node
|
||||
* @return the current modify node
|
||||
*/
|
||||
const etk::FSNode& operator= (const etk::FSNode &_obj );
|
||||
const etk::FSNode& operator= (const etk::FSNode &_obj );
|
||||
/**
|
||||
* @brief Check if the 2 node are link with the same file
|
||||
* @param[in] _obj input node
|
||||
@ -315,7 +315,7 @@ namespace etk
|
||||
* @return >=0 nb of subElement
|
||||
* @return -1 an error occured ==> not a folder ???
|
||||
*/
|
||||
int64_t FolderCount(void);
|
||||
int64_t folderCount(void);
|
||||
/**
|
||||
* @brief Get the List of all node inside a node (folder only)
|
||||
* @param[in] _showHidenFile Add hidden file/folder/...
|
||||
@ -324,75 +324,75 @@ namespace etk
|
||||
* @param[in] _temporaryFile add Tmp file like .bck or ~
|
||||
* @return The requested list
|
||||
*/
|
||||
etk::Vector<etk::FSNode *> FolderGetSubList(bool _showHidenFile=true,
|
||||
bool _getFolderAndOther=true,
|
||||
bool _getFile=true,
|
||||
bool _temporaryFile=true);
|
||||
etk::Vector<etk::FSNode*> folderGetSubList(bool _showHidenFile=true,
|
||||
bool _getFolderAndOther=true,
|
||||
bool _getFile=true,
|
||||
bool _temporaryFile=true);
|
||||
/**
|
||||
* @brief Get the father node of this node
|
||||
* @return The requested node
|
||||
*/
|
||||
etk::FSNode FolderGetParent(void);
|
||||
etk::FSNode folderGetParent(void);
|
||||
/**
|
||||
* @brief Get all the File inside a Folder (done recursively)
|
||||
* @param[out] _output List of all the File names (You must clear it before set it in)
|
||||
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
|
||||
*/
|
||||
void FolderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable=true);
|
||||
void folderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable=true);
|
||||
/**
|
||||
* @brief Check if the file have an extention ( ***.ccc)
|
||||
* @return true The file have an extention.
|
||||
* @return false The file have NO extention.
|
||||
*/
|
||||
bool FileHasExtention(void);
|
||||
bool fileHasExtention(void);
|
||||
/**
|
||||
* @brief Get the extention of the Node
|
||||
* @return the requested extention
|
||||
*/
|
||||
etk::UString FileGetExtention(void);
|
||||
etk::UString fileGetExtention(void);
|
||||
/**
|
||||
* @brief Get the File size
|
||||
* @return the requested size
|
||||
*/
|
||||
uint64_t FileSize(void);
|
||||
uint64_t fileSize(void);
|
||||
/**
|
||||
* @brief Open the file in Read mode
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool FileOpenRead(void);
|
||||
bool fileOpenRead(void);
|
||||
/**
|
||||
* @brief Open the file in write Mode
|
||||
* @note You can not do it with the DATA: file ==> this is not allowed in some Board like Android)
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool FileOpenWrite(void);
|
||||
bool fileOpenWrite(void);
|
||||
/**
|
||||
* @brief Open the file in write Append Mode
|
||||
* @note You can not do it with the DATA: file ==> this is not allowed in some Board like Android)
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool FileOpenAppend(void);
|
||||
bool fileOpenAppend(void);
|
||||
/**
|
||||
* @brief Close the cuurent file
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool FileClose(void);
|
||||
bool fileClose(void);
|
||||
/**
|
||||
* @brief Get the pointer on the start line and the next line (or null)
|
||||
* @param[in,out] _elementLine Pointer to an array of chars where the string read is copied.
|
||||
* @param[in] _maxData Maximum number of characters to be copied into str (including the terminating null-character).
|
||||
* @return the pointer on the end of the cuurent line.
|
||||
*/
|
||||
char* FileGets(char* _elementLine, int64_t _maxData);
|
||||
char* fileGets(char* _elementLine, int64_t _maxData);
|
||||
/**
|
||||
* @brief Get a unique data in the file
|
||||
* @return the next element in the file.
|
||||
*/
|
||||
char FileGet(void);
|
||||
char fileGet(void);
|
||||
/**
|
||||
* @brief Read data from the file
|
||||
* @param[in,out] _data Pointer on the buffer that might be set the data
|
||||
@ -400,7 +400,7 @@ namespace etk
|
||||
* @param[in] _nbBlock Number of block needed
|
||||
* @return Number of element read (in block number)
|
||||
*/
|
||||
int64_t FileRead(void* _data, int64_t _blockSize, int64_t _nbBlock);
|
||||
int64_t fileRead(void* _data, int64_t _blockSize, int64_t _nbBlock);
|
||||
/**
|
||||
* @brief Write data on the file
|
||||
* @param[in] _data Pointer on the buffer that might be set on the file
|
||||
@ -408,7 +408,7 @@ namespace etk
|
||||
* @param[in] _nbBlock Number of block needed
|
||||
* @return Number of element written (in block number)
|
||||
*/
|
||||
int64_t FileWrite(void* _data, int64_t _blockSize, int64_t _nbBlock);
|
||||
int64_t fileWrite(void* _data, int64_t _blockSize, int64_t _nbBlock);
|
||||
/**
|
||||
* @brief Move in the file Position
|
||||
* @param[in] _offset Offset to apply at the file
|
||||
@ -416,17 +416,17 @@ namespace etk
|
||||
* @return true : action done
|
||||
* @return false : action not done
|
||||
*/
|
||||
bool FileSeek(long int _offset, etk::seekNode_te _origin);
|
||||
bool fileSeek(long int _offset, enum etk::seekNode _origin);
|
||||
/**
|
||||
* @brief Flush the current file
|
||||
*/
|
||||
void FileFlush(void);
|
||||
void fileFlush(void);
|
||||
private:
|
||||
/**
|
||||
* @brief Order the list of subnode the folder first and the alphabetical order
|
||||
* @param[in,out] _list The list to order
|
||||
*/
|
||||
void SortElementList(etk::Vector<etk::FSNode *>& _list);
|
||||
void sortElementList(etk::Vector<etk::FSNode *>& _list);
|
||||
};
|
||||
|
||||
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNode &_obj);
|
||||
@ -435,32 +435,32 @@ namespace etk
|
||||
* @brief Set manualy the folder of the Data.(like /usr/shared/applName/ for linux)
|
||||
* @param[in] _folder folder path of the cathegorie
|
||||
*/
|
||||
void SetBaseFolderData(const char* _folder);
|
||||
void setBaseFolderData(const char* _folder);
|
||||
/**
|
||||
* @brief Set the user data folder (like /home/machin/.local/applName/ for linux)
|
||||
* @param[in] _folder folder path of the cathegorie
|
||||
*/
|
||||
void SetBaseFolderDataUser(const char* _folder);
|
||||
void setBaseFolderDataUser(const char* _folder);
|
||||
/**
|
||||
* @brief Set the Cach folder for the application (like /tmp)
|
||||
* @param[in] _folder folder path of the cathegorie
|
||||
*/
|
||||
void SetBaseFolderCache(const char* _folder);
|
||||
void setBaseFolderCache(const char* _folder);
|
||||
/**
|
||||
* @brief Initialyse all the subFolder usable by the user like DATA/HOME/CACHE/USERDATA
|
||||
* @param[in] _applName the name of the application
|
||||
*/
|
||||
void InitDefaultFolder(const char* _applName);
|
||||
void initDefaultFolder(const char* _applName);
|
||||
/**
|
||||
* @brief Get the home folder of the user
|
||||
* @return the home folder : like : "/home/machin/"
|
||||
*/
|
||||
etk::UString GetUserHomeFolder(void);
|
||||
etk::UString getUserHomeFolder(void);
|
||||
/**
|
||||
* @brief Get the folder of the Program is running
|
||||
* @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder)
|
||||
*/
|
||||
etk::UString GetUserRunFolder(void);
|
||||
etk::UString getUserRunFolder(void);
|
||||
|
||||
namespace theme
|
||||
{
|
||||
@ -470,18 +470,18 @@ namespace etk
|
||||
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
||||
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
|
||||
*/
|
||||
void SetName(etk::UString _refName, etk::UString _folderName);
|
||||
void setName(etk::UString _refName, etk::UString _folderName);
|
||||
/**
|
||||
* @brief get the folder from a Reference theme
|
||||
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
||||
* @return the path of the theme
|
||||
*/
|
||||
etk::UString GetName(etk::UString _refName);
|
||||
etk::UString getName(etk::UString _refName);
|
||||
/**
|
||||
* @brief Get the list of all the theme folder availlable in the user Home/appl
|
||||
* @return The list of elements
|
||||
*/
|
||||
etk::Vector<etk::UString> List(void);
|
||||
etk::Vector<etk::UString> list(void);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -506,7 +506,7 @@ namespace etk
|
||||
* @return true : Action done corectly
|
||||
* @return false : An error occured
|
||||
*/
|
||||
bool FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, etk::typeNode_te _type=etk::FSN_FOLDER);
|
||||
bool FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
|
||||
/**
|
||||
* @brief Simple access for : chexk the exestance of an element
|
||||
* @param[in] _path Folder/File/Pipe path of the node
|
||||
@ -535,7 +535,7 @@ namespace etk
|
||||
* @return true : Action done corectly
|
||||
* @return false : An error occured
|
||||
*/
|
||||
etk::typeNode_te FSNodeGetType(const etk::UString& _path);
|
||||
enum etk::typeNode FSNodeGetType(const etk::UString& _path);
|
||||
/**
|
||||
* @brief Simple access for : Getting creation time of the current node
|
||||
* @param[in] _path Folder/File/Pipe path of the node
|
||||
|
@ -49,22 +49,22 @@ const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t _newVal )
|
||||
}
|
||||
|
||||
// User
|
||||
bool etk::FSNodeRight::IsUserReadable(void) const
|
||||
bool etk::FSNodeRight::isUserReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_READ)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsUserWritable(void) const
|
||||
bool etk::FSNodeRight::isUserWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_WRITE)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsUserRunable(void) const
|
||||
bool etk::FSNodeRight::isUserRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_USER_EXECUTE)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserReadable(bool _newStatus)
|
||||
void etk::FSNodeRight::setUserReadable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_READ);
|
||||
@ -73,7 +73,7 @@ void etk::FSNodeRight::SetUserReadable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserWritable(bool _newStatus)
|
||||
void etk::FSNodeRight::setUserWritable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_WRITE);
|
||||
@ -82,7 +82,7 @@ void etk::FSNodeRight::SetUserWritable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetUserRunable(bool _newStatus)
|
||||
void etk::FSNodeRight::setUserRunable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_USER_EXECUTE);
|
||||
@ -92,22 +92,22 @@ void etk::FSNodeRight::SetUserRunable(bool _newStatus)
|
||||
}
|
||||
|
||||
// group
|
||||
bool etk::FSNodeRight::IsGroupReadable(void) const
|
||||
bool etk::FSNodeRight::isGroupReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_READ)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsGroupWritable(void) const
|
||||
bool etk::FSNodeRight::isGroupWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_WRITE)!=0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsGroupRunable(void) const
|
||||
bool etk::FSNodeRight::isGroupRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_GROUP_EXECUTE)!=0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupReadable(bool _newStatus)
|
||||
void etk::FSNodeRight::setGroupReadable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_READ);
|
||||
@ -116,7 +116,7 @@ void etk::FSNodeRight::SetGroupReadable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupWritable(bool _newStatus)
|
||||
void etk::FSNodeRight::setGroupWritable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_WRITE);
|
||||
@ -125,7 +125,7 @@ void etk::FSNodeRight::SetGroupWritable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetGroupRunable(bool _newStatus)
|
||||
void etk::FSNodeRight::setGroupRunable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_EXECUTE);
|
||||
@ -135,22 +135,22 @@ void etk::FSNodeRight::SetGroupRunable(bool _newStatus)
|
||||
}
|
||||
|
||||
// other
|
||||
bool etk::FSNodeRight::IsOtherReadable(void) const
|
||||
bool etk::FSNodeRight::isOtherReadable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_READ)!=0)?true:false;
|
||||
return ((m_rights&RIGHT_OTHER_READ) != 0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsOtherWritable(void) const
|
||||
bool etk::FSNodeRight::isOtherWritable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_WRITE)!=0)?true:false;
|
||||
return ((m_rights&RIGHT_OTHER_WRITE) != 0)?true:false;
|
||||
}
|
||||
|
||||
bool etk::FSNodeRight::IsOtherRunable(void) const
|
||||
bool etk::FSNodeRight::isOtherRunable(void) const
|
||||
{
|
||||
return ((m_rights&RIGHT_OTHER_EXECUTE)!=0)?true:false;
|
||||
return ((m_rights&RIGHT_OTHER_EXECUTE) != 0)?true:false;
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherReadable(bool _newStatus)
|
||||
void etk::FSNodeRight::setOtherReadable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_READ);
|
||||
@ -159,7 +159,7 @@ void etk::FSNodeRight::SetOtherReadable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherWritable(bool _newStatus)
|
||||
void etk::FSNodeRight::setOtherWritable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_WRITE);
|
||||
@ -168,7 +168,7 @@ void etk::FSNodeRight::SetOtherWritable(bool _newStatus)
|
||||
}
|
||||
}
|
||||
|
||||
void etk::FSNodeRight::SetOtherRunable(bool _newStatus)
|
||||
void etk::FSNodeRight::setOtherRunable(bool _newStatus)
|
||||
{
|
||||
// reset the flag :
|
||||
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_EXECUTE);
|
||||
@ -176,50 +176,50 @@ void etk::FSNodeRight::SetOtherRunable(bool _newStatus)
|
||||
m_rights |= RIGHT_OTHER_EXECUTE;
|
||||
}
|
||||
}
|
||||
etk::UString etk::FSNodeRight::GetRight(void) const
|
||||
etk::UString etk::FSNodeRight::getRight(void) const
|
||||
{
|
||||
etk::UString tmp;
|
||||
if (true==IsUserReadable()) {
|
||||
if (isUserReadable() == true) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsUserWritable()) {
|
||||
if (isUserWritable() == true) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsUserRunable()) {
|
||||
if (isUserRunable() == true) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupReadable()) {
|
||||
if (isGroupReadable() == true) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupWritable()) {
|
||||
if (isGroupWritable() == true) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsGroupRunable()) {
|
||||
if (isGroupRunable() == true) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherReadable()) {
|
||||
if (isOtherReadable() == true) {
|
||||
tmp += "r";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherWritable()) {
|
||||
if (isOtherWritable() == true) {
|
||||
tmp += "w";
|
||||
} else {
|
||||
tmp += "-";
|
||||
}
|
||||
if (true==IsOtherRunable()) {
|
||||
if (isOtherRunable() == true) {
|
||||
tmp += "x";
|
||||
} else {
|
||||
tmp += "-";
|
||||
@ -230,7 +230,7 @@ etk::UString etk::FSNodeRight::GetRight(void) const
|
||||
|
||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj)
|
||||
{
|
||||
_os << _obj.GetRight();
|
||||
_os << _obj.getRight();
|
||||
return _os;
|
||||
};
|
||||
|
||||
|
@ -26,30 +26,30 @@ namespace etk
|
||||
// set right :
|
||||
const etk::FSNodeRight& operator= (const int32_t _newVal );
|
||||
|
||||
void Clear(void) { m_rights = 0; };
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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::UString getRight(void) const;
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj);
|
||||
};
|
||||
|
@ -25,19 +25,19 @@ etk::Mutex::~Mutex(void)
|
||||
}
|
||||
|
||||
|
||||
void etk::Mutex::Lock(void)
|
||||
void etk::Mutex::lock(void)
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
|
||||
bool etk::Mutex::TryLock(void)
|
||||
bool etk::Mutex::tryLock(void)
|
||||
{
|
||||
return pthread_mutex_trylock(&m_mutex) != 0;
|
||||
}
|
||||
|
||||
|
||||
void etk::Mutex::UnLock(void)
|
||||
void etk::Mutex::unLock(void)
|
||||
{
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
@ -21,19 +21,19 @@ etk::Mutex::~Mutex(void)
|
||||
}
|
||||
|
||||
|
||||
void etk::Mutex::Lock(void)
|
||||
void etk::Mutex::lock(void)
|
||||
{
|
||||
EnterCriticalSection(&m_mutex);
|
||||
}
|
||||
|
||||
|
||||
bool etk::Mutex::TryLock(void)
|
||||
bool etk::Mutex::tryLock(void)
|
||||
{
|
||||
return TryEnterCriticalSection(&m_mutex) != 0;
|
||||
}
|
||||
|
||||
|
||||
void etk::Mutex::UnLock(void)
|
||||
void etk::Mutex::unLock(void)
|
||||
{
|
||||
LeaveCriticalSection(&m_mutex);
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ namespace etk
|
||||
public:
|
||||
Mutex(void);
|
||||
~Mutex(void);
|
||||
void Lock(void);
|
||||
bool TryLock(void);
|
||||
void UnLock(void);
|
||||
void lock(void);
|
||||
bool tryLock(void);
|
||||
void unLock(void);
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ etk::Semaphore::~Semaphore(void)
|
||||
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
|
||||
}
|
||||
|
||||
uint32_t etk::Semaphore::GetCount(void)
|
||||
uint32_t etk::Semaphore::getCount(void)
|
||||
{
|
||||
int32_t tmpData = 0;
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
@ -47,7 +47,7 @@ uint32_t etk::Semaphore::GetCount(void)
|
||||
return tmpData;
|
||||
}
|
||||
|
||||
void etk::Semaphore::Post(void)
|
||||
void etk::Semaphore::post(void)
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
if (m_data>=m_maximum) {
|
||||
@ -61,7 +61,7 @@ void etk::Semaphore::Post(void)
|
||||
}
|
||||
|
||||
|
||||
void etk::Semaphore::Wait(void)
|
||||
void etk::Semaphore::wait(void)
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
while(m_data == 0) {
|
||||
@ -72,7 +72,7 @@ void etk::Semaphore::Wait(void)
|
||||
}
|
||||
|
||||
|
||||
bool etk::Semaphore::Wait(uint32_t _timeOutInUs)
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs)
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
if(m_data == 0) {
|
||||
|
@ -12,7 +12,7 @@
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax)
|
||||
{
|
||||
// create interface mutex :
|
||||
m_semaphore = CreateSemaphore(NULL, _nbBasicElement, _nbMessageMax, NULL);
|
||||
m_semaphore = createSemaphore(NULL, _nbBasicElement, _nbMessageMax, NULL);
|
||||
TK_ASSERT(m_semaphore != 0, "Error creating SEMAPHORE ...");
|
||||
}
|
||||
|
||||
@ -22,28 +22,28 @@ etk::Semaphore::~Semaphore(void)
|
||||
CloseHandle(m_semaphore);
|
||||
}
|
||||
|
||||
uint32_t etk::Semaphore::GetCount(void)
|
||||
uint32_t etk::Semaphore::getCount(void)
|
||||
{
|
||||
LONG tmpData = 0;
|
||||
ReleaseSemaphore(m_semaphore, 0, &tmpData);
|
||||
releaseSemaphore(m_semaphore, 0, &tmpData);
|
||||
return tmpData;
|
||||
}
|
||||
|
||||
void etk::Semaphore::Post(void)
|
||||
void etk::Semaphore::post(void)
|
||||
{
|
||||
ReleaseSemaphore(m_semaphore, 1, NULL);
|
||||
releaseSemaphore(m_semaphore, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
void etk::Semaphore::Wait(void)
|
||||
void etk::Semaphore::wait(void)
|
||||
{
|
||||
WaitForSingleObject(m_semaphore, INFINITE);
|
||||
waitForSingleObject(m_semaphore, INFINITE);
|
||||
}
|
||||
|
||||
|
||||
bool etk::Semaphore::Wait(uint32_t _timeOutInUs)
|
||||
bool etk::Semaphore::wait(uint64_t _timeOutInUs)
|
||||
{
|
||||
DWORD result = WaitForSingleObject(m_semaphore, _timeOutInUs);
|
||||
DWORD result = waitForSingleObject(m_semaphore, _timeOutInUs);
|
||||
if (result == WAIT_FAILED) {
|
||||
TK_ERROR("Failed to wait for semaphore ");
|
||||
return false;
|
||||
|
@ -23,21 +23,21 @@ namespace etk
|
||||
{
|
||||
private:
|
||||
#ifdef __TARGET_OS__Windows
|
||||
HANDLE m_semaphore;
|
||||
HANDLE m_semaphore;
|
||||
#else
|
||||
pthread_mutex_t m_mutex;
|
||||
pthread_cond_t m_condition;
|
||||
uint32_t m_data;
|
||||
uint32_t m_maximum;
|
||||
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);
|
||||
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);
|
||||
bool wait(uint64_t _timeOutInUs);
|
||||
};
|
||||
|
||||
};
|
||||
|
30
etk/tool.cpp
30
etk/tool.cpp
@ -25,21 +25,21 @@ 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 *> &_list)
|
||||
void etk::tool::sortList(etk::Vector<etk::UString *> &_list)
|
||||
{
|
||||
etk::Vector<etk::UString *> tmpList = _list;
|
||||
_list.Clear();
|
||||
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
|
||||
_list.clear();
|
||||
for(int32_t iii=0; iii<tmpList.size(); iii++) {
|
||||
|
||||
int32_t findPos = 0;
|
||||
for(int32_t jjj=0; jjj<_list.Size(); jjj++) {
|
||||
for(int32_t jjj=0; jjj<_list.size(); jjj++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (*tmpList[iii] > *_list[jjj]) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
_list.Insert(findPos, tmpList[iii]);
|
||||
_list.insert(findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,46 +69,46 @@ bool etk::tool::strnCmpNoCase(const char * _input1, const char * _input2, int32_
|
||||
}
|
||||
|
||||
|
||||
etk::UString etk::tool::SimplifyPath(etk::UString _input)
|
||||
etk::UString etk::tool::simplifyPath(etk::UString _input)
|
||||
{
|
||||
int32_t findStartPos = _input.FindForward('/') + 1;
|
||||
int32_t findPos = _input.FindForward('/', findStartPos);
|
||||
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) {
|
||||
if (_input.size()<findPos+1) {
|
||||
// no more element ...
|
||||
break;
|
||||
}
|
||||
if( _input[findPos+1] == '/'
|
||||
|| ( _input[findPos+1] == '.'
|
||||
&& _input.Size()==findPos+2 )) {
|
||||
&& _input.size()==findPos+2 )) {
|
||||
// cleane the element path
|
||||
_input.Remove(findPos+1, 1);
|
||||
_input.remove(findPos+1, 1);
|
||||
//TK_DEBUG(" Remove // string=\"" << input << "\"");
|
||||
} else {
|
||||
if (_input.Size()<findPos+2) {
|
||||
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 );
|
||||
_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);
|
||||
_input.remove(findPos+1, 2);
|
||||
//TK_DEBUG(" Remove ./ string=\"" << input << "\"");
|
||||
} else {
|
||||
findStartPos = findPos+1;
|
||||
}
|
||||
}
|
||||
findPos = _input.FindForward('/', findStartPos);
|
||||
findPos = _input.findForward('/', findStartPos);
|
||||
preventBadCode++;
|
||||
if (preventBadCode>5000) {
|
||||
TK_CRITICAL("ERROR when getting the small path ... this is loop prevention...");
|
||||
|
@ -17,9 +17,9 @@ namespace etk {
|
||||
float frand(float _a, float _b);
|
||||
int32_t irand(int32_t _a, int32_t _b);
|
||||
|
||||
void SortList(etk::Vector<etk::UString *>& _list);
|
||||
void sortList(etk::Vector<etk::UString *>& _list);
|
||||
bool strnCmpNoCase(const char* _input1, const char* _input2, int32_t _maxLen);
|
||||
etk::UString SimplifyPath(etk::UString _input);
|
||||
etk::UString simplifyPath(etk::UString _input);
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -51,4 +51,6 @@
|
||||
typedef int32_t esize_t;
|
||||
#define ESIZE_T_IS_SIGNED
|
||||
#endif
|
||||
|
||||
typedef float float_t;
|
||||
#endif
|
||||
|
246
etk/unicode.cpp
246
etk/unicode.cpp
@ -19,20 +19,20 @@ void unicode::convertIsoToUnicode(charset_te _inputCharset, const char _input_IS
|
||||
{
|
||||
switch(_inputCharset)
|
||||
{
|
||||
case EDN_CHARSET_ISO_8859_1: _output_Unicode.Set(TableIso8859_1[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_2: _output_Unicode.Set(TableIso8859_2[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_3: _output_Unicode.Set(TableIso8859_3[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_4: _output_Unicode.Set(TableIso8859_4[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_5: _output_Unicode.Set(TableIso8859_5[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_6: _output_Unicode.Set(TableIso8859_6[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_7: _output_Unicode.Set(TableIso8859_7[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_8: _output_Unicode.Set(TableIso8859_8[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_9: _output_Unicode.Set(TableIso8859_9[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_10: _output_Unicode.Set(TableIso8859_10[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_11: _output_Unicode.Set(TableIso8859_11[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_13: _output_Unicode.Set(TableIso8859_13[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_14: _output_Unicode.Set(TableIso8859_14[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_15: _output_Unicode.Set(TableIso8859_15[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_1: _output_Unicode.set(tableIso8859_1[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_2: _output_Unicode.set(tableIso8859_2[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_3: _output_Unicode.set(tableIso8859_3[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_4: _output_Unicode.set(tableIso8859_4[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_5: _output_Unicode.set(tableIso8859_5[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_6: _output_Unicode.set(tableIso8859_6[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_7: _output_Unicode.set(tableIso8859_7[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_8: _output_Unicode.set(tableIso8859_8[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_9: _output_Unicode.set(tableIso8859_9[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_10: _output_Unicode.set(tableIso8859_10[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_11: _output_Unicode.set(tableIso8859_11[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_13: _output_Unicode.set(tableIso8859_13[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_14: _output_Unicode.set(tableIso8859_14[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_15: _output_Unicode.set(tableIso8859_15[(uint32_t)_input_ISO&0xFF]); break;
|
||||
default :
|
||||
TK_WARNING("Unknow charset ... " << _inputCharset);
|
||||
_output_Unicode = '?';
|
||||
@ -46,20 +46,20 @@ void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _inp
|
||||
const uint32_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;
|
||||
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 = '?';
|
||||
@ -67,7 +67,7 @@ void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _inp
|
||||
}
|
||||
int32_t i;
|
||||
for (i=0; i<256; i++) {
|
||||
if (tmpTable[i] == _input_Unicode.Get()) {
|
||||
if (tmpTable[i] == _input_Unicode.get()) {
|
||||
_output_ISO = (char)i;
|
||||
return;
|
||||
}
|
||||
@ -77,67 +77,67 @@ void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _inp
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
_output_Unicode.Clear();
|
||||
_output_Unicode.clear();
|
||||
uniChar_t output;
|
||||
for(int32_t iii=0; iii<_input_ISO.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.PushBack(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);
|
||||
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();
|
||||
return _output_Unicode.size();
|
||||
}
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
_output_Unicode.Clear();
|
||||
_output_Unicode.clear();
|
||||
uniChar_t output;
|
||||
for(int32_t iii=0; iii<_input_ISO.Size(); iii++) {
|
||||
for(int32_t iii=0; iii<_input_ISO.size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.PushBack(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);
|
||||
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();
|
||||
return _output_Unicode.size();
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_ISO)
|
||||
{
|
||||
_output_ISO.Clear();
|
||||
_output_ISO.clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
_output_ISO.PushBack(*tmp);
|
||||
_output_ISO.pushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_ISO.PushBack(0);
|
||||
return _output_ISO.Size();
|
||||
_output_ISO.pushBack(0);
|
||||
return _output_ISO.size();
|
||||
}
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_ISO)
|
||||
{
|
||||
_output_ISO.Clear();
|
||||
_output_ISO.clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
for(int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
_output_ISO.PushBack(*tmp);
|
||||
_output_ISO.pushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_ISO.PushBack(0);
|
||||
return _output_ISO.Size();
|
||||
_output_ISO.pushBack(0);
|
||||
return _output_ISO.size();
|
||||
}
|
||||
|
||||
|
||||
@ -146,32 +146,32 @@ int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unico
|
||||
{
|
||||
char output[10];
|
||||
|
||||
for (int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
for (int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
_output_UTF8.PushBack(*tmp);
|
||||
_output_UTF8.pushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_UTF8.PushBack('\0');
|
||||
return _output_UTF8.Size()-1;
|
||||
_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++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
for (int32_t iii=0; iii<_input_Unicode.size(); iii++) {
|
||||
_input_Unicode[iii].getUtf8(output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
_output_UTF8.PushBack((int8_t)*tmp);
|
||||
_output_UTF8.pushBack((int8_t)*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
_output_UTF8.PushBack('\0');
|
||||
return _output_UTF8.Size()-1;
|
||||
_output_UTF8.pushBack('\0');
|
||||
return _output_UTF8.size()-1;
|
||||
}
|
||||
|
||||
|
||||
@ -179,36 +179,36 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk:
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
while (pos < _input_UTF8.Size()) {
|
||||
int32_t lenMax = _input_UTF8.Size() - pos;
|
||||
while (pos < _input_UTF8.size()) {
|
||||
int32_t lenMax = _input_UTF8.size() - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
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) ) {
|
||||
} 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)) {
|
||||
} 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)) {
|
||||
} 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];
|
||||
@ -220,8 +220,8 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk:
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.setUtf8(tmpData);
|
||||
_output_Unicode.pushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -230,36 +230,36 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, et
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
while (pos < _input_UTF8.Size()) {
|
||||
int32_t lenMax = _input_UTF8.Size() - pos;
|
||||
while (pos < _input_UTF8.size()) {
|
||||
int32_t lenMax = _input_UTF8.size() - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
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) ) {
|
||||
} 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)) {
|
||||
} 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)) {
|
||||
} 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];
|
||||
@ -271,8 +271,8 @@ int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, et
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.setUtf8(tmpData);
|
||||
_output_Unicode.pushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -288,33 +288,33 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniC
|
||||
while (pos < len) {
|
||||
int32_t lenMax = len - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
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) ) {
|
||||
} 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)) {
|
||||
} 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)) {
|
||||
} 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];
|
||||
@ -326,8 +326,8 @@ int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniC
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.setUtf8(tmpData);
|
||||
_output_Unicode.pushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -340,7 +340,7 @@ void unicode::convertIsoToUtf8(charset_te _inputCharset, const char _input_ISO,
|
||||
// concert Iso in UniCode
|
||||
convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode );
|
||||
// convert UniCode in Utf-8
|
||||
tmpUnicode.GetUtf8(_output_UTF8);
|
||||
tmpUnicode.getUtf8(_output_UTF8);
|
||||
}
|
||||
|
||||
|
||||
@ -348,7 +348,7 @@ void unicode::convertUtf8ToIso(charset_te _inputCharset, const char * _input_UTF
|
||||
{
|
||||
uniChar_t tmpUnicode;
|
||||
// convert Utf-8 in UniCode
|
||||
tmpUnicode.SetUtf8(_input_UTF8);
|
||||
tmpUnicode.setUtf8(_input_UTF8);
|
||||
// concert UniCode in Iso
|
||||
convertUnicodeToIso(_inputCharset, tmpUnicode, _output_ISO);
|
||||
}
|
||||
@ -367,7 +367,7 @@ int32_t unicode::convertUtf8ToIso(charset_te _inputCharset, const etk::Vector<ch
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unicode::Utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid)
|
||||
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) {
|
||||
@ -531,7 +531,7 @@ int32_t unicode::strUtf8Len(const char *input_UTF8)
|
||||
uint8_t tmpSize;
|
||||
bool baseValid;
|
||||
while (size > 0) {
|
||||
Utf8_SizeElement(input_UTF8, size , tmpSize, baseValid);
|
||||
utf8_SizeElement(input_UTF8, size , tmpSize, baseValid);
|
||||
input_UTF8 += tmpSize;
|
||||
size -= tmpSize;
|
||||
count++;
|
||||
|
@ -50,7 +50,7 @@ namespace unicode {
|
||||
int32_t convertIsoToUtf8( charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<char>& _output_UTF8);
|
||||
int32_t convertUtf8ToIso( charset_te _inputCharset, const etk::Vector<char>& _input_UTF8, etk::Vector<char>& _output_ISO);
|
||||
|
||||
void Utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid);
|
||||
void utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid);
|
||||
int32_t strUtf8Len(const char *_input_UTF8);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
const uint32_t TableIso8859_1[] = {
|
||||
const uint32_t tableIso8859_1[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -31,7 +31,7 @@ extern "C" {
|
||||
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_2[] = {
|
||||
const uint32_t tableIso8859_2[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -50,7 +50,7 @@ extern "C" {
|
||||
0x00000111, 0x00000144, 0x00000148, 0x000000F3, 0x000000F4, 0x00000151, 0x000000F6, 0x000000F7, 0x00000159, 0x0000016F, 0x000000FA, 0x00000171, 0x000000FC, 0x000000FD, 0x00000163, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_3[] = {
|
||||
const uint32_t tableIso8859_3[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -69,7 +69,7 @@ extern "C" {
|
||||
0x00000000, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x00000121, 0x000000F6, 0x000000F7, 0x0000011D, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x0000016D, 0x0000015D, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_4[] = {
|
||||
const uint32_t tableIso8859_4[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -88,7 +88,7 @@ extern "C" {
|
||||
0x00000111, 0x00000146, 0x0000014D, 0x00000137, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000169, 0x0000016B, 0x000002D9
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_5[] = {
|
||||
const uint32_t tableIso8859_5[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -107,7 +107,7 @@ extern "C" {
|
||||
0x00002116, 0x00000451, 0x00000452, 0x00000453, 0x00000454, 0x00000455, 0x00000456, 0x00000457, 0x00000458, 0x00000459, 0x0000045A, 0x0000045B, 0x0000045C, 0x000000A7, 0x0000045E, 0x0000045F
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_6[] = {
|
||||
const uint32_t tableIso8859_6[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -126,7 +126,7 @@ extern "C" {
|
||||
0x00000650, 0x00000651, 0x00000652, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_7[] = {
|
||||
const uint32_t tableIso8859_7[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -145,7 +145,7 @@ extern "C" {
|
||||
0x000003C0, 0x000003C1, 0x000003C2, 0x000003C3, 0x000003C4, 0x000003C5, 0x000003C6, 0x000003C7, 0x000003C8, 0x000003C9, 0x000003CA, 0x000003CB, 0x000003CC, 0x000003CD, 0x000003CE, 0x00000000
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_8[] = {
|
||||
const uint32_t tableIso8859_8[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -164,7 +164,7 @@ extern "C" {
|
||||
0x000005E0, 0x000005E1, 0x000005E2, 0x000005E3, 0x000005E4, 0x000005E5, 0x000005E6, 0x000005E7, 0x000005E8, 0x000005E9, 0x000005EA, 0x00000000, 0x00000000, 0x0000200E, 0x0000200F, 0x000003C0
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_9[] = {
|
||||
const uint32_t tableIso8859_9[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -183,7 +183,7 @@ extern "C" {
|
||||
0x0000011F, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000131, 0x0000015F, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_10[] = {
|
||||
const uint32_t tableIso8859_10[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -202,7 +202,7 @@ extern "C" {
|
||||
0x000000F0, 0x00000146, 0x0000014D, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00000169, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x00000138
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_11[] = {
|
||||
const uint32_t tableIso8859_11[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -221,7 +221,7 @@ extern "C" {
|
||||
0x00000E50, 0x00000E51, 0x00000E52, 0x00000E53, 0x00000E54, 0x00000E55, 0x00000E56, 0x00000E57, 0x00000E58, 0x00000E59, 0x00000E5A, 0x00000E5B, 0x000006C0, 0x000006C0, 0x000006C0, 0x000006C0
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_13[] = {
|
||||
const uint32_t tableIso8859_13[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -240,7 +240,7 @@ extern "C" {
|
||||
0x00000161, 0x00000144, 0x00000146, 0x000000F3, 0x0000014D, 0x000000F5, 0x000000F6, 0x000000F7, 0x00000173, 0x00000142, 0x0000015B, 0x0000016B, 0x000000FC, 0x0000017C, 0x0000017E, 0x00002019
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_14[] = {
|
||||
const uint32_t tableIso8859_14[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -259,7 +259,7 @@ extern "C" {
|
||||
0x00000175, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00001E6B, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x00000177, 0x000000FF
|
||||
};
|
||||
|
||||
const uint32_t TableIso8859_15[] = {
|
||||
const uint32_t tableIso8859_15[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
|
@ -13,20 +13,20 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern const uint32_t TableIso8859_1[];
|
||||
extern const uint32_t TableIso8859_2[];
|
||||
extern const uint32_t TableIso8859_3[];
|
||||
extern const uint32_t TableIso8859_4[];
|
||||
extern const uint32_t TableIso8859_5[];
|
||||
extern const uint32_t TableIso8859_6[];
|
||||
extern const uint32_t TableIso8859_7[];
|
||||
extern const uint32_t TableIso8859_8[];
|
||||
extern const uint32_t TableIso8859_9[];
|
||||
extern const uint32_t TableIso8859_10[];
|
||||
extern const uint32_t TableIso8859_11[];
|
||||
extern const uint32_t TableIso8859_13[];
|
||||
extern const uint32_t TableIso8859_14[];
|
||||
extern const uint32_t TableIso8859_15[];
|
||||
extern const uint32_t tableIso8859_1[];
|
||||
extern const uint32_t tableIso8859_2[];
|
||||
extern const uint32_t tableIso8859_3[];
|
||||
extern const uint32_t tableIso8859_4[];
|
||||
extern const uint32_t tableIso8859_5[];
|
||||
extern const uint32_t tableIso8859_6[];
|
||||
extern const uint32_t tableIso8859_7[];
|
||||
extern const uint32_t tableIso8859_8[];
|
||||
extern const uint32_t tableIso8859_9[];
|
||||
extern const uint32_t tableIso8859_10[];
|
||||
extern const uint32_t tableIso8859_11[];
|
||||
extern const uint32_t tableIso8859_13[];
|
||||
extern const uint32_t tableIso8859_14[];
|
||||
extern const uint32_t tableIso8859_15[];
|
||||
|
||||
;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user