[DEV] change the buffer nomenclature

This commit is contained in:
Edouard DUPIN 2013-09-19 21:29:48 +02:00
parent bb085be53d
commit 0069f83679
3 changed files with 186 additions and 151 deletions

View File

@ -48,46 +48,46 @@ namespace etk
class Buffer class Buffer
{ {
private: private:
int8_t* m_data; //!< pointer on the curetn table of Data int8_t* m_data; //!< pointer on the curetn table of Data
int32_t m_allocated; //!< Current allocated size int32_t m_allocated; //!< Current allocated size
// empty part of the buffer data // empty part of the buffer data
int32_t m_gapStart; //!< points to the first character of the gap int32_t m_gapStart; //!< points to the first character of the gap
int32_t m_gapEnd; //!< points to the first char after the gap int32_t m_gapEnd; //!< points to the first char after the gap
public: public:
/** /**
* @brief Create an empty vector * @brief Create an empty vector
* @param[in] count Minimum request size of the Buffer * @param[in] _count Minimum request size of the Buffer
*/ */
Buffer(int32_t count = 0) : Buffer(int32_t _count = 0) :
m_data(NULL), m_data(NULL),
m_allocated(0), m_allocated(0),
m_gapStart(0), m_gapStart(0),
m_gapEnd(GAP_SIZE_MIN) m_gapEnd(GAP_SIZE_MIN)
{ {
ChangeAllocation(count+GAP_SIZE_MIN); ChangeAllocation(_count+GAP_SIZE_MIN);
} }
/** /**
* @brief Re-copy constructor (copy all needed data) * @brief Re-copy constructor (copy all needed data)
* @param[in] obj Buffer that might be copy * @param[in] _obj Buffer that might be copy
*/ */
Buffer(const etk::Buffer & obj) : Buffer(const etk::Buffer& _obj) :
m_data(NULL), m_data(NULL),
m_allocated(obj.m_allocated), m_allocated(_obj.m_allocated),
m_gapStart(obj.m_gapStart), m_gapStart(_obj.m_gapStart),
m_gapEnd(obj.m_gapEnd) m_gapEnd(_obj.m_gapEnd)
{ {
// allocate all same data // allocate all same data
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) ); m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
TK_ASSERT(NULL!=m_data, "Error in data allocation"); TK_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ... // Copy all data ...
memcpy(m_data, obj.m_data, m_allocated * sizeof(int8_t) ); memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
} }
/** /**
* @brief Destructor of the current Class * @brief Destructor of the current Class
*/ */
~Buffer(void) ~Buffer(void)
{ {
if (NULL!=m_data) { if (m_data != NULL) {
free(m_data); free(m_data);
} }
m_data = NULL; m_data = NULL;
@ -97,26 +97,29 @@ namespace etk
}; };
/** /**
* @brief Save in the current file open * @brief Save in the current file open
* @param[in,out] myFile pointer on the file where data might be writed * @param[in,out] _file Pointer on the file where data might be writed
* @return true if OK / false if an error occured * @return true if OK / false if an error occured
*/ */
bool DumpIn(etk::FSNode &file) bool DumpIn(etk::FSNode& _file)
{ {
bool ret = true; bool ret = true;
// write Data // write Data
(void)file.FileWrite(m_data, sizeof(int8_t), m_gapStart); (void)_file.FileWrite(m_data, sizeof(int8_t), m_gapStart);
(void)file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd); (void)_file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
return ret; return ret;
} }
/** /**
* @brief Load in the current file open * @brief Load in the current file open
* @param[in,out] myFile pointer on the file where data might be read * @param[in,out] _myFile Pointer on the file where data might be read
* @return true if OK / false if an error occured * @return true if OK / false if an error occured
*/ */
bool DumpFrom(etk::FSNode &file) bool DumpFrom(etk::FSNode& _file)
{ {
if (false == _file.FileOpenRead()) {
return false;
}
bool ret = true; bool ret = true;
uint32_t length = file.FileSize(); uint32_t length = _file.FileSize();
// error case ... // error case ...
if (length > 2000000000) { if (length > 2000000000) {
return false; return false;
@ -124,7 +127,7 @@ namespace etk
// allocate the current buffer : // allocate the current buffer :
ChangeAllocation(length + GAP_SIZE_MIN); ChangeAllocation(length + GAP_SIZE_MIN);
// insert Data // 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); TK_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
// check ERROR // check ERROR
if (nbReadData != length) { if (nbReadData != length) {
@ -134,55 +137,70 @@ namespace etk
// set the gapsize at the end ... // set the gapsize at the end ...
m_gapStart = 0; m_gapStart = 0;
m_gapEnd = GAP_SIZE_MIN; m_gapEnd = GAP_SIZE_MIN;
_file.FileClose();
return ret; return ret;
} }
/** /**
* @brief Re-copy operator * @brief Re-copy operator
* @param[in] obj Buffer that might be copy * @param[in] _obj Buffer that might be copy
* @return reference on the curent re-copy vector * @return reference on the curent re-copy vector
*/ */
etk::Buffer& operator=(const etk::Buffer & obj) etk::Buffer& operator=(const etk::Buffer& _obj)
{ {
if( this != &obj ) // avoid copy to itself if( this != &_obj ) // avoid copy to itself
{ {
if (NULL!=m_data) { if (NULL!=m_data) {
free(m_data); free(m_data);
m_data = NULL; m_data = NULL;
} }
// Set the new value // Set the new value
m_allocated = obj.m_allocated; m_allocated = _obj.m_allocated;
m_gapStart = obj.m_gapStart; m_gapStart = _obj.m_gapStart;
m_gapEnd = obj.m_gapEnd; m_gapEnd = _obj.m_gapEnd;
// allocate all same data // allocate all same data
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) ); m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
TK_ASSERT(NULL!=m_data, "Error in data allocation"); TK_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ... // Copy all data ...
memcpy(m_data, obj.m_data, m_allocated * sizeof(int8_t) ); memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
} }
// Return the curent pointer // Return the curent pointer
return *this; return *this;
} }
/** /**
* @brief Operator [] : Get the data at the requested position (gap abstraction done). * @brief Operator [] : Get the data at the requested position (gap abstraction done).
* @param[in] pos Position in the buffer. * @param[in] _pos Position in the buffer.
* @return Element at the request pos. * @return Element at the request pos.
*/ */
int8_t operator[] (int32_t pos) const 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) { if (_pos < m_gapStart) {
return m_data[pos]; return m_data[_pos];
} }
return m_data[pos + m_gapEnd-m_gapStart]; return m_data[_pos + m_gapEnd-m_gapStart];
} }
/** /**
* @brief Get a current element in the vector * @brief Get a current element in the vector
* @param[in] pos Desired position read * @param[in] _pos Desired position read
* @return Reference on the Element * @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");
if (_pos < m_gapStart) {
return m_data[_pos];
}
return m_data[_pos + m_gapEnd-m_gapStart];
}
#if 0
/**
* @brief Get a current element in the vector
* @param[in] _pos Desired position read
* @return Reference on the Element
*/
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) { if (pos < m_gapStart) {
@ -190,168 +208,169 @@ namespace etk
} }
return m_data[pos + m_gapEnd-m_gapStart]; return m_data[pos + m_gapEnd-m_gapStart];
} }
#endif
/** /**
* @brief Get elements from a specific position. * @brief Get elements from a specific position.
* @param[in] pos Position of the first element. * @param[in] _pos Position of the first element.
* @param[in] nbElement Number of element needed. * @param[in] _nbElement Number of element needed.
* @return The data requested * @return The data requested
*/ */
etk::Vector<int8_t> Get(int32_t pos, int32_t nbElement) etk::Vector<int8_t> Get(int32_t _pos, int32_t _nbElement)
{ {
etk::Vector<int8_t> tmpBuffer; etk::Vector<int8_t> tmpBuffer;
tmpBuffer.Clear(); tmpBuffer.Clear();
if (pos < m_gapStart) { if (_pos < m_gapStart) {
if (pos + nbElement < m_gapStart) { if (pos + _nbElement < m_gapStart) {
tmpBuffer.PushBack(&m_data[pos], nbElement); tmpBuffer.PushBack(&m_data[_pos], _nbElement);
} else { } else {
tmpBuffer.PushBack(&m_data[pos], m_gapStart - pos); tmpBuffer.PushBack(&m_data[_pos], m_gapStart - _pos);
tmpBuffer.PushBack(&m_data[m_gapEnd], nbElement - (m_gapStart - pos) ); tmpBuffer.PushBack(&m_data[m_gapEnd], _nbElement - (m_gapStart - _pos) );
} }
} else { } else {
tmpBuffer.PushBack(&m_data[pos+(m_gapEnd-m_gapStart)], nbElement); tmpBuffer.PushBack(&m_data[_pos+(m_gapEnd-m_gapStart)], _nbElement);
} }
return tmpBuffer; return tmpBuffer;
} }
/** /**
* @brief Add at the Last position of the Vector * @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector * @param[in] _item Element to add at the end of vector
*/ */
void PushBack(const int8_t& item) void PushBack(const int8_t& _item)
{ {
Insert( Size(), item); Insert(Size(), _item);
} }
/** /**
* @brief Insert One item at the specify position. * @brief Insert One item at the specify position.
* @param[in] pos Position where data might be inserted * @param[in] _pos Position where data might be inserted
* @param[in] items Data that might be inserted. * @param[in] _items Data that might be inserted.
*/ */
void Insert(int32_t pos, const int8_t& item) void Insert(int32_t _pos, const int8_t& _item)
{ {
if( pos > Size() if( _pos > Size()
|| pos < 0 ) { || _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; return;
} }
if( 0 == GapSize() ) { if( 0 == GapSize() ) {
if (false == GapResize(pos, GAP_SIZE_MIN + 1) ) { if (false == GapResize(_pos, GAP_SIZE_MIN + 1) ) {
return; return;
} }
} else if( pos == m_gapStart } else if( _pos == m_gapStart
&& pos == m_gapEnd-1 ) && _pos == m_gapEnd-1 )
{ {
// mothing to do ... // mothing to do ...
} else { } else {
if (false == GapMove(pos)) { if (GapMove(_pos) == false) {
return; return;
} }
} }
if(pos == m_gapStart) { if(_pos == m_gapStart) {
m_data[m_gapStart] = item; m_data[m_gapStart] = _item;
m_gapStart++; m_gapStart++;
} else { } else {
m_data[m_gapEnd-1] = item; m_data[m_gapEnd-1] = _item;
m_gapEnd--; m_gapEnd--;
} }
} }
/** /**
* @brief Insert data in the buffer * @brief Insert data in the buffer
* @param[in] pos Position where data might be inserted * @param[in] _pos Position where data might be inserted
* @param[in] items Data that might be inserted. * @param[in] _items Data that might be inserted.
*/ */
void Insert(int32_t pos, etk::Vector<int8_t>& items) void Insert(int32_t _pos, etk::Vector<int8_t>& _items)
{ {
if( pos > Size() if( _pos > Size()
|| pos < 0 ) { || _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; return;
} }
if( items.Size() > GapSize() ) { if( _items.Size() > GapSize() ) {
if (false == GapResize(pos, GAP_SIZE_MIN + items.Size()) ) { if (false == GapResize(_pos, GAP_SIZE_MIN + _items.Size()) ) {
return; return;
} }
} else { } else {
if (false == GapMove(pos) ) { if (false == GapMove(_pos) ) {
return; return;
} }
} }
int32_t i; for(esize_t iii=0; iii<_items.Size(); iii++) {
for(i=0; i<items.Size(); i++) { m_data[m_gapStart+iii] = _items[iii];
m_data[m_gapStart+i] = items[i];
} }
m_gapStart += items.Size(); m_gapStart += _items.Size();
} }
/** /**
* @brief Replace one element in the buffer * @brief Replace one element in the buffer
* @param[in] pos The first element to remove. * @param[in] _pos The first element to remove.
* @param[in] items Data that might be inserted. * @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 ) { || _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; return;
} }
// just replace the element, not update Gap position // just replace the element, not update Gap position
if (pos < m_gapStart) { if (_pos < m_gapStart) {
m_data[pos] = item; m_data[_pos] = _item;
} else { } else {
m_data[pos+GapSize()] = item; m_data[_pos+GapSize()] = _item;
} }
} }
/** /**
* @brief Replace specified data. * @brief Replace specified data.
* @param[in] pos The first element to remove. * @param[in] _pos The first element to remove.
* @param[in] nbRemoveElement number of element to remove. * @param[in] _nbRemoveElement number of element to remove.
* @param[in] items Data that might be inserted. * @param[in] _items Data that might be inserted.
*/ */
void Replace(int32_t pos, int32_t nbRemoveElement, etk::Vector<int8_t>& items) void Replace(int32_t _pos, int32_t _nbRemoveElement, etk::Vector<int8_t>& _items)
{ {
if( pos > Size() if( _pos > Size()
|| pos < 0 ) { || _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; 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()); TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
<< _pos+_nbRemoveElement << " bufferSize=" << Size());
return; return;
} }
if (false == GapMove(pos)) { if (false == GapMove(_pos)) {
return; return;
} }
// Remove elements : // Remove elements :
m_gapEnd += nbRemoveElement; m_gapEnd += _nbRemoveElement;
//Display(); //Display();
// insert elements // insert elements
Insert(pos, items); Insert(_pos, _items);
// Resize buffer if needed... // Resize buffer if needed...
GapCheckMaxSize(); GapCheckMaxSize();
} }
/** /**
* @brief Remove specific data in the buffer. * @brief Remove specific data in the buffer.
* @param[in] pos The first element to remove * @param[in] _pos The first element to remove
* @param[in] nbRemoveElement number of 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 ) { || _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; 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()); TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
<< _pos+_nbRemoveElement << " bufferSize=" << Size());
return; return;
} }
if (false == GapMove(pos) ) { if (GapMove(_pos) == false) {
return; return;
} }
// Remove elements : // Remove elements :
if (m_allocated==m_gapEnd) { if (m_allocated == m_gapEnd) {
m_gapStart -= nbRemoveElement; m_gapStart -= _nbRemoveElement;
} else { } else {
m_gapEnd += nbRemoveElement; m_gapEnd += _nbRemoveElement;
} }
// Resize buffer if needed... // Resize buffer if needed...
GapCheckMaxSize(); GapCheckMaxSize();
@ -374,12 +393,12 @@ namespace etk
} }
/** /**
* @brief Get a current element in the vector (iterator system) * @brief Get a current element in the vector (iterator system)
* @param[in] RealElementPosition Real position in the buffer (only use in the ITERATOR) * @param[in] _realElementPosition Real position in the buffer (only use in the ITERATOR)
* @return Reference on the Element * @return Reference on the Element
*/ */
int8_t& GetDirect(int32_t RealElementPosition) int8_t& GetDirect(int32_t _realElementPosition)
{ {
return m_data[RealElementPosition]; return m_data[_realElementPosition];
}; };
/** /**
* @brief Get the number of element in the vector * @brief Get the number of element in the vector
@ -392,104 +411,104 @@ namespace etk
private: private:
/** /**
* @brief Change the current allocation to the corect one (depend on the current size) * @brief Change the current allocation to the corect one (depend on the current size)
* @param[in] newSize Minimum number of element needed * @param[in] _newSize Minimum number of element needed
*/ */
void ChangeAllocation(int32_t newSize) void ChangeAllocation(int32_t _newSize)
{ {
// set the minimal size to 1 // set the minimal size to 1
if(newSize <= 0) { if(_newSize <= 0) {
newSize = 1; _newSize = 1;
} }
// set the size with the corect chose type : // set the size with the corect chose type :
if (newSize == m_allocated) { if (_newSize == m_allocated) {
return; return;
} }
TK_DEBUG("Change Allocation : " << m_allocated << " ==> " << newSize); TK_DEBUG("Change Allocation : " << m_allocated << " ==> " << _newSize);
// check if something is allocated : // check if something is allocated :
if (NULL == m_data) { if (m_data == NULL) {
// no data allocated ==> request an allocation (might be the first) // no data allocated ==> request an allocation (might be the first)
m_data = (int8_t *)malloc( newSize * sizeof(int8_t) ); m_data = (int8_t *)malloc( _newSize * sizeof(int8_t) );
} else { } else {
// move datas // move datas
m_data = (int8_t *)realloc( m_data, newSize* sizeof(int8_t) ); m_data = (int8_t *)realloc( m_data, _newSize* sizeof(int8_t) );
} }
// Check result with assert : // Check result with assert :
TK_ASSERT(NULL!=m_data, "Error in data allocation"); TK_ASSERT(m_data != NULL, "Error in data allocation");
// set the new allocation size // set the new allocation size
m_allocated = newSize; m_allocated = _newSize;
} }
/** /**
* @brief Move the current gap at an other position * @brief Move the current gap at an other position
* @param[in] pos Position of the new Gap. * @param[in] _pos Position of the new Gap.
* @return false The operation can not be proccesed. * @return false The operation can not be proccesed.
* @return true The operation done correctly. * @return true The operation done correctly.
*/ */
bool GapMove(int32_t pos) bool GapMove(int32_t _pos)
{ {
if( pos > Size() if( _pos > Size()
|| pos < 0 ) { || _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; return false;
} }
int32_t gapLen = m_gapEnd - m_gapStart; int32_t gapLen = m_gapEnd - m_gapStart;
if (pos > m_gapStart) { if (_pos > m_gapStart) {
memmove(&m_data[m_gapStart], &m_data[m_gapEnd], pos - m_gapStart); memmove(&m_data[m_gapStart], &m_data[m_gapEnd], _pos - m_gapStart);
} else { } else {
memmove(&m_data[pos + gapLen], &m_data[pos], m_gapStart - pos); memmove(&m_data[_pos + gapLen], &m_data[_pos], m_gapStart - _pos);
} }
m_gapEnd += pos - m_gapStart; m_gapEnd += _pos - m_gapStart;
m_gapStart += pos - m_gapStart; m_gapStart += _pos - m_gapStart;
return true; return true;
} }
/** /**
* @brief Change The gap position and size * @brief Change The gap position and size
* @param[in] pos Position of the new Gap. * @param[in] _pos Position of the new Gap.
* @param[in] newGapLen Size of the new gap (can be bigger than GAP_SIZE_MAX). * @param[in] _newGapLen Size of the new gap (can be bigger than GAP_SIZE_MAX).
* @return false The operation can not be proccesed. * @return false The operation can not be proccesed.
* @return true The operation done correctly. * @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 ) { || _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; return false;
} }
int32_t previousSize = Size(); int32_t previousSize = Size();
if (newGapLen == GapSize() ) { if (_newGapLen == GapSize() ) {
// nothing to do ... // nothing to do ...
return true; return true;
} else { } else {
if (newGapLen > GapSize() ) { if (_newGapLen > GapSize() ) {
// reallocation // reallocation
ChangeAllocation( previousSize + newGapLen); ChangeAllocation( previousSize + _newGapLen);
} }
// move Data // move Data
if (pos <= m_gapStart) { if (_pos <= m_gapStart) {
// just move the end of the gap // just move the end of the gap
memmove(&m_data[m_gapStart + newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart); memmove(&m_data[m_gapStart + _newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
// update gap end position // update gap end position
m_gapEnd = m_gapStart + newGapLen; m_gapEnd = m_gapStart + _newGapLen;
if (pos < m_gapStart) { if (pos < m_gapStart) {
if (false == GapMove(pos)) { if (false == GapMove(_pos)) {
return false; return false;
} }
} }
// no else // no else
} else { } else {
if (false == GapMove(pos) ) { if (false == GapMove(_pos) ) {
return false; return false;
} }
memmove(&m_data[m_gapStart + newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart); memmove(&m_data[m_gapStart + _newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
} }
if (newGapLen < GapSize() ) { if (_newGapLen < GapSize() ) {
// rellocation // rellocation
ChangeAllocation(previousSize + newGapLen); ChangeAllocation(previousSize + _newGapLen);
} }
} }
// update gap position // update gap position
m_gapStart = pos; m_gapStart = _pos;
m_gapEnd = pos + newGapLen; m_gapEnd = _pos + _newGapLen;
return true; return true;
} }
/** /**

View File

@ -15,6 +15,14 @@
#include <etk/Vector.h> #include <etk/Vector.h>
#include <etk/Char.h> #include <etk/Char.h>
const etk::UniChar etk::UniChar::Return('\n');
const etk::UniChar etk::UniChar::CarrierReturn('\r');
const etk::UniChar etk::UniChar::Tabulation('\t');
const etk::UniChar etk::UniChar::Backspace((const char)8);
const etk::UniChar etk::UniChar::Delete((const char)127);
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' if( m_value>=(uint32_t)'A'

View File

@ -43,6 +43,14 @@ namespace etk
class UniChar class UniChar
{ {
public: // classic unicar code :
static const UniChar Return; //!< '\n'
static const UniChar CarrierReturn; //!< '\r' CR
static const UniChar Tabulation; //!< '\t' TAB
static const UniChar Backspace; //!< BS (SUPPRESS)
static const UniChar Delete; //!< DEL
static const UniChar Space; //!< ' ' SPACE
static const UniChar Escape; //!< ESC Escape
private: private:
uint32_t m_value; uint32_t m_value;
public: public: