[DEV] WORK on a port for BOOST
This commit is contained in:
parent
26ce81aec5
commit
2fb4b79749
543
etk/Buffer.h
543
etk/Buffer.h
@ -1,543 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ETK_BUFFER_H__
|
|
||||||
#define __ETK_BUFFER_H__
|
|
||||||
|
|
||||||
#include <etk/os/FSNode.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "etk::Buffer"
|
|
||||||
|
|
||||||
// minimum gapSize when allocated
|
|
||||||
#define GAP_SIZE_MIN (80)
|
|
||||||
// maximum gap that is automaticly resize
|
|
||||||
#define GAP_SIZE_MAX (GAP_SIZE_MIN*4)
|
|
||||||
|
|
||||||
/*
|
|
||||||
______________________________________________________________________________________
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| <GapStart |
|
|
||||||
| *******************************************************************|
|
|
||||||
|****************************************** |
|
|
||||||
| Gap Stop > |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
|____________________________________________________________________________________|
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace etk {
|
|
||||||
/**
|
|
||||||
* @brief This is an access on raw data that contain an internal gap.
|
|
||||||
* the gap size has an offset to increase an an offset to decrease.
|
|
||||||
*/
|
|
||||||
class Buffer {
|
|
||||||
private:
|
|
||||||
int8_t* m_data; //!< pointer on the curetn table of Data
|
|
||||||
int32_t m_allocated; //!< Current allocated size
|
|
||||||
// empty part of the buffer data
|
|
||||||
int32_t m_gapStart; //!< points to the first character of the gap
|
|
||||||
int32_t m_gapEnd; //!< points to the first char after the gap
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Create an empty vector
|
|
||||||
* @param[in] _count Minimum request size of the Buffer
|
|
||||||
*/
|
|
||||||
Buffer(int32_t _count = 0) :
|
|
||||||
m_data(NULL),
|
|
||||||
m_allocated(0),
|
|
||||||
m_gapStart(0),
|
|
||||||
m_gapEnd(GAP_SIZE_MIN) {
|
|
||||||
changeAllocation(_count+GAP_SIZE_MIN);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Re-copy constructor (copy all needed data)
|
|
||||||
* @param[in] _obj Buffer that might be copy
|
|
||||||
*/
|
|
||||||
Buffer(const etk::Buffer& _obj) :
|
|
||||||
m_data(NULL),
|
|
||||||
m_allocated(_obj.m_allocated),
|
|
||||||
m_gapStart(_obj.m_gapStart),
|
|
||||||
m_gapEnd(_obj.m_gapEnd) {
|
|
||||||
// allocate all same data
|
|
||||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
|
||||||
TK_ASSERT(NULL!=m_data, "Error in data allocation");
|
|
||||||
// Copy all data ...
|
|
||||||
memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Destructor of the current Class
|
|
||||||
*/
|
|
||||||
~Buffer() {
|
|
||||||
if (m_data != NULL) {
|
|
||||||
free(m_data);
|
|
||||||
}
|
|
||||||
m_data = NULL;
|
|
||||||
m_allocated = 0;
|
|
||||||
m_gapStart = 0;
|
|
||||||
m_gapEnd = 0;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @brief Store the selected data in the requested file.
|
|
||||||
* @param[in] _file Name of the file that might be written.
|
|
||||||
* @return true if the data corectly stored
|
|
||||||
* @return false if an error occured
|
|
||||||
*/
|
|
||||||
bool dumpIn(const std::string& _file) {
|
|
||||||
etk::FSNode file(_file);
|
|
||||||
if (false == file.fileOpenWrite()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ret = true;
|
|
||||||
// write Data
|
|
||||||
file.fileWrite(m_data, sizeof(int8_t), m_gapStart);
|
|
||||||
file.fileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
|
||||||
file.fileClose();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Load data fron a selected file name.
|
|
||||||
* @param[in] _file Name of the file to store buffer data.
|
|
||||||
* @return true if the data corectly stored
|
|
||||||
* @return false if an error occured
|
|
||||||
*/
|
|
||||||
bool dumpFrom(const std::string& _file) {
|
|
||||||
etk::FSNode file(_file);
|
|
||||||
if (false == file.fileOpenRead()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ret = true;
|
|
||||||
int64_t length = file.fileSize();
|
|
||||||
// error case ...
|
|
||||||
if (length > 2000000000) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// allocate the current buffer :
|
|
||||||
changeAllocation(length + GAP_SIZE_MIN);
|
|
||||||
// insert Data
|
|
||||||
int32_t nbReadData = file.fileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
|
||||||
TK_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
|
|
||||||
// check ERROR
|
|
||||||
if (nbReadData != length) {
|
|
||||||
TK_ERROR("load data pb : filesize=" << length << ", readData=" << nbReadData);
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
// set the gapsize at the fd ...
|
|
||||||
m_gapStart = 0;
|
|
||||||
m_gapEnd = GAP_SIZE_MIN;
|
|
||||||
file.fileClose();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Re-copy operator
|
|
||||||
* @param[in] _obj Buffer that might be copy
|
|
||||||
* @return reference on the curent copied Buffer
|
|
||||||
*/
|
|
||||||
etk::Buffer& operator=(const etk::Buffer& _obj) {
|
|
||||||
if( this == &_obj ) {// avoid copy to itself
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
if (NULL != m_data) {
|
|
||||||
free(m_data);
|
|
||||||
m_data = NULL;
|
|
||||||
}
|
|
||||||
// Set the new value
|
|
||||||
m_allocated = _obj.m_allocated;
|
|
||||||
m_gapStart = _obj.m_gapStart;
|
|
||||||
m_gapEnd = _obj.m_gapEnd;
|
|
||||||
// allocate all same data
|
|
||||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
|
||||||
TK_ASSERT(NULL!=m_data, "Error in data allocation");
|
|
||||||
// Copy all data ...
|
|
||||||
memcpy(m_data, _obj.m_data, m_allocated * sizeof(int8_t) );
|
|
||||||
// Return the curent pointer
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Get the data at the requested position (gap abstraction done).
|
|
||||||
* @param[in] _pos Position in the buffer.
|
|
||||||
* @return Element at the request pos.
|
|
||||||
*/
|
|
||||||
int8_t operator[] (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];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get a current element in the vector
|
|
||||||
* @param[in] _pos Desired position read
|
|
||||||
* @return Reference on the Element
|
|
||||||
*/
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Get elements from a specific position.
|
|
||||||
* @param[in] _pos Position of the first element.
|
|
||||||
* @param[in] _nbElement Number of element needed.
|
|
||||||
* @return The data requested
|
|
||||||
*/
|
|
||||||
std::vector<int8_t> get(int32_t _pos, int32_t _nbElement) {
|
|
||||||
std::vector<int8_t> tmpBuffer;
|
|
||||||
tmpBuffer.clear();
|
|
||||||
if (_pos < m_gapStart) {
|
|
||||||
if (_pos + _nbElement < m_gapStart) {
|
|
||||||
for (int32_t iii = _pos; iii<_pos+_nbElement; ++iii) {
|
|
||||||
tmpBuffer.push_back(m_data[iii]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int32_t iii = _pos; iii<m_gapStart; ++iii) {
|
|
||||||
tmpBuffer.push_back(m_data[iii]);
|
|
||||||
}
|
|
||||||
for (int32_t iii = m_gapEnd; iii<m_gapEnd - (_nbElement - (m_gapStart - _pos)); ++iii) {
|
|
||||||
tmpBuffer.push_back(m_data[iii]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int32_t iii = _pos+(m_gapEnd-m_gapStart);
|
|
||||||
iii<_pos+(m_gapEnd-m_gapStart)+_nbElement;
|
|
||||||
++iii) {
|
|
||||||
tmpBuffer.push_back(m_data[iii]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tmpBuffer;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Add at the Last position of the Buffer.
|
|
||||||
* @param[in] _item Element to add.
|
|
||||||
*/
|
|
||||||
void push_back(const int8_t& _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) {
|
|
||||||
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) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if( _pos == m_gapStart
|
|
||||||
&& _pos == m_gapEnd-1 )
|
|
||||||
{
|
|
||||||
// mothing to do ...
|
|
||||||
} else {
|
|
||||||
if (gapMove(_pos) == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(_pos == m_gapStart) {
|
|
||||||
m_data[m_gapStart] = _item;
|
|
||||||
m_gapStart++;
|
|
||||||
} else {
|
|
||||||
m_data[m_gapEnd-1] = _item;
|
|
||||||
m_gapEnd--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Insert data in the Buffer.
|
|
||||||
* @param[in] _pos Position where data might be inserted
|
|
||||||
* @param[in] _items Data that might be inserted.
|
|
||||||
*/
|
|
||||||
void insert(int32_t _pos, const std::vector<int8_t>& _items) {
|
|
||||||
insert(_pos, &_items[0], _items.size());
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Insert data in the buffer
|
|
||||||
* @param[in] _pos Position where data might be inserted
|
|
||||||
* @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, const int8_t* _items, int32_t _nbElement) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(_nbElement > gapSize()) {
|
|
||||||
if (false == gapResize(_pos, GAP_SIZE_MIN + _nbElement) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (false == gapMove(_pos) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int32_t iii=0; iii<_nbElement; ++iii) {
|
|
||||||
m_data[m_gapStart+iii] = _items[iii];
|
|
||||||
}
|
|
||||||
m_gapStart += _nbElement;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Replace one element in the buffer with an other.
|
|
||||||
* @param[in] _pos Position of the element to remove.
|
|
||||||
* @param[in] _items Element that might be inserted.
|
|
||||||
*/
|
|
||||||
void replace(int32_t _pos, const int8_t& _item) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Replace a part of the buffer with the specified data.
|
|
||||||
* @param[in] _pos The first element to remove.
|
|
||||||
* @param[in] _nbRemoveElement number of element to remove.
|
|
||||||
* @param[in] _items Data that will be inserted.
|
|
||||||
*/
|
|
||||||
void replace(int32_t _pos, int32_t _nbRemoveElement, const std::vector<int8_t>& _items) {
|
|
||||||
replace(_pos, _nbRemoveElement, &_items[0], _items.size());
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Replace a part of the buffer with the specified data.
|
|
||||||
* @param[in] _pos The first element to remove.
|
|
||||||
* @param[in] _nbRemoveElement number of element to remove.
|
|
||||||
* @param[in] _items Data that might be inserted.
|
|
||||||
* @param[in] _nbElement Number of element that might be added.
|
|
||||||
*/
|
|
||||||
void replace(int32_t _pos, int32_t _nbRemoveElement, const int8_t* _items, int32_t _nbElement) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( _pos+_nbRemoveElement > size() ) {
|
|
||||||
TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
|
|
||||||
<< _pos+_nbRemoveElement << " bufferSize=" << size());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (false == gapMove(_pos)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Remove elements :
|
|
||||||
m_gapEnd += _nbRemoveElement;
|
|
||||||
//Display();
|
|
||||||
// insert elements
|
|
||||||
insert(_pos, _items, _nbElement);
|
|
||||||
// Resize buffer if needed...
|
|
||||||
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) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize="<<size());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( _pos+_nbRemoveElement > size() ) {
|
|
||||||
TK_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="
|
|
||||||
<< _pos+_nbRemoveElement << " bufferSize=" << size());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (gapMove(_pos) == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Remove elements :
|
|
||||||
if (m_allocated == m_gapEnd) {
|
|
||||||
m_gapStart -= _nbRemoveElement;
|
|
||||||
} else {
|
|
||||||
m_gapEnd += _nbRemoveElement;
|
|
||||||
}
|
|
||||||
// Resize buffer if needed...
|
|
||||||
gapCheckMaxSize();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Remove the last element of the Buffer.
|
|
||||||
*/
|
|
||||||
void pop_back() {
|
|
||||||
if (size() > 0) {
|
|
||||||
remove( size() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Remove all the data in the buffer.
|
|
||||||
*/
|
|
||||||
void clear() {
|
|
||||||
remove(0, size() );
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Get a current element in the Buffer (iterator system)
|
|
||||||
* @param[in] _realElementPosition Real position in the buffer (only use in the ITERATOR)
|
|
||||||
* @return Reference on the Element
|
|
||||||
*/
|
|
||||||
int8_t& getDirect(int32_t _realElementPosition) {
|
|
||||||
return m_data[_realElementPosition];
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get the number of element in the vector. This does not contain the gap size.
|
|
||||||
* @return The size of the set data.
|
|
||||||
*/
|
|
||||||
int32_t size() const {
|
|
||||||
return m_allocated - gapSize();
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* @brief Change the current allocation to the new one (depend on the current size)
|
|
||||||
* @param[in] _newSize Minimum number of element needed
|
|
||||||
*/
|
|
||||||
void changeAllocation(int32_t _newSize) {
|
|
||||||
// set the minimal size to 1
|
|
||||||
if(_newSize <= 0) {
|
|
||||||
_newSize = 1;
|
|
||||||
}
|
|
||||||
// set the size with the corect chose type :
|
|
||||||
if (_newSize == m_allocated) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//TODO : use new and delete and multiple of power of 2.
|
|
||||||
TK_DEBUG("Change Allocation : " << m_allocated << " ==> " << _newSize);
|
|
||||||
// check if something is allocated :
|
|
||||||
if (m_data == NULL) {
|
|
||||||
// no data allocated ==> request an allocation (might be the first)
|
|
||||||
m_data = (int8_t *)malloc( _newSize * sizeof(int8_t) );
|
|
||||||
} else {
|
|
||||||
// move datas
|
|
||||||
m_data = (int8_t *)realloc( m_data, _newSize* sizeof(int8_t) );
|
|
||||||
}
|
|
||||||
// Check result with assert :
|
|
||||||
TK_ASSERT(m_data != NULL, "Error in data allocation");
|
|
||||||
// set the new allocation size
|
|
||||||
m_allocated = _newSize;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Move the current gap at an other position
|
|
||||||
* @param[in] _pos Position of the new Gap.
|
|
||||||
* @return false The operation can not be proccesed.
|
|
||||||
* @return true The operation done correctly.
|
|
||||||
*/
|
|
||||||
bool gapMove(int32_t _pos) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << size());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int32_t gapLen = m_gapEnd - m_gapStart;
|
|
||||||
if (_pos > m_gapStart) {
|
|
||||||
memmove(&m_data[m_gapStart], &m_data[m_gapEnd], _pos - m_gapStart);
|
|
||||||
} else {
|
|
||||||
memmove(&m_data[_pos + gapLen], &m_data[_pos], m_gapStart - _pos);
|
|
||||||
}
|
|
||||||
m_gapEnd += _pos - m_gapStart;
|
|
||||||
m_gapStart += _pos - m_gapStart;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Change The gap position and size
|
|
||||||
* @param[in] _pos Position of the new Gap.
|
|
||||||
* @param[in] _newGapLen Size of the new gap (can be bigger than GAP_SIZE_MAX).
|
|
||||||
* @return false The operation can not be done.
|
|
||||||
* @return true The operation done correctly.
|
|
||||||
*/
|
|
||||||
bool gapResize(int32_t _pos, int32_t _newGapLen) {
|
|
||||||
if( _pos > size()
|
|
||||||
|| _pos < 0 ) {
|
|
||||||
TK_ERROR("Request higher than buffer size : pos=" << _pos << " bufferSize=" << size());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int32_t previousSize = size();
|
|
||||||
if (_newGapLen == gapSize() ) {
|
|
||||||
// nothing to do ...
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (_newGapLen > gapSize() ) {
|
|
||||||
// reallocation
|
|
||||||
changeAllocation( previousSize + _newGapLen);
|
|
||||||
}
|
|
||||||
// move Data
|
|
||||||
if (_pos <= m_gapStart) {
|
|
||||||
// just move the end of the gap
|
|
||||||
memmove(&m_data[m_gapStart + _newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
|
|
||||||
// update gap end position
|
|
||||||
m_gapEnd = m_gapStart + _newGapLen;
|
|
||||||
if (_pos < m_gapStart) {
|
|
||||||
if (false == gapMove(_pos)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (false == gapMove(_pos) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memmove(&m_data[m_gapStart + _newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
|
|
||||||
}
|
|
||||||
if (_newGapLen < gapSize() ) {
|
|
||||||
// rellocation
|
|
||||||
changeAllocation(previousSize + _newGapLen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// update gap position
|
|
||||||
m_gapStart = _pos;
|
|
||||||
m_gapEnd = _pos + _newGapLen;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Get the current gap size.
|
|
||||||
* @return The number of element in the gap.
|
|
||||||
*/
|
|
||||||
int32_t gapSize() const {
|
|
||||||
return m_gapEnd - m_gapStart;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Control if the writing gap is not too big (automatic call when resize the buffer).
|
|
||||||
*/
|
|
||||||
void gapCheckMaxSize() {
|
|
||||||
if(gapSize() > GAP_SIZE_MAX) {
|
|
||||||
int32_t currentSize = size();
|
|
||||||
// Change the gap Size
|
|
||||||
if (false == gapResize(m_gapStart, GAP_SIZE_MAX) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// remove deprecated elements at the end of the buffer ...
|
|
||||||
changeAllocation(currentSize + GAP_SIZE_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ NULL
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -385,72 +385,80 @@ template<> template<> Color<uint16_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 1>>(const Color<uint16_t, 1>& _val) {
|
template<> std::string to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint16_t, 1>>(const Color<uint16_t, 1>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint16_t, 1>>(const Color<uint16_t, 1>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
|
|
||||||
template<> bool from_string<Color<uint16_t, 1>>(Color<uint16_t, 1>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint16_t, 1>>(Color<uint16_t, 1>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint16_t, 1>(to_string(_value));
|
_variableRet = Color<uint16_t, 1>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint16_t, 1>>(Color<uint16_t, 1>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint16_t, 1> >(Color<uint16_t, 1>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint16_t, 1>(_value);
|
_variableRet = Color<uint16_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 2>>(const Color<uint16_t, 2>& _val) {
|
template<> std::string to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint16_t, 2>>(const Color<uint16_t, 2>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint16_t, 2>>(const Color<uint16_t, 2>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
|
|
||||||
template<> bool from_string<Color<uint16_t, 2>>(Color<uint16_t, 2>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint16_t, 2>>(Color<uint16_t, 2>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint16_t, 2>(to_string(_value));
|
_variableRet = Color<uint16_t, 2>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint16_t, 2>>(Color<uint16_t, 2>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint16_t, 2> >(Color<uint16_t, 2>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint16_t, 2>(_value);
|
_variableRet = Color<uint16_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 3>>(const Color<uint16_t, 3>& _val) {
|
template<> std::string to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint16_t, 3>>(const Color<uint16_t, 3>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint16_t, 3>>(const Color<uint16_t, 3>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
|
|
||||||
template<> bool from_string<Color<uint16_t, 3>>(Color<uint16_t, 3>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint16_t, 3>>(Color<uint16_t, 3>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint16_t, 3>(to_string(_value));
|
_variableRet = Color<uint16_t, 3>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint16_t, 3>>(Color<uint16_t, 3>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint16_t, 3> >(Color<uint16_t, 3>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint16_t, 3>(_value);
|
_variableRet = Color<uint16_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 4>>(const Color<uint16_t, 4>& _val) {
|
template<> std::string to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint16_t, 4>>(const Color<uint16_t, 4>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint16_t, 4>>(const Color<uint16_t, 4>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
|
|
||||||
template<> bool from_string<Color<uint16_t, 4>>(Color<uint16_t, 4>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint16_t, 4>>(Color<uint16_t, 4>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint16_t, 4>(to_string(_value));
|
_variableRet = Color<uint16_t, 4>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint16_t, 4>>(Color<uint16_t, 4>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint16_t, 4> >(Color<uint16_t, 4>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint16_t, 4>(_value);
|
_variableRet = Color<uint16_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -385,70 +385,74 @@ template<> template<> Color<uint32_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 1>>(const Color<uint32_t, 1>& _val) {
|
template<> std::string to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint32_t, 1>>(const Color<uint32_t, 1>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint32_t, 1>>(const Color<uint32_t, 1>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 1>>(Color<uint32_t, 1>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint32_t, 1>>(Color<uint32_t, 1>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint32_t, 1>(to_string(_value));
|
_variableRet = Color<uint32_t, 1>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 1>>(Color<uint32_t, 1>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint32_t, 1> >(Color<uint32_t, 1>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint32_t, 1>(_value);
|
_variableRet = Color<uint32_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 2>>(const Color<uint32_t, 2>& _val) {
|
template<> std::string to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint32_t, 2>>(const Color<uint32_t, 2>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint32_t, 2>>(const Color<uint32_t, 2>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 2>>(Color<uint32_t, 2>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint32_t, 2>>(Color<uint32_t, 2>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint32_t, 2>(to_string(_value));
|
_variableRet = Color<uint32_t, 2>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 2>>(Color<uint32_t, 2>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint32_t, 2> >(Color<uint32_t, 2>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint32_t, 2>(_value);
|
_variableRet = Color<uint32_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 3>>(const Color<uint32_t, 3>& _val) {
|
template<> std::string to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint32_t, 3>>(const Color<uint32_t, 3>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint32_t, 3>>(const Color<uint32_t, 3>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 3>>(Color<uint32_t, 3>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint32_t, 3>>(Color<uint32_t, 3>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint32_t, 3>(to_string(_value));
|
_variableRet = Color<uint32_t, 3>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 3>>(Color<uint32_t, 3>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint32_t, 3> >(Color<uint32_t, 3>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint32_t, 3>(_value);
|
_variableRet = Color<uint32_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 4>>(const Color<uint32_t, 4>& _val) {
|
template<> std::string to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint32_t, 4>>(const Color<uint32_t, 4>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint32_t, 4>>(const Color<uint32_t, 4>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 4>>(Color<uint32_t, 4>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint32_t, 4>>(Color<uint32_t, 4>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint32_t, 4>(to_string(_value));
|
_variableRet = Color<uint32_t, 4>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint32_t, 4>>(Color<uint32_t, 4>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint32_t, 4> >(Color<uint32_t, 4>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint32_t, 4>(_value);
|
_variableRet = Color<uint32_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -384,18 +384,19 @@ template<> template<> Color<uint8_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
|
|
||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 1>>(const Color<uint8_t, 1>& _val) {
|
template<> std::string to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint8_t, 1>>(const Color<uint8_t, 1>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint8_t, 1>>(const Color<uint8_t, 1>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 1>>(Color<uint8_t, 1>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint8_t, 1>>(Color<uint8_t, 1>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint8_t, 1>(to_string(_value));
|
_variableRet = Color<uint8_t, 1>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 1>>(Color<uint8_t, 1>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint8_t, 1> >(Color<uint8_t, 1>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint8_t, 1>(_value);
|
_variableRet = Color<uint8_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -403,53 +404,56 @@ template<> bool from_string<Color<uint8_t, 1>>(Color<uint8_t, 1>& _variableRet,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 2>>(const Color<uint8_t, 2>& _val) {
|
template<> std::string to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint8_t, 2>>(const Color<uint8_t, 2>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint8_t, 2>>(const Color<uint8_t, 2>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 2>>(Color<uint8_t, 2>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint8_t, 2>>(Color<uint8_t, 2>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint8_t, 2>(to_string(_value));
|
_variableRet = Color<uint8_t, 2>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 2>>(Color<uint8_t, 2>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint8_t, 2> >(Color<uint8_t, 2>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint8_t, 2>(_value);
|
_variableRet = Color<uint8_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 3>>(const Color<uint8_t, 3>& _val) {
|
template<> std::string to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint8_t, 3>>(const Color<uint8_t, 3>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint8_t, 3>>(const Color<uint8_t, 3>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 3>>(Color<uint8_t, 3>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint8_t, 3>>(Color<uint8_t, 3>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint8_t, 3>(to_string(_value));
|
_variableRet = Color<uint8_t, 3>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 3>>(Color<uint8_t, 3>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint8_t, 3> >(Color<uint8_t, 3>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint8_t, 3>(_value);
|
_variableRet = Color<uint8_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 4>>(const Color<uint8_t, 4>& _val) {
|
template<> std::string to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<uint8_t, 4>>(const Color<uint8_t, 4>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<uint8_t, 4>>(const Color<uint8_t, 4>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 4>>(Color<uint8_t, 4>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<uint8_t, 4>>(Color<uint8_t, 4>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<uint8_t, 4>(to_string(_value));
|
_variableRet = Color<uint8_t, 4>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<uint8_t, 4>>(Color<uint8_t, 4>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<uint8_t, 4> >(Color<uint8_t, 4>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<uint8_t, 4>(_value);
|
_variableRet = Color<uint8_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -385,18 +385,19 @@ template<> template<> Color<double,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 1>>(const Color<double, 1>& _val) {
|
template<> std::string to_string<Color<double, 1> >(const Color<double, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<double, 1>>(const Color<double, 1>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<double, 1>>(const Color<double, 1>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<double, 1>(to_string(_value));
|
_variableRet = Color<double, 1>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<double, 1> >(Color<double, 1>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<double, 1>(_value);
|
_variableRet = Color<double, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -404,18 +405,19 @@ template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, co
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 2>>(const Color<double, 2>& _val) {
|
template<> std::string to_string<Color<double, 2> >(const Color<double, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<double, 2>>(const Color<double, 2>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<double, 2>>(const Color<double, 2>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<double, 2>(to_string(_value));
|
_variableRet = Color<double, 2>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<double, 2> >(Color<double, 2>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<double, 2>(_value);
|
_variableRet = Color<double, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -423,36 +425,38 @@ template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, co
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 3>>(const Color<double, 3>& _val) {
|
template<> std::string to_string<Color<double, 3> >(const Color<double, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<double, 3>>(const Color<double, 3>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<double, 3>>(const Color<double, 3>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<double, 3>(to_string(_value));
|
_variableRet = Color<double, 3>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<double, 3> >(Color<double, 3>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<double, 3>(_value);
|
_variableRet = Color<double, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 4>>(const Color<double, 4>& _val) {
|
template<> std::string to_string<Color<double, 4> >(const Color<double, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<double, 4>>(const Color<double, 4>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<double, 4>>(const Color<double, 4>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<double, 4>(to_string(_value));
|
_variableRet = Color<double, 4>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<double, 4> >(Color<double, 4>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<double, 4>(_value);
|
_variableRet = Color<double, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -383,69 +383,73 @@ template<> template<> Color<float,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 1>>(const Color<float, 1>& _val) {
|
template<> std::string to_string<Color<float, 1> >(const Color<float, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<float, 1>>(const Color<float, 1>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<float, 1>>(const Color<float, 1>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<float, 1>(to_string(_value));
|
_variableRet = Color<float, 1>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<float, 1> >(Color<float, 1>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<float, 1>(_value);
|
_variableRet = Color<float, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 2>>(const Color<float, 2>& _val) {
|
template<> std::string to_string<Color<float, 2> >(const Color<float, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<float, 2>>(const Color<float, 2>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<float, 2>>(const Color<float, 2>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<float, 2>(to_string(_value));
|
_variableRet = Color<float, 2>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<float, 2> >(Color<float, 2>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<float, 2>(_value);
|
_variableRet = Color<float, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 3>>(const Color<float, 3>& _val) {
|
template<> std::string to_string<Color<float, 3> >(const Color<float, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<float, 3>>(const Color<float, 3>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<float, 3>>(const Color<float, 3>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<float, 3>(to_string(_value));
|
_variableRet = Color<float, 3>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<float, 3> >(Color<float, 3>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<float, 3>(_value);
|
_variableRet = Color<float, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 4>>(const Color<float, 4>& _val) {
|
template<> std::string to_string<Color<float, 4> >(const Color<float, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<Color<float, 4>>(const Color<float, 4>& _val) {
|
#if __cplusplus >= 201103L
|
||||||
return to_u32string(_val.getString());
|
template<> std::u32string to_u32string<Color<float, 4>>(const Color<float, 4>& _val) {
|
||||||
}
|
return to_u32string(_val.getString());
|
||||||
|
}
|
||||||
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = Color<float, 4>(to_string(_value));
|
_variableRet = Color<float, 4>(to_string(_value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::string& _value) {
|
#endif
|
||||||
|
template<> bool from_string<Color<float, 4> >(Color<float, 4>& _variableRet, const std::string& _value) {
|
||||||
_variableRet = Color<float, 4>(_value);
|
_variableRet = Color<float, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#ifdef ETK_BUILD_MINIZIP
|
||||||
|
|
||||||
#include <etk/archive/Archive.h>
|
#include <etk/archive/Archive.h>
|
||||||
#include <etk/archive/Zip.h>
|
#include <etk/archive/Zip.h>
|
||||||
@ -100,3 +101,5 @@ void etk::Archive::close(const std::string& _key) {
|
|||||||
it->second.decreaseRef();
|
it->second.decreaseRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
#ifdef ETK_BUILD_MINIZIP
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
|
|
||||||
@ -139,3 +140,4 @@ namespace etk {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -6,25 +6,11 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef ETK_BUILD_MINIZIP
|
||||||
|
|
||||||
#include <etk/archive/Zip.h>
|
#include <etk/archive/Zip.h>
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
|
|
||||||
#ifndef ETK_BUILD_MINIZIP
|
|
||||||
etk::archive::Zip::Zip(const std::string& _fileName) :
|
|
||||||
etk::Archive(_fileName) {
|
|
||||||
TK_WARNING("No archive interface (not compiled with) minizip lib");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::archive::Zip::~Zip() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void etk::archive::Zip::loadFile(const std::map<std::string, Content>::iterator& it) {
|
|
||||||
TK_ERROR("Can not load File with no Archive interface");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
etk::archive::Zip::Zip(const std::string& _fileName) :
|
etk::archive::Zip::Zip(const std::string& _fileName) :
|
||||||
etk::Archive(_fileName),
|
etk::Archive(_fileName),
|
||||||
m_ctx(nullptr) {
|
m_ctx(nullptr) {
|
||||||
|
@ -14,24 +14,22 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include <minizip/unzip.h>
|
#include <minizip/unzip.h>
|
||||||
}
|
}
|
||||||
#endif
|
namespace etk {
|
||||||
|
namespace archive {
|
||||||
namespace etk {
|
class Zip : public etk::Archive {
|
||||||
namespace archive {
|
|
||||||
class Zip : public etk::Archive {
|
|
||||||
#ifdef ETK_BUILD_MINIZIP
|
|
||||||
private:
|
private:
|
||||||
unzFile m_ctx; //!< mini zip context
|
unzFile m_ctx; //!< mini zip context
|
||||||
unz_global_info m_info; //!< global information of the Zip
|
unz_global_info m_info; //!< global information of the Zip
|
||||||
#endif
|
public:
|
||||||
public:
|
Zip(const std::string& _fileName);
|
||||||
Zip(const std::string& _fileName);
|
virtual ~Zip();
|
||||||
virtual ~Zip();
|
protected: // herited functions :
|
||||||
protected: // herited functions :
|
virtual void loadFile(const std::map<std::string, Content>::iterator& it);
|
||||||
virtual void loadFile(const std::map<std::string, Content>::iterator& it);
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
7
etk/boost_to_std/etk/chrono.h
Normal file
7
etk/boost_to_std/etk/chrono.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_CHRONO_FROM_BOOST_H__
|
||||||
|
#define __ETK_CHRONO_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/chrono.hpp>
|
||||||
|
|
||||||
|
#endif
|
7
etk/boost_to_std/etk/condition_variable.h
Normal file
7
etk/boost_to_std/etk/condition_variable.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_CONDITION_VARIABLE_FROM_BOOST_H__
|
||||||
|
#define __ETK_CONDITION_VARIABLE_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/thread/condition_variable.hpp>
|
||||||
|
|
||||||
|
#endif
|
10
etk/boost_to_std/etk/functional.h
Normal file
10
etk/boost_to_std/etk/functional.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_FUNCTIONNAL_FROM_BOOST_H__
|
||||||
|
#define __ETK_FUNCTIONNAL_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/bind/placeholders.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
11
etk/boost_to_std/etk/memory.h
Normal file
11
etk/boost_to_std/etk/memory.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_MEMORY_FROM_BOOST_H__
|
||||||
|
#define __ETK_MEMORY_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/weak_ptr.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
8
etk/boost_to_std/etk/mutex.h
Normal file
8
etk/boost_to_std/etk/mutex.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_MUTEX_FROM_BOOST_H__
|
||||||
|
#define __ETK_MUTEX_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
|
|
||||||
|
#endif
|
7
etk/boost_to_std/etk/thread.h
Normal file
7
etk/boost_to_std/etk/thread.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef __ETK_THREAD_FROM_BOOST_H__
|
||||||
|
#define __ETK_THREAD_FROM_BOOST_H__
|
||||||
|
|
||||||
|
#include <boost/thread/thread.hpp>
|
||||||
|
|
||||||
|
#endif
|
148
etk/log.cpp
148
etk/log.cpp
@ -8,8 +8,12 @@
|
|||||||
|
|
||||||
#include <etk/log.h>
|
#include <etk/log.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <mutex>
|
#if __cplusplus >= 201103L
|
||||||
#include <thread>
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
#else
|
||||||
|
#include <etk/mutex.h>
|
||||||
|
#endif
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
@ -89,8 +93,8 @@ int32_t& getsizeLog() {
|
|||||||
static int32_t g_val = 5;
|
static int32_t g_val = 5;
|
||||||
return g_val;
|
return g_val;
|
||||||
}
|
}
|
||||||
static std::vector<std::pair<std::string, enum etk::log::level>>& getList() {
|
static std::vector<std::pair<std::string, enum etk::log::level> >& getList() {
|
||||||
static std::vector<std::pair<std::string, enum etk::log::level>> g_val;
|
static std::vector<std::pair<std::string, enum etk::log::level> > g_val;
|
||||||
return g_val;
|
return g_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,52 +228,62 @@ static std::map<uint32_t, std::string>& getThreadList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string etk::log::getThreadName() {
|
std::string etk::log::getThreadName() {
|
||||||
std::map<uint32_t,std::string>& list = getThreadList();
|
#if __cplusplus >= 201103L
|
||||||
uint32_t threadID = getThreadID();
|
std::map<uint32_t,std::string>& list = getThreadList();
|
||||||
std::string out;
|
uint32_t threadID = getThreadID();
|
||||||
static std::mutex g_lock;
|
std::string out;
|
||||||
g_lock.lock();
|
static std11::mutex g_lock;
|
||||||
auto it = list.find(threadID);
|
g_lock.lock();
|
||||||
if (it != list.end()) {
|
auto it = list.find(threadID);
|
||||||
out = it->second;
|
if (it != list.end()) {
|
||||||
}
|
out = it->second;
|
||||||
g_lock.unlock();
|
}
|
||||||
return out;
|
g_lock.unlock();
|
||||||
|
return out;
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::log::setThreadName(const std::string& _name) {
|
void etk::log::setThreadName(const std::string& _name) {
|
||||||
std::map<uint32_t,std::string>& list = getThreadList();
|
#if __cplusplus >= 201103L
|
||||||
uint32_t threadID = getThreadID();
|
std::map<uint32_t,std::string>& list = getThreadList();
|
||||||
static std::mutex g_lock;
|
uint32_t threadID = getThreadID();
|
||||||
g_lock.lock();
|
static std11::mutex g_lock;
|
||||||
auto it = list.find(threadID);
|
g_lock.lock();-Wc++0x-compat
|
||||||
if (it == list.end()) {
|
auto it = list.find(threadID);
|
||||||
list.insert(std::pair<uint32_t, std::string>(threadID,_name));
|
if (it == list.end()) {
|
||||||
} else {
|
list.insert(std::pair<uint32_t, std::string>(threadID,_name));
|
||||||
it->second = _name;
|
} else {
|
||||||
}
|
it->second = _name;
|
||||||
g_lock.unlock();
|
}
|
||||||
|
g_lock.unlock();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t etk::log::getThreadID() {
|
uint32_t etk::log::getThreadID() {
|
||||||
uint32_t out = 0;
|
#if __cplusplus >= 201103L
|
||||||
std::thread::id this_id = std::this_thread::get_id();
|
uint32_t out = 0;
|
||||||
uint64_t iddd = std::hash<std::thread::id>()(this_id);
|
std::thread::id this_id = std::this_thread::get_id();
|
||||||
static std::mutex g_lock;
|
uint64_t iddd = std::hash<std::thread::id>()(this_id);
|
||||||
g_lock.lock();
|
static std11::mutex g_lock;
|
||||||
static std::map<uint64_t, uint32_t> g_list;
|
g_lock.lock();
|
||||||
auto it = g_list.find(iddd);
|
static std::map<uint64_t, uint32_t> g_list;
|
||||||
if (it == g_list.end()) {
|
auto it = g_list.find(iddd);
|
||||||
// attribute new ID :
|
if (it == g_list.end()) {
|
||||||
static uint32_t tmpId = 0;
|
// attribute new ID :
|
||||||
g_list.insert(std::pair<uint64_t, uint32_t>(iddd,tmpId));
|
static uint32_t tmpId = 0;
|
||||||
out = tmpId;
|
g_list.insert(std::pair<uint64_t, uint32_t>(iddd,tmpId));
|
||||||
tmpId++;
|
out = tmpId;
|
||||||
} else {
|
tmpId++;
|
||||||
out = it->second;
|
} else {
|
||||||
}
|
out = it->second;
|
||||||
g_lock.unlock();
|
}
|
||||||
return out;
|
g_lock.unlock();
|
||||||
|
return out;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getDisplayTime(char* data) {
|
static void getDisplayTime(char* data) {
|
||||||
@ -320,7 +334,7 @@ static void getDisplayTime(char* data) {
|
|||||||
|
|
||||||
|
|
||||||
void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log) {
|
void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log) {
|
||||||
static std::mutex g_lock;
|
static std11::mutex g_lock;
|
||||||
char handle[1024] = "";
|
char handle[1024] = "";
|
||||||
memset(handle, ' ', 1024);
|
memset(handle, ' ', 1024);
|
||||||
handle[0] = '\0';
|
handle[0] = '\0';
|
||||||
@ -393,30 +407,32 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
|
|||||||
*pointer++ = ' ';
|
*pointer++ = ' ';
|
||||||
*pointer = '\0';
|
*pointer = '\0';
|
||||||
}
|
}
|
||||||
if(getThreadId() == true) {
|
#if __cplusplus >= 201103L
|
||||||
// display thread ID
|
if(getThreadId() == true) {
|
||||||
uint32_t iddd = etk::log::getThreadID();
|
// display thread ID
|
||||||
sprintf(pointer, "%3d", iddd);
|
uint32_t iddd = etk::log::getThreadID();
|
||||||
pointer = handle+strlen(handle);
|
sprintf(pointer, "%3d", iddd);
|
||||||
*pointer++ = ' ';
|
pointer = handle+strlen(handle);
|
||||||
*pointer++ = '|';
|
*pointer++ = ' ';
|
||||||
*pointer++ = ' ';
|
*pointer++ = '|';
|
||||||
*pointer = '\0';
|
|
||||||
}
|
|
||||||
if(getThreadNameEnable() == true) {
|
|
||||||
// display thread ID
|
|
||||||
std::string name = etk::log::getThreadName();
|
|
||||||
int32_t len = strlen(handle);
|
|
||||||
snprintf(pointer, 20, "%s", name.c_str());
|
|
||||||
pointer = handle+strlen(handle);
|
|
||||||
while (strlen(handle) - len < 20) {
|
|
||||||
*pointer++ = ' ';
|
*pointer++ = ' ';
|
||||||
*pointer = '\0';
|
*pointer = '\0';
|
||||||
}
|
}
|
||||||
*pointer++ = '|';
|
if(getThreadNameEnable() == true) {
|
||||||
*pointer++ = ' ';
|
// display thread ID
|
||||||
*pointer = '\0';
|
std::string name = etk::log::getThreadName();
|
||||||
}
|
int32_t len = strlen(handle);
|
||||||
|
snprintf(pointer, 20, "%s", name.c_str());
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
while (strlen(handle) - len < 20) {
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
*pointer++ = '|';
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(getLine() == true) {
|
if(getLine() == true) {
|
||||||
if (_ligne >= 0) {
|
if (_ligne >= 0) {
|
||||||
sprintf(pointer, "(l=%5d)", _ligne);
|
sprintf(pointer, "(l=%5d)", _ligne);
|
||||||
|
@ -87,7 +87,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector<bvec2 >& _ob
|
|||||||
|
|
||||||
vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) {
|
vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) {
|
||||||
vec2 out = _val;
|
vec2 out = _val;
|
||||||
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs))
|
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs) || __cplusplus < 201103L)
|
||||||
float sinAngle = sin(_angle);
|
float sinAngle = sin(_angle);
|
||||||
float cosAngle = cos(_angle);
|
float cosAngle = cos(_angle);
|
||||||
#else
|
#else
|
||||||
@ -118,15 +118,17 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> Vector2D<bool>::operator std::u32string() const {
|
#if __cplusplus >= 201103L
|
||||||
std::u32string str;
|
template<> Vector2D<bool>::operator std::u32string() const {
|
||||||
str = U"(";
|
std::u32string str;
|
||||||
str += etk::to_u32string(x());
|
str = U"(";
|
||||||
str += U",";
|
str += etk::to_u32string(x());
|
||||||
str += etk::to_u32string(y());
|
str += U",";
|
||||||
str += U")";
|
str += etk::to_u32string(y());
|
||||||
return str;
|
str += U")";
|
||||||
}
|
return str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> Vector2D<bool>::Vector2D(const std::string& _str) {
|
template<> Vector2D<bool>::Vector2D(const std::string& _str) {
|
||||||
m_floats[0] = false;
|
m_floats[0] = false;
|
||||||
@ -152,30 +154,32 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
||||||
}
|
}
|
||||||
template<> Vector2D<bool>::Vector2D(const std::u32string& _str) {
|
#if __cplusplus >= 201103L
|
||||||
m_floats[0] = false;
|
template<> Vector2D<bool>::Vector2D(const std::u32string& _str) {
|
||||||
m_floats[1] = false;
|
m_floats[0] = false;
|
||||||
// copy to permit to modify it :
|
m_floats[1] = false;
|
||||||
std::u32string tmpStr = _str;
|
// copy to permit to modify it :
|
||||||
if (tmpStr[0] == '(') {
|
std::u32string tmpStr = _str;
|
||||||
tmpStr.erase(tmpStr.begin());
|
if (tmpStr[0] == '(') {
|
||||||
|
tmpStr.erase(tmpStr.begin());
|
||||||
|
}
|
||||||
|
if (tmpStr[tmpStr.size()-1] == ')') {
|
||||||
|
tmpStr.erase(tmpStr.end()-1);
|
||||||
|
}
|
||||||
|
size_t posComa = tmpStr.find(',');
|
||||||
|
if (posComa == std::string::npos) {
|
||||||
|
// no coma ...
|
||||||
|
// in every case, we parse the first element :
|
||||||
|
m_floats[0] = etk::string_to_bool(tmpStr);
|
||||||
|
m_floats[1] = m_floats[0];
|
||||||
|
} else {
|
||||||
|
m_floats[0] = etk::string_to_bool(std::u32string(tmpStr, 0, posComa));
|
||||||
|
tmpStr.erase(0, posComa+1);
|
||||||
|
m_floats[1] = etk::string_to_bool(tmpStr);
|
||||||
|
}
|
||||||
|
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
||||||
}
|
}
|
||||||
if (tmpStr[tmpStr.size()-1] == ')') {
|
#endif
|
||||||
tmpStr.erase(tmpStr.end()-1);
|
|
||||||
}
|
|
||||||
size_t posComa = tmpStr.find(',');
|
|
||||||
if (posComa == std::string::npos) {
|
|
||||||
// no coma ...
|
|
||||||
// in every case, we parse the first element :
|
|
||||||
m_floats[0] = etk::string_to_bool(tmpStr);
|
|
||||||
m_floats[1] = m_floats[0];
|
|
||||||
} else {
|
|
||||||
m_floats[0] = etk::string_to_bool(std::u32string(tmpStr, 0, posComa));
|
|
||||||
tmpStr.erase(0, posComa+1);
|
|
||||||
m_floats[1] = etk::string_to_bool(tmpStr);
|
|
||||||
}
|
|
||||||
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> Vector2D<int32_t>::operator std::string() const {
|
template<> Vector2D<int32_t>::operator std::string() const {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -186,15 +190,17 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> Vector2D<int32_t>::operator std::u32string() const {
|
#if __cplusplus >= 201103L
|
||||||
std::u32string str;
|
template<> Vector2D<int32_t>::operator std::u32string() const {
|
||||||
str = U"(";
|
std::u32string str;
|
||||||
str += etk::to_u32string(x());
|
str = U"(";
|
||||||
str += U",";
|
str += etk::to_u32string(x());
|
||||||
str += etk::to_u32string(y());
|
str += U",";
|
||||||
str += U")";
|
str += etk::to_u32string(y());
|
||||||
return str;
|
str += U")";
|
||||||
}
|
return str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> Vector2D<int32_t>::Vector2D(const std::string& _str) {
|
template<> Vector2D<int32_t>::Vector2D(const std::string& _str) {
|
||||||
m_floats[0] = 0;
|
m_floats[0] = 0;
|
||||||
@ -221,31 +227,33 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
template<> Vector2D<int32_t>::Vector2D(const std::u32string& _str) {
|
#if __cplusplus >= 201103L
|
||||||
m_floats[0] = 0;
|
template<> Vector2D<int32_t>::Vector2D(const std::u32string& _str) {
|
||||||
m_floats[1] = 0;
|
m_floats[0] = 0;
|
||||||
// copy to permit to modify it :
|
m_floats[1] = 0;
|
||||||
std::u32string tmpStr = _str;
|
// copy to permit to modify it :
|
||||||
if (tmpStr[0] == '(') {
|
std::u32string tmpStr = _str;
|
||||||
tmpStr.erase(tmpStr.begin());
|
if (tmpStr[0] == '(') {
|
||||||
}
|
tmpStr.erase(tmpStr.begin());
|
||||||
if (tmpStr[tmpStr.size()-1] == ')') {
|
}
|
||||||
tmpStr.erase(tmpStr.end()-1);
|
if (tmpStr[tmpStr.size()-1] == ')') {
|
||||||
}
|
tmpStr.erase(tmpStr.end()-1);
|
||||||
|
}
|
||||||
|
|
||||||
size_t posComa = tmpStr.find(',');
|
size_t posComa = tmpStr.find(',');
|
||||||
if (posComa == 0) {
|
if (posComa == 0) {
|
||||||
// no coma ...
|
// no coma ...
|
||||||
// in every case, we parse the first element :
|
// in every case, we parse the first element :
|
||||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||||
m_floats[1] = m_floats[0];
|
m_floats[1] = m_floats[0];
|
||||||
} else {
|
} else {
|
||||||
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
||||||
tmpStr.erase(0,posComa+1);
|
tmpStr.erase(0,posComa+1);
|
||||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||||
|
}
|
||||||
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
template<> Vector2D<uint32_t>::operator std::string() const {
|
template<> Vector2D<uint32_t>::operator std::string() const {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -256,16 +264,17 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
template<> Vector2D<uint32_t>::operator std::u32string() const {
|
template<> Vector2D<uint32_t>::operator std::u32string() const {
|
||||||
std::u32string str;
|
std::u32string str;
|
||||||
str = U"(";
|
str = U"(";
|
||||||
str += etk::to_u32string(x());
|
str += etk::to_u32string(x());
|
||||||
str += U",";
|
str += U",";
|
||||||
str += etk::to_u32string(y());
|
str += etk::to_u32string(y());
|
||||||
str += U")";
|
str += U")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> Vector2D<uint32_t>::Vector2D(const std::string& _str) {
|
template<> Vector2D<uint32_t>::Vector2D(const std::string& _str) {
|
||||||
m_floats[0] = 0;
|
m_floats[0] = 0;
|
||||||
@ -291,31 +300,32 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
template<> Vector2D<uint32_t>::Vector2D(const std::u32string& _str)
|
#if __cplusplus >= 201103L
|
||||||
{
|
template<> Vector2D<uint32_t>::Vector2D(const std::u32string& _str) {
|
||||||
m_floats[0] = 0;
|
m_floats[0] = 0;
|
||||||
m_floats[1] = 0;
|
m_floats[1] = 0;
|
||||||
// copy to permit to modify it :
|
// copy to permit to modify it :
|
||||||
std::u32string tmpStr = _str;
|
std::u32string tmpStr = _str;
|
||||||
if (tmpStr[0] == '(') {
|
if (tmpStr[0] == '(') {
|
||||||
tmpStr.erase(tmpStr.begin());
|
tmpStr.erase(tmpStr.begin());
|
||||||
|
}
|
||||||
|
if (tmpStr[tmpStr.size()-1] == ')') {
|
||||||
|
tmpStr.erase(tmpStr.end()-1);
|
||||||
|
}
|
||||||
|
size_t posComa = tmpStr.find(',');
|
||||||
|
if (posComa == std::string::npos) {
|
||||||
|
// no coma ...
|
||||||
|
// in every case, we parse the first element :
|
||||||
|
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||||
|
m_floats[1] = m_floats[0];
|
||||||
|
} else {
|
||||||
|
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
||||||
|
tmpStr.erase(0,posComa+1);
|
||||||
|
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||||
|
}
|
||||||
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
if (tmpStr[tmpStr.size()-1] == ')') {
|
#endif
|
||||||
tmpStr.erase(tmpStr.end()-1);
|
|
||||||
}
|
|
||||||
size_t posComa = tmpStr.find(',');
|
|
||||||
if (posComa == std::string::npos) {
|
|
||||||
// no coma ...
|
|
||||||
// in every case, we parse the first element :
|
|
||||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
|
||||||
m_floats[1] = m_floats[0];
|
|
||||||
} else {
|
|
||||||
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
|
||||||
tmpStr.erase(0,posComa+1);
|
|
||||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
|
||||||
}
|
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> Vector2D<float>::operator std::string() const {
|
template<> Vector2D<float>::operator std::string() const {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -326,15 +336,17 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> Vector2D<float>::operator std::u32string() const {
|
#if __cplusplus >= 201103L
|
||||||
std::u32string str;
|
template<> Vector2D<float>::operator std::u32string() const {
|
||||||
str = U"(";
|
std::u32string str;
|
||||||
str += etk::to_u32string(x());
|
str = U"(";
|
||||||
str += U",";
|
str += etk::to_u32string(x());
|
||||||
str += etk::to_u32string(y());
|
str += U",";
|
||||||
str += U")";
|
str += etk::to_u32string(y());
|
||||||
return str;
|
str += U")";
|
||||||
}
|
return str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> Vector2D<float>::Vector2D(const std::string& _str) {
|
template<> Vector2D<float>::Vector2D(const std::string& _str) {
|
||||||
m_floats[0] = 0;
|
m_floats[0] = 0;
|
||||||
@ -360,30 +372,32 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
template<> Vector2D<float>::Vector2D(const std::u32string& _str) {
|
#if __cplusplus >= 201103L
|
||||||
m_floats[0] = 0;
|
template<> Vector2D<float>::Vector2D(const std::u32string& _str) {
|
||||||
m_floats[1] = 0;
|
m_floats[0] = 0;
|
||||||
// copy to permit to modify it :
|
m_floats[1] = 0;
|
||||||
std::u32string tmpStr = _str;
|
// copy to permit to modify it :
|
||||||
if (tmpStr[0] == '(') {
|
std::u32string tmpStr = _str;
|
||||||
tmpStr.erase(tmpStr.begin());
|
if (tmpStr[0] == '(') {
|
||||||
|
tmpStr.erase(tmpStr.begin());
|
||||||
|
}
|
||||||
|
if (tmpStr[tmpStr.size()-1] == ')') {
|
||||||
|
tmpStr.erase(tmpStr.end()-1);
|
||||||
|
}
|
||||||
|
size_t posComa = tmpStr.find(',');
|
||||||
|
if (posComa == std::string::npos) {
|
||||||
|
// no coma ...
|
||||||
|
// in every case, we parse the first element :
|
||||||
|
m_floats[0] = etk::string_to_float(tmpStr);
|
||||||
|
m_floats[1] = m_floats[0];
|
||||||
|
} else {
|
||||||
|
m_floats[0] = etk::string_to_float(std::u32string(tmpStr, 0, posComa));
|
||||||
|
tmpStr.erase(0,posComa+1);
|
||||||
|
m_floats[1] = etk::string_to_float(tmpStr);
|
||||||
|
}
|
||||||
|
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||||
}
|
}
|
||||||
if (tmpStr[tmpStr.size()-1] == ')') {
|
#endif
|
||||||
tmpStr.erase(tmpStr.end()-1);
|
|
||||||
}
|
|
||||||
size_t posComa = tmpStr.find(',');
|
|
||||||
if (posComa == std::string::npos) {
|
|
||||||
// no coma ...
|
|
||||||
// in every case, we parse the first element :
|
|
||||||
m_floats[0] = etk::string_to_float(tmpStr);
|
|
||||||
m_floats[1] = m_floats[0];
|
|
||||||
} else {
|
|
||||||
m_floats[0] = etk::string_to_float(std::u32string(tmpStr, 0, posComa));
|
|
||||||
tmpStr.erase(0,posComa+1);
|
|
||||||
m_floats[1] = etk::string_to_float(tmpStr);
|
|
||||||
}
|
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> std::string to_string<vec2>(const vec2& _obj) {
|
template<> std::string to_string<vec2>(const vec2& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -394,9 +408,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<vec2>(const vec2& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<vec2>(const vec2& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<ivec2>(const ivec2& _obj) {
|
template<> std::string to_string<ivec2>(const ivec2& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -407,9 +423,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<ivec2>(const ivec2& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<ivec2>(const ivec2& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<uivec2>(const uivec2& _obj) {
|
template<> std::string to_string<uivec2>(const uivec2& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -420,9 +438,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<uivec2>(const uivec2& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<uivec2>(const uivec2& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<bvec2>(const bvec2& _obj) {
|
template<> std::string to_string<bvec2>(const bvec2& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -433,39 +453,49 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<bvec2>(const bvec2& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<bvec2>(const bvec2& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<vec2>(vec2& _variableRet, const std::string& _value) {
|
template<> bool from_string<vec2>(vec2& _variableRet, const std::string& _value) {
|
||||||
_variableRet = vec2(_value);
|
_variableRet = vec2(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::string& _value) {
|
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::string& _value) {
|
||||||
_variableRet = ivec2(_value);
|
_variableRet = ivec2(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::string& _value) {
|
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::string& _value) {
|
||||||
_variableRet = uivec2(_value);
|
_variableRet = uivec2(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::string& _value) {
|
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::string& _value) {
|
||||||
_variableRet = bvec2(_value);
|
_variableRet = bvec2(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -48,7 +48,9 @@ namespace etk {
|
|||||||
m_floats[1] = (T)_obj.y();
|
m_floats[1] = (T)_obj.y();
|
||||||
};
|
};
|
||||||
Vector2D(const std::string& _str);
|
Vector2D(const std::string& _str);
|
||||||
Vector2D(const std::u32string& _str);
|
#if __cplusplus >= 201103L
|
||||||
|
Vector2D(const std::u32string& _str);
|
||||||
|
#endif
|
||||||
~Vector2D() { };
|
~Vector2D() { };
|
||||||
/* ****************************************************
|
/* ****************************************************
|
||||||
* = assigment
|
* = assigment
|
||||||
@ -371,7 +373,9 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
//!< string cast :
|
//!< string cast :
|
||||||
operator std::string() const;
|
operator std::string() const;
|
||||||
operator std::u32string() const;
|
#if __cplusplus >= 201103L
|
||||||
|
operator std::u32string() const;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
|
@ -124,9 +124,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<vec3>(const vec3& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<vec3>(const vec3& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<ivec3>(const ivec3& _obj) {
|
template<> std::string to_string<ivec3>(const ivec3& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -139,9 +141,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<ivec3>(const ivec3& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<ivec3>(const ivec3& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<uivec3>(const uivec3& _obj) {
|
template<> std::string to_string<uivec3>(const uivec3& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -154,9 +158,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<uivec3>(const uivec3& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<uivec3>(const uivec3& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> std::string to_string<bvec3>(const bvec3& _obj) {
|
template<> std::string to_string<bvec3>(const bvec3& _obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -169,9 +175,11 @@ namespace etk {
|
|||||||
str += ")";
|
str += ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<bvec3>(const bvec3& _obj) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
template<> std::u32string to_u32string<bvec3>(const bvec3& _obj) {
|
||||||
}
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<vec3>(vec3& _variableRet, const std::string& _value) {
|
template<> bool from_string<vec3>(vec3& _variableRet, const std::string& _value) {
|
||||||
float floats[3];
|
float floats[3];
|
||||||
@ -212,9 +220,11 @@ namespace etk {
|
|||||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::string& _value) {
|
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::string& _value) {
|
||||||
int32_t floats[3];
|
int32_t floats[3];
|
||||||
@ -255,9 +265,11 @@ namespace etk {
|
|||||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::string& _value) {
|
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::string& _value) {
|
||||||
uint32_t floats[3];
|
uint32_t floats[3];
|
||||||
@ -298,9 +310,11 @@ namespace etk {
|
|||||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::string& _value) {
|
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::string& _value) {
|
||||||
bool floats[3];
|
bool floats[3];
|
||||||
@ -341,7 +355,9 @@ namespace etk {
|
|||||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -159,7 +159,11 @@ namespace etk {
|
|||||||
#ifdef ETK_BUILD_LINEARMATH
|
#ifdef ETK_BUILD_LINEARMATH
|
||||||
return btSqrt(length2());
|
return btSqrt(length2());
|
||||||
#else
|
#else
|
||||||
return std::sqrt(length2());
|
#if __cplusplus >= 201103L
|
||||||
|
return std::sqrt(length2());
|
||||||
|
#else
|
||||||
|
return sqrt(length2());
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,9 +276,11 @@ std::string getApplicationPath() {
|
|||||||
TK_INFO("Binary name : " << binaryName);
|
TK_INFO("Binary name : " << binaryName);
|
||||||
return binaryName;
|
return binaryName;
|
||||||
}
|
}
|
||||||
std::u32string getUApplicationPath() {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getApplicationPath());
|
std::u32string getUApplicationPath() {
|
||||||
}
|
return etk::to_u32string(getApplicationPath());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void etk::initDefaultFolder(const char* _applName) {
|
void etk::initDefaultFolder(const char* _applName) {
|
||||||
baseApplName = _applName;
|
baseApplName = _applName;
|
||||||
@ -388,16 +390,20 @@ void etk::initDefaultFolder(const char* _applName) {
|
|||||||
std::string etk::getUserHomeFolder() {
|
std::string etk::getUserHomeFolder() {
|
||||||
return baseFolderHome;
|
return baseFolderHome;
|
||||||
}
|
}
|
||||||
std::u32string etk::getUUserHomeFolder() {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(baseFolderHome);
|
std::u32string etk::getUUserHomeFolder() {
|
||||||
}
|
return etk::to_u32string(baseFolderHome);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::getUserRunFolder() {
|
std::string etk::getUserRunFolder() {
|
||||||
return baseRunPath;
|
return baseRunPath;
|
||||||
}
|
}
|
||||||
std::u32string etk::getUUserRunFolder() {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(baseRunPath);
|
std::u32string etk::getUUserRunFolder() {
|
||||||
}
|
return etk::to_u32string(baseRunPath);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
@ -484,22 +490,23 @@ etk::FSNode::FSNode(const std::string& _nodeName) :
|
|||||||
{
|
{
|
||||||
privateSetName(_nodeName);
|
privateSetName(_nodeName);
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
etk::FSNode::FSNode(const std::u32string& _nodeName) :
|
etk::FSNode::FSNode(const std::u32string& _nodeName) :
|
||||||
m_userFileName(""),
|
m_userFileName(""),
|
||||||
m_type(etk::FSN_TYPE_UNKNOW),
|
m_type(etk::FSN_TYPE_UNKNOW),
|
||||||
m_typeNode(etk::FSN_UNKNOW),
|
m_typeNode(etk::FSN_UNKNOW),
|
||||||
m_PointerFile(NULL),
|
m_PointerFile(NULL),
|
||||||
m_timeCreate(0),
|
m_timeCreate(0),
|
||||||
m_timeModify(0),
|
m_timeModify(0),
|
||||||
m_timeAccess(0)
|
m_timeAccess(0)
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
, m_zipContent(NULL),
|
, m_zipContent(NULL),
|
||||||
m_zipReadingOffset(-1)
|
m_zipReadingOffset(-1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
privateSetName(_nodeName);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
privateSetName(_nodeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
etk::FSNode::~FSNode() {
|
etk::FSNode::~FSNode() {
|
||||||
@ -702,9 +709,11 @@ void etk::FSNode::privateSetName(const std::string& _newName) {
|
|||||||
updateFileSystemProperty();
|
updateFileSystemProperty();
|
||||||
TK_DBG_MODE("6 : type : [" << m_typeNode << "] right :" << m_rights);
|
TK_DBG_MODE("6 : type : [" << m_typeNode << "] right :" << m_rights);
|
||||||
}
|
}
|
||||||
void etk::FSNode::privateSetName(const std::u32string& _newName) {
|
#if __cplusplus >= 201103L
|
||||||
privateSetName(etk::to_string(_newName));
|
void etk::FSNode::privateSetName(const std::u32string& _newName) {
|
||||||
}
|
privateSetName(etk::to_string(_newName));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
@ -723,9 +732,11 @@ bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded =
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool directCheckFile(std::u32string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
#if __cplusplus >= 201103L
|
||||||
return directCheckFile(etk::to_string(_tmpFileNameDirect));
|
bool directCheckFile(std::u32string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||||
}
|
return directCheckFile(etk::to_string(_tmpFileNameDirect));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// Now we generate the real FS path:
|
// Now we generate the real FS path:
|
||||||
void etk::FSNode::generateFileSystemPath() {
|
void etk::FSNode::generateFileSystemPath() {
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
@ -916,9 +927,11 @@ bool etk::FSNode::setRight(etk::FSNodeRight _newRight) {
|
|||||||
void etk::FSNode::setName(const std::string& _newName) {
|
void etk::FSNode::setName(const std::string& _newName) {
|
||||||
privateSetName(_newName);
|
privateSetName(_newName);
|
||||||
}
|
}
|
||||||
void etk::FSNode::setName(const std::u32string& _newName) {
|
#if __cplusplus >= 201103L
|
||||||
privateSetName(_newName);
|
void etk::FSNode::setName(const std::u32string& _newName) {
|
||||||
}
|
privateSetName(_newName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getNameFolder() const {
|
std::string etk::FSNode::getNameFolder() const {
|
||||||
size_t lastPos = m_systemFileName.rfind('/');
|
size_t lastPos = m_systemFileName.rfind('/');
|
||||||
@ -927,16 +940,20 @@ std::string etk::FSNode::getNameFolder() const {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::getUNameFolder() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getNameFolder());
|
std::u32string etk::FSNode::getUNameFolder() const {
|
||||||
}
|
return etk::to_u32string(getNameFolder());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getFileSystemName() const {
|
std::string etk::FSNode::getFileSystemName() const {
|
||||||
return m_systemFileName;
|
return m_systemFileName;
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::getUFileSystemName() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getFileSystemName());
|
std::u32string etk::FSNode::getUFileSystemName() const {
|
||||||
}
|
return etk::to_u32string(getFileSystemName());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getName() const {
|
std::string etk::FSNode::getName() const {
|
||||||
std::string output;
|
std::string output;
|
||||||
@ -971,9 +988,11 @@ std::string etk::FSNode::getName() const {
|
|||||||
output += m_userFileName;
|
output += m_userFileName;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::getUName() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getName());
|
std::u32string etk::FSNode::getUName() const {
|
||||||
}
|
return etk::to_u32string(getName());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getNameFile() const {
|
std::string etk::FSNode::getNameFile() const {
|
||||||
size_t lastPos = m_systemFileName.rfind('/');
|
size_t lastPos = m_systemFileName.rfind('/');
|
||||||
@ -982,9 +1001,11 @@ std::string etk::FSNode::getNameFile() const {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::getUNameFile() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getNameFile());
|
std::u32string etk::FSNode::getUNameFile() const {
|
||||||
}
|
return etk::to_u32string(getNameFile());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getRelativeFolder() const {
|
std::string etk::FSNode::getRelativeFolder() const {
|
||||||
std::string tmppp = getName();
|
std::string tmppp = getName();
|
||||||
@ -1024,9 +1045,11 @@ std::string etk::FSNode::getRelativeFolder() const {
|
|||||||
TK_DBG_MODE(" ==> : ''" );
|
TK_DBG_MODE(" ==> : ''" );
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::getURelativeFolder() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getRelativeFolder());
|
std::u32string etk::FSNode::getURelativeFolder() const {
|
||||||
}
|
return etk::to_u32string(getRelativeFolder());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool etk::FSNode::touch() {
|
bool etk::FSNode::touch() {
|
||||||
@ -1054,9 +1077,11 @@ bool etk::FSNode::move(const std::string& _path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool etk::FSNode::move(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return move(etk::to_string(_path));
|
bool etk::FSNode::move(const std::u32string& _path) {
|
||||||
}
|
return move(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNode::remove() {
|
bool etk::FSNode::remove() {
|
||||||
if (getNodeType()==etk::FSN_FOLDER) {
|
if (getNodeType()==etk::FSN_FOLDER) {
|
||||||
@ -1089,9 +1114,11 @@ std::string etk::FSNode::timeCreatedString() const {
|
|||||||
}
|
}
|
||||||
return tmpTime;
|
return tmpTime;
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::timeUCreatedString() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(timeCreatedString());
|
std::u32string etk::FSNode::timeUCreatedString() const {
|
||||||
}
|
return etk::to_u32string(timeCreatedString());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNode::timeModified() const {
|
uint64_t etk::FSNode::timeModified() const {
|
||||||
return m_timeModify;
|
return m_timeModify;
|
||||||
@ -1105,9 +1132,11 @@ std::string etk::FSNode::timeModifiedString() const {
|
|||||||
}
|
}
|
||||||
return tmpTime;
|
return tmpTime;
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::timeUModifiedString() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(timeModifiedString());
|
std::u32string etk::FSNode::timeUModifiedString() const {
|
||||||
}
|
return etk::to_u32string(timeModifiedString());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNode::timeAccessed() const {
|
uint64_t etk::FSNode::timeAccessed() const {
|
||||||
return m_timeAccess;
|
return m_timeAccess;
|
||||||
@ -1121,9 +1150,11 @@ std::string etk::FSNode::timeAccessedString() const {
|
|||||||
}
|
}
|
||||||
return tmpTime;
|
return tmpTime;
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::timeUAccessedString() const {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(timeAccessedString());
|
std::u32string etk::FSNode::timeUAccessedString() const {
|
||||||
}
|
return etk::to_u32string(timeAccessedString());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
Operator :
|
Operator :
|
||||||
*/
|
*/
|
||||||
@ -1437,14 +1468,16 @@ void etk::FSNode::folderGetRecursiveFiles(std::vector<std::string>& _output, boo
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void etk::FSNode::folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable) {
|
#if __cplusplus >= 201103L
|
||||||
_output.clear();
|
void etk::FSNode::folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable) {
|
||||||
std::vector<std::string> tmpVal;
|
_output.clear();
|
||||||
folderGetRecursiveFiles(tmpVal, _recursiveEnable);
|
std::vector<std::string> tmpVal;
|
||||||
for (size_t iii=0; iii<tmpVal.size(); ++iii) {
|
folderGetRecursiveFiles(tmpVal, _recursiveEnable);
|
||||||
_output.push_back(to_u32string(tmpVal[iii]));
|
for (size_t iii=0; iii<tmpVal.size(); ++iii) {
|
||||||
|
_output.push_back(to_u32string(tmpVal[iii]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
File Specific :
|
File Specific :
|
||||||
@ -1468,9 +1501,11 @@ std::string etk::FSNode::fileGetExtention() {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::u32string etk::FSNode::fileUGetExtention() {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(fileGetExtention());
|
std::u32string etk::FSNode::fileUGetExtention() {
|
||||||
}
|
return etk::to_u32string(fileGetExtention());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNode::fileSize() {
|
uint64_t etk::FSNode::fileSize() {
|
||||||
if (etk::FSN_FILE != m_typeNode) {
|
if (etk::FSN_FILE != m_typeNode) {
|
||||||
@ -1823,66 +1858,99 @@ static std::map<std::string, std::string> g_listTheme;
|
|||||||
|
|
||||||
void etk::theme::setName(const std::string& _refName, const std::string& _folderName) {
|
void etk::theme::setName(const std::string& _refName, const std::string& _folderName) {
|
||||||
TK_WARNING("Change theme : '" << _refName << "' : '" << _folderName << "'");
|
TK_WARNING("Change theme : '" << _refName << "' : '" << _folderName << "'");
|
||||||
auto it = g_listTheme.find(_refName);
|
#if __cplusplus >= 201103L
|
||||||
|
auto it = g_listTheme.find(_refName);
|
||||||
|
#else
|
||||||
|
std::map<std::string, std::string>::iterator it = g_listTheme.find(_refName);
|
||||||
|
#endif
|
||||||
if (it != g_listTheme.end()) {
|
if (it != g_listTheme.end()) {
|
||||||
it->second = _folderName;
|
it->second = _folderName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_listTheme.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
g_listTheme.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
||||||
}
|
}
|
||||||
void etk::theme::setName(const std::u32string& _refName, const std::u32string& _folderName) {
|
#if __cplusplus >= 201103L
|
||||||
setName(etk::to_string(_refName), etk::to_string(_folderName));
|
void etk::theme::setName(const std::u32string& _refName, const std::u32string& _folderName) {
|
||||||
}
|
setName(etk::to_string(_refName), etk::to_string(_folderName));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::theme::getName(const std::string& _refName) {
|
std::string etk::theme::getName(const std::string& _refName) {
|
||||||
auto it=g_listTheme.find(_refName);
|
#if __cplusplus >= 201103L
|
||||||
|
auto it = g_listTheme.find(_refName);
|
||||||
|
#else
|
||||||
|
std::map<std::string, std::string>::iterator it = g_listTheme.find(_refName);
|
||||||
|
#endif
|
||||||
if (it != g_listTheme.end()) {
|
if (it != g_listTheme.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return _refName;
|
return _refName;
|
||||||
}
|
}
|
||||||
std::u32string etk::theme::getName(const std::u32string& _refName) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getName(etk::to_string(_refName)));
|
std::u32string etk::theme::getName(const std::u32string& _refName) {
|
||||||
}
|
return etk::to_u32string(getName(etk::to_string(_refName)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// get the list of all the theme folder availlable in the user Home/appl
|
// get the list of all the theme folder availlable in the user Home/appl
|
||||||
std::vector<std::string> etk::theme::list() {
|
std::vector<std::string> etk::theme::list() {
|
||||||
std::vector<std::string> keys;
|
std::vector<std::string> keys;
|
||||||
for (auto &it : g_listTheme) {
|
#if __cplusplus >= 201103L
|
||||||
keys.push_back(it.first);
|
for (auto &it : g_listTheme) {
|
||||||
}
|
keys.push_back(it.first);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (std::map<std::string, std::string>::iterator it(g_listTheme.begin()); it != g_listTheme.end(); ++it) {
|
||||||
|
keys.push_back(it->first);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
std::vector<std::u32string> etk::theme::listU() {
|
#if __cplusplus >= 201103L
|
||||||
std::vector<std::u32string> keys;
|
std::vector<std::u32string> etk::theme::listU() {
|
||||||
for (auto &it : g_listTheme) {
|
std::vector<std::u32string> keys;
|
||||||
keys.push_back(etk::to_u32string(it.first));
|
for (auto &it : g_listTheme) {
|
||||||
|
keys.push_back(etk::to_u32string(it.first));
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
}
|
}
|
||||||
return keys;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
static std::map<std::string, std::string> g_listThemeDefault;
|
static std::map<std::string, std::string> g_listThemeDefault;
|
||||||
void etk::theme::setNameDefault(const std::string& _refName, const std::string& _folderName) {
|
void etk::theme::setNameDefault(const std::string& _refName, const std::string& _folderName) {
|
||||||
auto it = g_listThemeDefault.find(_refName);
|
#if __cplusplus >= 201103L
|
||||||
|
auto it = g_listThemeDefault.find(_refName);
|
||||||
|
#else
|
||||||
|
std::map<std::string, std::string>::iterator it = g_listThemeDefault.find(_refName);
|
||||||
|
#endif
|
||||||
if (it != g_listThemeDefault.end()) {
|
if (it != g_listThemeDefault.end()) {
|
||||||
it->second = _folderName;
|
it->second = _folderName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_listThemeDefault.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
g_listThemeDefault.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
||||||
}
|
}
|
||||||
void etk::theme::setNameDefault(const std::u32string& _refName, const std::u32string& _folderName) {
|
#if __cplusplus >= 201103L
|
||||||
setNameDefault(etk::to_string(_refName), etk::to_string(_folderName));
|
void etk::theme::setNameDefault(const std::u32string& _refName, const std::u32string& _folderName) {
|
||||||
}
|
setNameDefault(etk::to_string(_refName), etk::to_string(_folderName));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::theme::getNameDefault(const std::string& _refName) {
|
std::string etk::theme::getNameDefault(const std::string& _refName) {
|
||||||
auto it=g_listThemeDefault.find(_refName);
|
#if __cplusplus >= 201103L
|
||||||
|
auto it=g_listThemeDefault.find(_refName);
|
||||||
|
#else
|
||||||
|
std::map<std::string, std::string>::iterator it = g_listThemeDefault.find(_refName);
|
||||||
|
#endif
|
||||||
if (it != g_listThemeDefault.end()) {
|
if (it != g_listThemeDefault.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
std::u32string etk::theme::getNameDefault(const std::u32string& _refName) {
|
#if __cplusplus >= 201103L
|
||||||
return etk::to_u32string(getNameDefault(etk::to_string(_refName)));
|
std::u32string etk::theme::getNameDefault(const std::u32string& _refName) {
|
||||||
}
|
return etk::to_u32string(getNameDefault(etk::to_string(_refName)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1898,9 +1966,11 @@ bool etk::FSNodeRemove(const std::string& _path) {
|
|||||||
}
|
}
|
||||||
return tmpNode.remove();
|
return tmpNode.remove();
|
||||||
}
|
}
|
||||||
bool etk::FSNodeRemove(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeRemove(etk::to_string(_path));
|
bool etk::FSNodeRemove(const std::u32string& _path) {
|
||||||
}
|
return FSNodeRemove(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int64_t etk::FSNodeGetCount(const std::string& _path) {
|
int64_t etk::FSNodeGetCount(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
@ -1909,25 +1979,31 @@ int64_t etk::FSNodeGetCount(const std::string& _path) {
|
|||||||
}
|
}
|
||||||
return tmpNode.folderCount();
|
return tmpNode.folderCount();
|
||||||
}
|
}
|
||||||
int64_t etk::FSNodeGetCount(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetCount(etk::to_string(_path));
|
int64_t etk::FSNodeGetCount(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetCount(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||||
// TODO :
|
// TODO :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool etk::FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeCreate(etk::to_string(_path), _right, _type);
|
bool etk::FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||||
}
|
return FSNodeCreate(etk::to_string(_path), _right, _type);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeExist(const std::string& _path) {
|
bool etk::FSNodeExist(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.exist();
|
return tmpNode.exist();
|
||||||
}
|
}
|
||||||
bool etk::FSNodeExist(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeExist(etk::to_string(_path));
|
bool etk::FSNodeExist(const std::u32string& _path) {
|
||||||
}
|
return FSNodeExist(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
||||||
etk::FSNode tmpNode(_path1);
|
etk::FSNode tmpNode(_path1);
|
||||||
@ -1940,57 +2016,71 @@ bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
|||||||
//move the node
|
//move the node
|
||||||
return tmpNode.move(_path2);
|
return tmpNode.move(_path2);
|
||||||
}
|
}
|
||||||
bool etk::FSNodeMove(const std::u32string& _path1, const std::u32string& _path2) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeMove(etk::to_string(_path1), etk::to_string(_path2));
|
bool etk::FSNodeMove(const std::u32string& _path1, const std::u32string& _path2) {
|
||||||
}
|
return FSNodeMove(etk::to_string(_path1), etk::to_string(_path2));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.getRight();
|
return tmpNode.getRight();
|
||||||
}
|
}
|
||||||
etk::FSNodeRight etk::FSNodeGetRight(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetRight(etk::to_string(_path));
|
etk::FSNodeRight etk::FSNodeGetRight(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetRight(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.getNodeType();
|
return tmpNode.getNodeType();
|
||||||
}
|
}
|
||||||
enum etk::typeNode etk::FSNodeGetType(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetType(etk::to_string(_path));
|
enum etk::typeNode etk::FSNodeGetType(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetType(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.timeCreated();
|
return tmpNode.timeCreated();
|
||||||
}
|
}
|
||||||
uint64_t etk::FSNodeGetTimeCreated(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetTimeCreated(etk::to_string(_path));
|
uint64_t etk::FSNodeGetTimeCreated(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetTimeCreated(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.timeModified();
|
return tmpNode.timeModified();
|
||||||
}
|
}
|
||||||
uint64_t etk::FSNodeGetTimeModified(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetTimeModified(etk::to_string(_path));
|
uint64_t etk::FSNodeGetTimeModified(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetTimeModified(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.timeAccessed();
|
return tmpNode.timeAccessed();
|
||||||
}
|
}
|
||||||
uint64_t etk::FSNodeGetTimeAccessed(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeGetTimeAccessed(etk::to_string(_path));
|
uint64_t etk::FSNodeGetTimeAccessed(const std::u32string& _path) {
|
||||||
}
|
return FSNodeGetTimeAccessed(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeTouch(const std::string& _path) {
|
bool etk::FSNodeTouch(const std::string& _path) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
return tmpNode.touch();
|
return tmpNode.touch();
|
||||||
}
|
}
|
||||||
bool etk::FSNodeTouch(const std::u32string& _path) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeTouch(etk::to_string(_path));
|
bool etk::FSNodeTouch(const std::u32string& _path) {
|
||||||
}
|
return FSNodeTouch(etk::to_string(_path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite) {
|
bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
@ -2010,9 +2100,11 @@ bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite)
|
|||||||
}
|
}
|
||||||
return tmpNode.fileClose();
|
return tmpNode.fileClose();
|
||||||
}
|
}
|
||||||
bool etk::FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeEcho(etk::to_string(_path), etk::to_string(_dataTowrite));
|
bool etk::FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||||
}
|
return FSNodeEcho(etk::to_string(_path), etk::to_string(_dataTowrite));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite) {
|
bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite) {
|
||||||
etk::FSNode tmpNode(_path);
|
etk::FSNode tmpNode(_path);
|
||||||
@ -2032,9 +2124,11 @@ bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrit
|
|||||||
}
|
}
|
||||||
return tmpNode.fileClose();
|
return tmpNode.fileClose();
|
||||||
}
|
}
|
||||||
bool etk::FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeEchoAdd(etk::to_string(_path), etk::to_string(_dataTowrite));
|
bool etk::FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||||
}
|
return FSNodeEchoAdd(etk::to_string(_path), etk::to_string(_dataTowrite));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
||||||
// step 1 : Move the file to prevent writing error
|
// step 1 : Move the file to prevent writing error
|
||||||
@ -2048,9 +2142,11 @@ void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
|||||||
etk::FSNodeMove(_path, _path + "-1");
|
etk::FSNodeMove(_path, _path + "-1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
#if __cplusplus >= 201103L
|
||||||
return FSNodeHistory(etk::to_string(_path), _historyCount);
|
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
||||||
}
|
return FSNodeHistory(etk::to_string(_path), _historyCount);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNodeReadAllData(const std::string& _path) {
|
std::string etk::FSNodeReadAllData(const std::string& _path) {
|
||||||
std::string output;
|
std::string output;
|
||||||
|
161
etk/os/FSNode.h
161
etk/os/FSNode.h
@ -141,7 +141,9 @@ namespace etk {
|
|||||||
* @param[in] _path Path of the curent file /folder ...
|
* @param[in] _path Path of the curent file /folder ...
|
||||||
*/
|
*/
|
||||||
FSNode(const std::string& _path = "~");
|
FSNode(const std::string& _path = "~");
|
||||||
FSNode(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
FSNode(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
* @note you will have some warning if you did not close your files
|
* @note you will have some warning if you did not close your files
|
||||||
@ -161,7 +163,9 @@ namespace etk {
|
|||||||
* @param[in] _newName Name of the Node
|
* @param[in] _newName Name of the Node
|
||||||
*/
|
*/
|
||||||
void privateSetName(const std::string& _newName);
|
void privateSetName(const std::string& _newName);
|
||||||
void privateSetName(const std::u32string& _newName);
|
#if __cplusplus >= 201103L
|
||||||
|
void privateSetName(const std::u32string& _newName);
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
/**
|
/**
|
||||||
@ -210,40 +214,52 @@ namespace etk {
|
|||||||
* @return false : action not done
|
* @return false : action not done
|
||||||
*/
|
*/
|
||||||
void setName(const std::string& _newName);
|
void setName(const std::string& _newName);
|
||||||
void setName(const std::u32string& _newName);
|
#if __cplusplus >= 201103L
|
||||||
|
void setName(const std::u32string& _newName);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the Generate FileSystem name
|
* @brief Get the Generate FileSystem name
|
||||||
* @return the requested filename
|
* @return the requested filename
|
||||||
*/
|
*/
|
||||||
std::string getFileSystemName() const;
|
std::string getFileSystemName() const;
|
||||||
std::u32string getUFileSystemName() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUFileSystemName() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the current folder of the Node. (file system name)
|
* @brief Get the current folder of the Node. (file system name)
|
||||||
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
|
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
|
||||||
* @note Auto remove of ../../../ and //
|
* @note Auto remove of ../../../ and //
|
||||||
*/
|
*/
|
||||||
std::string getNameFolder() const;
|
std::string getNameFolder() const;
|
||||||
std::u32string getUNameFolder() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUNameFolder() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the current compleate node name (file system name)
|
* @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)
|
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
|
||||||
* @note Auto remove of ../../../ and //
|
* @note Auto remove of ../../../ and //
|
||||||
*/
|
*/
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
std::u32string getUName() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUName() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the file or current file name (if it was a file)
|
* @brief Get the file or current file name (if it was a file)
|
||||||
* @return the name of the node (like myFile.kkk)
|
* @return the name of the node (like myFile.kkk)
|
||||||
*/
|
*/
|
||||||
std::string getNameFile() const;
|
std::string getNameFile() const;
|
||||||
std::u32string getUNameFile() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUNameFile() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the current folder of the Node.
|
* @brief Get the current folder of the Node.
|
||||||
* @return the common name define (like DATA:xxxxx/xxxxx/)
|
* @return the common name define (like DATA:xxxxx/xxxxx/)
|
||||||
* @note Auto remove of ../../../ and //
|
* @note Auto remove of ../../../ and //
|
||||||
*/
|
*/
|
||||||
std::string getRelativeFolder() const;
|
std::string getRelativeFolder() const;
|
||||||
std::u32string getURelativeFolder() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getURelativeFolder() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief update the Time of the file with the current time
|
* @brief update the Time of the file with the current time
|
||||||
* @return true : action done
|
* @return true : action done
|
||||||
@ -257,7 +273,9 @@ namespace etk {
|
|||||||
* @return false : action not done
|
* @return false : action not done
|
||||||
*/
|
*/
|
||||||
bool move(const std::string& _path);
|
bool move(const std::string& _path);
|
||||||
bool move(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
bool move(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the node type (DATA/DIRECT...)
|
* @brief Get the node type (DATA/DIRECT...)
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
@ -281,7 +299,9 @@ namespace etk {
|
|||||||
* @return The time requested (in string)
|
* @return The time requested (in string)
|
||||||
*/
|
*/
|
||||||
std::string timeCreatedString() const;
|
std::string timeCreatedString() const;
|
||||||
std::u32string timeUCreatedString() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string timeUCreatedString() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the modifying time of the File
|
* @brief Get the modifying time of the File
|
||||||
* @return The time requested
|
* @return The time requested
|
||||||
@ -292,7 +312,9 @@ namespace etk {
|
|||||||
* @return The time requested (in string)
|
* @return The time requested (in string)
|
||||||
*/
|
*/
|
||||||
std::string timeModifiedString() const;
|
std::string timeModifiedString() const;
|
||||||
std::u32string timeUModifiedString() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string timeUModifiedString() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the Accessed time of the File
|
* @brief Get the Accessed time of the File
|
||||||
* @return The time requested
|
* @return The time requested
|
||||||
@ -303,7 +325,9 @@ namespace etk {
|
|||||||
* @return The time requested (in string)
|
* @return The time requested (in string)
|
||||||
*/
|
*/
|
||||||
std::string timeAccessedString() const;
|
std::string timeAccessedString() const;
|
||||||
std::u32string timeUAccessedString() const;
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string timeUAccessedString() const;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief copy the other FSnode ==> for vector
|
* @brief copy the other FSnode ==> for vector
|
||||||
* @param[in] _obj input node
|
* @param[in] _obj input node
|
||||||
@ -359,7 +383,9 @@ namespace etk {
|
|||||||
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
|
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
|
||||||
*/
|
*/
|
||||||
void folderGetRecursiveFiles(std::vector<std::string>& _output, bool _recursiveEnable=true);
|
void folderGetRecursiveFiles(std::vector<std::string>& _output, bool _recursiveEnable=true);
|
||||||
void folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable=true);
|
#if __cplusplus >= 201103L
|
||||||
|
void folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable=true);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Check if the file have an extention ( ***.ccc)
|
* @brief Check if the file have an extention ( ***.ccc)
|
||||||
* @return true The file have an extention.
|
* @return true The file have an extention.
|
||||||
@ -371,7 +397,9 @@ namespace etk {
|
|||||||
* @return the requested extention
|
* @return the requested extention
|
||||||
*/
|
*/
|
||||||
std::string fileGetExtention();
|
std::string fileGetExtention();
|
||||||
std::u32string fileUGetExtention();
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string fileUGetExtention();
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the File size
|
* @brief Get the File size
|
||||||
* @return the requested size
|
* @return the requested size
|
||||||
@ -496,9 +524,11 @@ namespace etk {
|
|||||||
fileRead(&value[0], sizeof(char), fileSize()/sizeof(char));
|
fileRead(&value[0], sizeof(char), fileSize()/sizeof(char));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string fileReadAllU32String() {
|
std::u32string fileReadAllU32String() {
|
||||||
return utf8::convertUnicode(fileReadAllString());
|
return utf8::convertUnicode(fileReadAllString());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Write all the vector in a file
|
* @brief Write all the vector in a file
|
||||||
*/
|
*/
|
||||||
@ -508,9 +538,11 @@ namespace etk {
|
|||||||
void fileWriteAll(const std::string& _value) {
|
void fileWriteAll(const std::string& _value) {
|
||||||
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char));
|
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char));
|
||||||
}
|
}
|
||||||
void fileWriteAll(const std::u32string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
fileWriteAll(u32char::convertToUtf8(_value));
|
void fileWriteAll(const std::u32string& _value) {
|
||||||
}
|
fileWriteAll(u32char::convertToUtf8(_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Order the list of subnode the folder first and the alphabetical order
|
* @brief Order the list of subnode the folder first and the alphabetical order
|
||||||
@ -546,13 +578,17 @@ namespace etk {
|
|||||||
* @return the home folder : like : "/home/machin/"
|
* @return the home folder : like : "/home/machin/"
|
||||||
*/
|
*/
|
||||||
std::string getUserHomeFolder();
|
std::string getUserHomeFolder();
|
||||||
std::u32string getUUserHomeFolder();
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUUserHomeFolder();
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the folder of the Program is running
|
* @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)
|
* @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder)
|
||||||
*/
|
*/
|
||||||
std::string getUserRunFolder();
|
std::string getUserRunFolder();
|
||||||
std::u32string getUUserRunFolder();
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string getUUserRunFolder();
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace theme {
|
namespace theme {
|
||||||
// TODO : Add an INIT ...
|
// TODO : Add an INIT ...
|
||||||
@ -562,40 +598,49 @@ namespace etk {
|
|||||||
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
|
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
|
||||||
*/
|
*/
|
||||||
void setName(const std::string& _refName, const std::string& _folderName);
|
void setName(const std::string& _refName, const std::string& _folderName);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
void setName(const std::u32string& _refName, const std::u32string& _folderName);
|
//! @previous
|
||||||
|
void setName(const std::u32string& _refName, const std::u32string& _folderName);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief get the folder from a Reference theme
|
* @brief get the folder from a Reference theme
|
||||||
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
||||||
* @return the path of the theme
|
* @return the path of the theme
|
||||||
*/
|
*/
|
||||||
std::string getName(const std::string& _refName);
|
std::string getName(const std::string& _refName);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string getName(const std::u32string& _refName);
|
//! @previous
|
||||||
|
std::u32string getName(const std::u32string& _refName);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Set the default folder of a subset of a theme ...
|
* @brief Set the default folder of a subset of a theme ...
|
||||||
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
||||||
* @param[in] _folderName The associated default folder of the Theme (like "myTheme/color/default/")
|
* @param[in] _folderName The associated default folder of the Theme (like "myTheme/color/default/")
|
||||||
*/
|
*/
|
||||||
void setNameDefault(const std::string& _refName, const std::string& _folderName);
|
void setNameDefault(const std::string& _refName, const std::string& _folderName);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
void setNameDefault(const std::u32string& _refName, const std::u32string& _folderName);
|
//! @previous
|
||||||
|
void setNameDefault(const std::u32string& _refName, const std::u32string& _folderName);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief get the default folder from a Reference theme
|
* @brief get the default folder from a Reference theme
|
||||||
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
|
||||||
* @return the path of the theme
|
* @return the path of the theme
|
||||||
*/
|
*/
|
||||||
std::string getNameDefault(const std::string& _refName);
|
std::string getNameDefault(const std::string& _refName);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string getNameDefault(const std::u32string& _refName);
|
//! @previous
|
||||||
|
std::u32string getNameDefault(const std::u32string& _refName);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Get the list of all the theme folder availlable in the user Home/appl
|
* @brief Get the list of all the theme folder availlable in the user Home/appl
|
||||||
* @return The list of elements
|
* @return The list of elements
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> list();
|
std::vector<std::string> list();
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::vector<std::u32string> listU();
|
//! @previous
|
||||||
|
std::vector<std::u32string> listU();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,7 +650,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeRemove(const std::string& _path);
|
bool FSNodeRemove(const std::string& _path);
|
||||||
bool FSNodeRemove(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeRemove(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : count the number of element in a path (if it is not a path ==> return -1)
|
* @brief Simple access for : count the number of element in a path (if it is not a path ==> return -1)
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -613,7 +660,9 @@ namespace etk {
|
|||||||
* @return -1 : An error occured
|
* @return -1 : An error occured
|
||||||
*/
|
*/
|
||||||
int64_t FSNodeGetCount(const std::string& _path);
|
int64_t FSNodeGetCount(const std::string& _path);
|
||||||
int64_t FSNodeGetCount(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
int64_t FSNodeGetCount(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Create a file or a folder depending of the request
|
* @brief Simple access for : Create a file or a folder depending of the request
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -623,7 +672,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
|
bool FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
|
||||||
bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : chexk the exestance of an element
|
* @brief Simple access for : chexk the exestance of an element
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -631,7 +682,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeExist(const std::string& _path);
|
bool FSNodeExist(const std::string& _path);
|
||||||
bool FSNodeExist(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeExist(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : chexk the exestance of an element
|
* @brief Simple access for : chexk the exestance of an element
|
||||||
* @param[in] _path1 Folder/File/Pipe path of the node sources
|
* @param[in] _path1 Folder/File/Pipe path of the node sources
|
||||||
@ -640,7 +693,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeMove(const std::string& _path1, const std::string& _path2);
|
bool FSNodeMove(const std::string& _path1, const std::string& _path2);
|
||||||
bool FSNodeMove(const std::u32string& _path1, const std::u32string& _path2);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeMove(const std::u32string& _path1, const std::u32string& _path2);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Get right of the current Node
|
* @brief Simple access for : Get right of the current Node
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -648,7 +703,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
etk::FSNodeRight FSNodeGetRight(const std::string& _path);
|
etk::FSNodeRight FSNodeGetRight(const std::string& _path);
|
||||||
etk::FSNodeRight FSNodeGetRight(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
etk::FSNodeRight FSNodeGetRight(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Get type of the current node
|
* @brief Simple access for : Get type of the current node
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -656,7 +713,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
enum etk::typeNode FSNodeGetType(const std::string& _path);
|
enum etk::typeNode FSNodeGetType(const std::string& _path);
|
||||||
enum etk::typeNode FSNodeGetType(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
enum etk::typeNode FSNodeGetType(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Getting creation time of the current node
|
* @brief Simple access for : Getting creation time of the current node
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -664,7 +723,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
uint64_t FSNodeGetTimeCreated(const std::string& _path);
|
uint64_t FSNodeGetTimeCreated(const std::string& _path);
|
||||||
uint64_t FSNodeGetTimeCreated(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
uint64_t FSNodeGetTimeCreated(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Getting Modification time of the current node
|
* @brief Simple access for : Getting Modification time of the current node
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -672,7 +733,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
uint64_t FSNodeGetTimeModified(const std::string& _path);
|
uint64_t FSNodeGetTimeModified(const std::string& _path);
|
||||||
uint64_t FSNodeGetTimeModified(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
uint64_t FSNodeGetTimeModified(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Getting Accessing time of the current node
|
* @brief Simple access for : Getting Accessing time of the current node
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -680,7 +743,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
uint64_t FSNodeGetTimeAccessed(const std::string& _path);
|
uint64_t FSNodeGetTimeAccessed(const std::string& _path);
|
||||||
uint64_t FSNodeGetTimeAccessed(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
uint64_t FSNodeGetTimeAccessed(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Update Modification time with the current time of the node (>)
|
* @brief Simple access for : Update Modification time with the current time of the node (>)
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -688,7 +753,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeTouch(const std::string& _path);
|
bool FSNodeTouch(const std::string& _path);
|
||||||
bool FSNodeTouch(const std::u32string& _path);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeTouch(const std::u32string& _path);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Basic write on the node (like console echo)
|
* @brief Simple access for : Basic write on the node (like console echo)
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -697,7 +764,9 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeEcho(const std::string& _path, const std::string& _dataTowrite);
|
bool FSNodeEcho(const std::string& _path, const std::string& _dataTowrite);
|
||||||
bool FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Simple access for : Basic write on the node (like console echo) in adding mode (>>)
|
* @brief Simple access for : Basic write on the node (like console echo) in adding mode (>>)
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
@ -706,14 +775,18 @@ namespace etk {
|
|||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
*/
|
*/
|
||||||
bool FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite);
|
bool FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite);
|
||||||
bool FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite);
|
#if __cplusplus >= 201103L
|
||||||
|
bool FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief move file to generate an history of the current file
|
* @brief move file to generate an history of the current file
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
* @param[in] _historyCount number of saved file in the history (-xxx)
|
* @param[in] _historyCount number of saved file in the history (-xxx)
|
||||||
*/
|
*/
|
||||||
void FSNodeHistory(const std::string& _path, int32_t _historyCount);
|
void FSNodeHistory(const std::string& _path, int32_t _historyCount);
|
||||||
void FSNodeHistory(const std::u32string& _path, int32_t _historyCount);
|
#if __cplusplus >= 201103L
|
||||||
|
void FSNodeHistory(const std::u32string& _path, int32_t _historyCount);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Read all the data from a file
|
* @brief Read all the data from a file
|
||||||
* @param[in] _path Folder/File/Pipe path of the node
|
* @param[in] _path Folder/File/Pipe path of the node
|
||||||
|
@ -174,10 +174,11 @@ void etk::FSNodeRight::setOtherRunable(bool _newStatus)
|
|||||||
m_rights |= RIGHT_OTHER_EXECUTE;
|
m_rights |= RIGHT_OTHER_EXECUTE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string etk::FSNodeRight::getURight() const {
|
std::u32string etk::FSNodeRight::getURight() const {
|
||||||
return etk::to_u32string(getRight());
|
return etk::to_u32string(getRight());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNodeRight::getRight() const {
|
std::string etk::FSNodeRight::getRight() const {
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
|
@ -48,8 +48,9 @@ namespace etk {
|
|||||||
void setOtherReadable(bool _newStatus);
|
void setOtherReadable(bool _newStatus);
|
||||||
void setOtherWritable(bool _newStatus);
|
void setOtherWritable(bool _newStatus);
|
||||||
void setOtherRunable(bool _newStatus);
|
void setOtherRunable(bool _newStatus);
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string getURight() const;
|
std::u32string getURight() const;
|
||||||
|
#endif
|
||||||
std::string getRight() const;
|
std::string getRight() const;
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
|
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
|
||||||
|
730
etk/stdTools.cpp
730
etk/stdTools.cpp
@ -130,12 +130,12 @@ int8_t u32char::convertUtf8(char32_t _val, char _output[5]) {
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::string u32char::convertToUtf8(const std::u32string& _input) {
|
std::string u32char::convertToUtf8(const std::u32string& _input) {
|
||||||
TK_TODO("implement this function ...");
|
TK_TODO("implement this function ...");
|
||||||
return "TODO ... std::string u32char::convertToUtf8(const std::u32string& _input)";
|
return "TODO ... std::string u32char::convertToUtf8(const std::u32string& _input)";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "utf8"
|
#define __class__ "utf8"
|
||||||
@ -231,11 +231,12 @@ bool utf8::theoricFirst(const char _input) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string utf8::convertUnicode(const std::string& _input) {
|
std::u32string utf8::convertUnicode(const std::string& _input) {
|
||||||
TK_TODO("implement this function ...");
|
TK_TODO("implement this function ...");
|
||||||
return U"TODO ... std::u32string utf8::convertUnicode(const std::string& _input)";
|
return U"TODO ... std::u32string utf8::convertUnicode(const std::string& _input)";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
utf8::iterator& utf8::iterator::operator++ () {
|
utf8::iterator& utf8::iterator::operator++ () {
|
||||||
m_value = u32char::Null;
|
m_value = u32char::Null;
|
||||||
@ -311,22 +312,24 @@ char32_t utf8::iterator::operator* () {
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "etk"
|
#define __class__ "etk"
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> std::string to_string<std::u32string>(const std::u32string& _input) {
|
#if __cplusplus >= 201103L
|
||||||
std::string out;
|
template<> std::string to_string<std::u32string>(const std::u32string& _input) {
|
||||||
for (size_t iii=0; iii<_input.size(); ++iii) {
|
std::string out;
|
||||||
char output[10];
|
for (size_t iii=0; iii<_input.size(); ++iii) {
|
||||||
u32char::convertUtf8(_input[iii], output);
|
char output[10];
|
||||||
out += output;
|
u32char::convertUtf8(_input[iii], output);
|
||||||
|
out += output;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
return out;
|
template<> std::string to_string<char32_t>(const char32_t& _input) {
|
||||||
}
|
std::string out;
|
||||||
template<> std::string to_string<char32_t>(const char32_t& _input) {
|
char output[10];
|
||||||
std::string out;
|
u32char::convertUtf8(_input, output);
|
||||||
char output[10];
|
out += output;
|
||||||
u32char::convertUtf8(_input, output);
|
return out;
|
||||||
out += output;
|
}
|
||||||
return out;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
template<> std::string to_string<std::string>(const std::string& _val) {
|
template<> std::string to_string<std::string>(const std::string& _val) {
|
||||||
return _val;
|
return _val;
|
||||||
@ -415,171 +418,180 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::u32string transform_to_u32string(const char* _input) {
|
#if __cplusplus >= 201103L
|
||||||
if (_input == NULL) {
|
static std::u32string transform_to_u32string(const char* _input) {
|
||||||
return U"";
|
if (_input == NULL) {
|
||||||
}
|
return U"";
|
||||||
std::u32string out;
|
|
||||||
char tmpData[20];
|
|
||||||
int64_t pos = 0;
|
|
||||||
int64_t inputLen = strlen(_input);
|
|
||||||
while (pos < inputLen) {
|
|
||||||
int32_t lenMax = inputLen - pos;
|
|
||||||
//4 case
|
|
||||||
if ( 1<=lenMax
|
|
||||||
&& 0x00 == (_input[pos+0] & 0x80) ) {
|
|
||||||
tmpData[0] = _input[pos+0];
|
|
||||||
tmpData[1] = '\0';
|
|
||||||
pos += 1;
|
|
||||||
} else if ( 2<=lenMax
|
|
||||||
&& 0xC0 == (_input[pos+0] & 0xE0)
|
|
||||||
&& 0x80 == (_input[pos+1] & 0xC0) ) {
|
|
||||||
tmpData[0] = _input[pos+0];
|
|
||||||
tmpData[1] = _input[pos+1];
|
|
||||||
tmpData[2] = '\0';
|
|
||||||
pos += 2;
|
|
||||||
} else if ( 3<=lenMax
|
|
||||||
&& 0xE0 == (_input[pos+0] & 0xF0)
|
|
||||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
|
||||||
&& 0x80 == (_input[pos+2] & 0xC0)) {
|
|
||||||
tmpData[0] = _input[pos+0];
|
|
||||||
tmpData[1] = _input[pos+1];
|
|
||||||
tmpData[2] = _input[pos+2];
|
|
||||||
tmpData[3] = '\0';
|
|
||||||
pos += 3;
|
|
||||||
} else if ( 4<=lenMax
|
|
||||||
&& 0xF0 == (_input[pos+0] & 0xF8)
|
|
||||||
&& 0x80 == (_input[pos+1] & 0xC0)
|
|
||||||
&& 0x80 == (_input[pos+2] & 0xC0)
|
|
||||||
&& 0x80 == (_input[pos+3] & 0xC0)) {
|
|
||||||
tmpData[0] = _input[pos+0];
|
|
||||||
tmpData[1] = _input[pos+1];
|
|
||||||
tmpData[2] = _input[pos+2];
|
|
||||||
tmpData[3] = _input[pos+3];
|
|
||||||
tmpData[4] = '\0';
|
|
||||||
pos += 4;
|
|
||||||
} else {
|
|
||||||
tmpData[0] = '\0';
|
|
||||||
pos += 1;
|
|
||||||
}
|
}
|
||||||
out += utf8::convertChar32(tmpData);
|
std::u32string out;
|
||||||
}
|
char tmpData[20];
|
||||||
return out;
|
int64_t pos = 0;
|
||||||
}
|
int64_t inputLen = strlen(_input);
|
||||||
|
while (pos < inputLen) {
|
||||||
namespace etk {
|
int32_t lenMax = inputLen - pos;
|
||||||
template<> std::u32string to_u32string<char*>(char* const & _input) {
|
//4 case
|
||||||
return transform_to_u32string(_input);
|
if ( 1<=lenMax
|
||||||
}
|
&& 0x00 == (_input[pos+0] & 0x80) ) {
|
||||||
template<> std::u32string to_u32string<std::string>(const std::string& _input) {
|
tmpData[0] = _input[pos+0];
|
||||||
return transform_to_u32string(_input.c_str());
|
tmpData[1] = '\0';
|
||||||
}
|
pos += 1;
|
||||||
template<> std::u32string to_u32string<int8_t>(const int8_t& _val) {
|
} else if ( 2<=lenMax
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
&& 0xC0 == (_input[pos+0] & 0xE0)
|
||||||
};
|
&& 0x80 == (_input[pos+1] & 0xC0) ) {
|
||||||
template<> std::u32string to_u32string<int16_t>(const int16_t& _val) {
|
tmpData[0] = _input[pos+0];
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
tmpData[1] = _input[pos+1];
|
||||||
};
|
tmpData[2] = '\0';
|
||||||
template<> std::u32string to_u32string<int32_t>(const int32_t& _val) {
|
pos += 2;
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
} else if ( 3<=lenMax
|
||||||
};
|
&& 0xE0 == (_input[pos+0] & 0xF0)
|
||||||
template<> std::u32string to_u32string<int64_t>(const int64_t& _val) {
|
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
&& 0x80 == (_input[pos+2] & 0xC0)) {
|
||||||
};
|
tmpData[0] = _input[pos+0];
|
||||||
template<> std::u32string to_u32string<uint8_t>(const uint8_t& _val) {
|
tmpData[1] = _input[pos+1];
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
tmpData[2] = _input[pos+2];
|
||||||
};
|
tmpData[3] = '\0';
|
||||||
template<> std::u32string to_u32string<uint16_t>(const uint16_t& _val) {
|
pos += 3;
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
} else if ( 4<=lenMax
|
||||||
};
|
&& 0xF0 == (_input[pos+0] & 0xF8)
|
||||||
template<> std::u32string to_u32string<uint32_t>(const uint32_t& _val) {
|
&& 0x80 == (_input[pos+1] & 0xC0)
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
&& 0x80 == (_input[pos+2] & 0xC0)
|
||||||
};
|
&& 0x80 == (_input[pos+3] & 0xC0)) {
|
||||||
template<> std::u32string to_u32string<uint64_t>(const uint64_t& _val) {
|
tmpData[0] = _input[pos+0];
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
tmpData[1] = _input[pos+1];
|
||||||
};
|
tmpData[2] = _input[pos+2];
|
||||||
template<> std::u32string to_u32string<float>(const float& _val) {
|
tmpData[3] = _input[pos+3];
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
tmpData[4] = '\0';
|
||||||
};
|
pos += 4;
|
||||||
template<> std::u32string to_u32string<double>(const double& _val) {
|
} else {
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
tmpData[0] = '\0';
|
||||||
};
|
pos += 1;
|
||||||
template<> std::u32string to_u32string<long double>(const long double& _val) {
|
}
|
||||||
return etk::to_u32string(etk::to_string(_val));
|
out += utf8::convertChar32(tmpData);
|
||||||
};
|
|
||||||
template<> std::u32string to_u32string<bool>(const bool& _val) {
|
|
||||||
if (_val == true) {
|
|
||||||
return U"true";
|
|
||||||
}
|
}
|
||||||
return U"false";
|
return out;
|
||||||
}
|
}
|
||||||
};
|
#endif
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
namespace etk {
|
||||||
|
template<> std::u32string to_u32string<char*>(char* const & _input) {
|
||||||
|
return transform_to_u32string(_input);
|
||||||
|
}
|
||||||
|
template<> std::u32string to_u32string<std::string>(const std::string& _input) {
|
||||||
|
return transform_to_u32string(_input.c_str());
|
||||||
|
}
|
||||||
|
template<> std::u32string to_u32string<int8_t>(const int8_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<int16_t>(const int16_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<int32_t>(const int32_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<int64_t>(const int64_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<uint8_t>(const uint8_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<uint16_t>(const uint16_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<uint32_t>(const uint32_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<uint64_t>(const uint64_t& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<float>(const float& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<double>(const double& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<long double>(const long double& _val) {
|
||||||
|
return etk::to_u32string(etk::to_string(_val));
|
||||||
|
};
|
||||||
|
template<> std::u32string to_u32string<bool>(const bool& _val) {
|
||||||
|
if (_val == true) {
|
||||||
|
return U"true";
|
||||||
|
}
|
||||||
|
return U"false";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool etk::string_to_bool(const std::u32string& _str) {
|
bool etk::string_to_bool(const std::u32string& _str) {
|
||||||
if( true == compare_no_case(_str, U"true")
|
if( true == compare_no_case(_str, U"true")
|
||||||
|| true == compare_no_case(_str, U"enable")
|
|| true == compare_no_case(_str, U"enable")
|
||||||
|| true == compare_no_case(_str, U"yes")
|
|| true == compare_no_case(_str, U"yes")
|
||||||
|| _str == U"1") {
|
|| _str == U"1") {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
double etk::string_to_double(const std::u32string& _str) {
|
double etk::string_to_double(const std::u32string& _str) {
|
||||||
return std::stod(etk::to_string(_str));
|
return std::stod(etk::to_string(_str));
|
||||||
}
|
}
|
||||||
long double etk::string_to_long_double(const std::u32string& _str) {
|
long double etk::string_to_long_double(const std::u32string& _str) {
|
||||||
return std::stold(etk::to_string(_str));
|
return std::stold(etk::to_string(_str));
|
||||||
}
|
}
|
||||||
float etk::string_to_float(const std::u32string& _str) {
|
float etk::string_to_float(const std::u32string& _str) {
|
||||||
return std::stof(etk::to_string(_str));
|
return std::stof(etk::to_string(_str));
|
||||||
}
|
}
|
||||||
int8_t etk::string_to_int8_t(const std::u32string& _str, int _base) {
|
int8_t etk::string_to_int8_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoi(etk::to_string(_str), 0, _base);
|
return std::stoi(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
int16_t etk::string_to_int16_t(const std::u32string& _str, int _base) {
|
int16_t etk::string_to_int16_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoi(etk::to_string(_str), 0, _base);
|
return std::stoi(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
int32_t etk::string_to_int32_t(const std::u32string& _str, int _base) {
|
int32_t etk::string_to_int32_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoi(etk::to_string(_str), 0, _base);
|
return std::stoi(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
int64_t etk::string_to_int64_t(const std::u32string& _str, int _base) {
|
int64_t etk::string_to_int64_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoll(etk::to_string(_str), 0, _base);
|
return std::stoll(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
uint8_t etk::string_to_uint8_t(const std::u32string& _str, int _base) {
|
uint8_t etk::string_to_uint8_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoul(etk::to_string(_str), 0, _base);
|
return std::stoul(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
uint16_t etk::string_to_uint16_t(const std::u32string& _str, int _base) {
|
uint16_t etk::string_to_uint16_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoul(etk::to_string(_str), 0, _base);
|
return std::stoul(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
uint32_t etk::string_to_uint32_t(const std::u32string& _str, int _base) {
|
uint32_t etk::string_to_uint32_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoul(etk::to_string(_str), 0, _base);
|
return std::stoul(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
uint64_t etk::string_to_uint64_t(const std::u32string& _str, int _base) {
|
uint64_t etk::string_to_uint64_t(const std::u32string& _str, int _base) {
|
||||||
return std::stoull(etk::to_string(_str), 0, _base);
|
return std::stoull(etk::to_string(_str), 0, _base);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool etk::string_to_bool(const std::string& _str) {
|
bool etk::string_to_bool(const std::string& _str) {
|
||||||
if( true == compare_no_case(_str, "true")
|
if( true == compare_no_case(_str, "true")
|
||||||
|| true == compare_no_case(_str, "enable")
|
|| true == compare_no_case(_str, "enable")
|
||||||
|| true == compare_no_case(_str, "yes")
|
|| true == compare_no_case(_str, "yes")
|
||||||
|| _str == u8"1") {
|
#if __cplusplus >= 201103L
|
||||||
|
|| _str == u8"1"
|
||||||
|
#else
|
||||||
|
|| _str == "1"
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
bool etk::compare_no_case(const std::u32string& _obj, const std::u32string& _val) {
|
bool etk::compare_no_case(const std::u32string& _obj, const std::u32string& _val) {
|
||||||
if (_val.size() != _obj.size()) {
|
if (_val.size() != _obj.size()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
|
||||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||||
|
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
bool etk::compare_no_case(const std::string& _obj, const std::string& _val) {
|
bool etk::compare_no_case(const std::string& _obj, const std::string& _val) {
|
||||||
if (_val.size() != _obj.size()) {
|
if (_val.size() != _obj.size()) {
|
||||||
@ -598,6 +610,7 @@ struct doublette {
|
|||||||
char32_t upper;
|
char32_t upper;
|
||||||
};
|
};
|
||||||
struct doublette convertionTable[] = {
|
struct doublette convertionTable[] = {
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
{U'ç', U'Ç'},
|
{U'ç', U'Ç'},
|
||||||
|
|
||||||
{U'á', U'Á'}, {U'à', U'À'}, {U'ä', U'Ä'}, {U'â', U'Â'}, {U'å', U'Å'}, {U'ã', U'Ã'},
|
{U'á', U'Á'}, {U'à', U'À'}, {U'ä', U'Ä'}, {U'â', U'Â'}, {U'å', U'Å'}, {U'ã', U'Ã'},
|
||||||
@ -618,6 +631,7 @@ struct doublette convertionTable[] = {
|
|||||||
{U'æ', U'Æ'},
|
{U'æ', U'Æ'},
|
||||||
{U'ð', U'Ð'},
|
{U'ð', U'Ð'},
|
||||||
{U'ø', U'Ø'}
|
{U'ø', U'Ø'}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
size_t convertionTableSize = sizeof(convertionTable)/sizeof(struct doublette);
|
size_t convertionTableSize = sizeof(convertionTable)/sizeof(struct doublette);
|
||||||
|
|
||||||
@ -652,12 +666,14 @@ std::string etk::tolower(std::string _obj) {
|
|||||||
}
|
}
|
||||||
return _obj;
|
return _obj;
|
||||||
}
|
}
|
||||||
std::u32string etk::tolower(std::u32string _obj) {
|
#if __cplusplus >= 201103L
|
||||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
std::u32string etk::tolower(std::u32string _obj) {
|
||||||
_obj[iii] = localToLower(_obj[iii]);
|
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||||
|
_obj[iii] = localToLower(_obj[iii]);
|
||||||
|
}
|
||||||
|
return _obj;
|
||||||
}
|
}
|
||||||
return _obj;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
std::string etk::toupper(std::string _obj) {
|
std::string etk::toupper(std::string _obj) {
|
||||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||||
@ -665,13 +681,14 @@ std::string etk::toupper(std::string _obj) {
|
|||||||
}
|
}
|
||||||
return _obj;
|
return _obj;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string etk::toupper(std::u32string _obj) {
|
std::u32string etk::toupper(std::u32string _obj) {
|
||||||
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
for(size_t iii=0 ; iii<_obj.size() ; iii++) {
|
||||||
_obj[iii] = localToUpper(_obj[iii]);
|
_obj[iii] = localToUpper(_obj[iii]);
|
||||||
|
}
|
||||||
|
return _obj;
|
||||||
}
|
}
|
||||||
return _obj;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
bool etk::end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
bool etk::end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||||
if (_val.size() == 0) {
|
if (_val.size() == 0) {
|
||||||
@ -699,33 +716,34 @@ bool etk::end_with(const std::string& _obj, const std::string& _val, bool _caseS
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
bool etk::end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
bool etk::end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||||
if (_val.size() == 0) {
|
if (_val.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_val.size() > _obj.size()) {
|
if (_val.size() > _obj.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (true == _caseSensitive) {
|
if (true == _caseSensitive) {
|
||||||
|
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||||
|
iii>=0 && jjj>=0;
|
||||||
|
iii--, jjj--) {
|
||||||
|
if (_obj[jjj] != _val[iii]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||||
iii>=0 && jjj>=0;
|
iii>=0 && jjj>=0;
|
||||||
iii--, jjj--) {
|
iii--, jjj--) {
|
||||||
if (_obj[jjj] != _val[iii]) {
|
if (std::tolower(_val[iii]) != std::tolower(_obj[jjj])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
#endif
|
||||||
iii>=0 && jjj>=0;
|
|
||||||
iii--, jjj--) {
|
|
||||||
if (std::tolower(_val[iii]) != std::tolower(_obj[jjj])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool etk::start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
bool etk::start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive) {
|
||||||
if (_val.size() == 0) {
|
if (_val.size() == 0) {
|
||||||
@ -753,45 +771,46 @@ bool etk::start_with(const std::string& _obj, const std::string& _val, bool _cas
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
bool etk::start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
bool etk::start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive) {
|
||||||
if (_val.size() == 0) {
|
if (_val.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_val.size() > _obj.size()) {
|
if (_val.size() > _obj.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (true == _caseSensitive) {
|
if (true == _caseSensitive) {
|
||||||
|
for( size_t iii = 0;
|
||||||
|
iii < _val.size();
|
||||||
|
iii++) {
|
||||||
|
if (_obj[iii] != _val[iii]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for( size_t iii = 0;
|
for( size_t iii = 0;
|
||||||
iii < _val.size();
|
iii < _val.size();
|
||||||
iii++) {
|
iii++) {
|
||||||
if (_obj[iii] != _val[iii]) {
|
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for( size_t iii = 0;
|
|
||||||
iii < _val.size();
|
|
||||||
iii++) {
|
|
||||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::u32string etk::replace(const std::u32string& _obj, char32_t _val, char32_t _replace) {
|
std::u32string etk::replace(const std::u32string& _obj, char32_t _val, char32_t _replace) {
|
||||||
std::u32string copy(_obj);
|
std::u32string copy(_obj);
|
||||||
for( size_t iii = 0;
|
for( size_t iii = 0;
|
||||||
iii < copy.size();
|
iii < copy.size();
|
||||||
iii++) {
|
iii++) {
|
||||||
if (copy[iii] == _val) {
|
if (copy[iii] == _val) {
|
||||||
copy[iii] = _replace;
|
copy[iii] = _replace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return copy;
|
||||||
}
|
}
|
||||||
return copy;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
std::string etk::replace(const std::string& _obj, char _val, char _replace) {
|
std::string etk::replace(const std::string& _obj, char _val, char _replace) {
|
||||||
std::string copy(_obj);
|
std::string copy(_obj);
|
||||||
@ -833,35 +852,36 @@ std::string etk::extract_line(const std::string& _obj, int32_t _pos) {
|
|||||||
}
|
}
|
||||||
return std::string(_obj, startPos, stopPos - startPos);
|
return std::string(_obj, startPos, stopPos - startPos);
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::u32string etk::extract_line(const std::u32string& _obj, int32_t _pos) {
|
std::u32string etk::extract_line(const std::u32string& _obj, int32_t _pos) {
|
||||||
// search back : '\n'
|
// search back : '\n'
|
||||||
size_t startPos = _obj.rfind('\n', _pos);
|
size_t startPos = _obj.rfind('\n', _pos);
|
||||||
if ((int64_t)startPos == _pos) {
|
if ((int64_t)startPos == _pos) {
|
||||||
startPos = 0;
|
startPos = 0;
|
||||||
} else {
|
} else {
|
||||||
startPos++;
|
startPos++;
|
||||||
}
|
}
|
||||||
// search forward : '\n'
|
// search forward : '\n'
|
||||||
size_t stopPos = _pos;
|
size_t stopPos = _pos;
|
||||||
if (_obj[_pos] != '\n') {
|
if (_obj[_pos] != '\n') {
|
||||||
stopPos = _obj.find('\n', _pos);
|
stopPos = _obj.find('\n', _pos);
|
||||||
if ((int64_t)stopPos == _pos) {
|
if ((int64_t)stopPos == _pos) {
|
||||||
|
stopPos = _obj.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startPos == std::string::npos) {
|
||||||
|
startPos = 0;
|
||||||
|
} else if (startPos >= _obj.size() ) {
|
||||||
|
return U"";
|
||||||
|
}
|
||||||
|
if (stopPos == std::string::npos) {
|
||||||
|
return U"";
|
||||||
|
} else if (stopPos >= _obj.size() ) {
|
||||||
stopPos = _obj.size();
|
stopPos = _obj.size();
|
||||||
}
|
}
|
||||||
|
return std::u32string(_obj, startPos, stopPos - startPos);
|
||||||
}
|
}
|
||||||
if (startPos == std::string::npos) {
|
#endif
|
||||||
startPos = 0;
|
|
||||||
} else if (startPos >= _obj.size() ) {
|
|
||||||
return U"";
|
|
||||||
}
|
|
||||||
if (stopPos == std::string::npos) {
|
|
||||||
return U"";
|
|
||||||
} else if (stopPos >= _obj.size() ) {
|
|
||||||
stopPos = _obj.size();
|
|
||||||
}
|
|
||||||
return std::u32string(_obj, startPos, stopPos - startPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> etk::split(const std::string& _input, char _val) {
|
std::vector<std::string> etk::split(const std::string& _input, char _val) {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
@ -878,20 +898,22 @@ std::vector<std::string> etk::split(const std::string& _input, char _val) {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _val) {
|
#if __cplusplus >= 201103L
|
||||||
std::vector<std::u32string> list;
|
std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _val) {
|
||||||
size_t lastStartPos = 0;
|
std::vector<std::u32string> list;
|
||||||
for(size_t iii=0; iii<_input.size(); iii++) {
|
size_t lastStartPos = 0;
|
||||||
if (_input[iii]==_val) {
|
for(size_t iii=0; iii<_input.size(); iii++) {
|
||||||
list.push_back(std::u32string(_input, lastStartPos, iii - lastStartPos));
|
if (_input[iii]==_val) {
|
||||||
lastStartPos = iii+1;
|
list.push_back(std::u32string(_input, lastStartPos, iii - lastStartPos));
|
||||||
|
lastStartPos = iii+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (lastStartPos<_input.size()) {
|
||||||
|
list.push_back(std::u32string(_input, lastStartPos));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
if (lastStartPos<_input.size()) {
|
#endif
|
||||||
list.push_back(std::u32string(_input, lastStartPos));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
long double etk::string_to_long_double(const std::string& _str) {
|
long double etk::string_to_long_double(const std::string& _str) {
|
||||||
long double ret = 0;
|
long double ret = 0;
|
||||||
@ -981,27 +1003,31 @@ void etk::sort(std::vector<std::string *> &_list) {
|
|||||||
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
void etk::sort(std::vector<std::u32string *> &_list) {
|
void etk::sort(std::vector<std::u32string *> &_list) {
|
||||||
std::vector<std::u32string *> tmpList(_list);
|
std::vector<std::u32string *> tmpList(_list);
|
||||||
_list.clear();
|
_list.clear();
|
||||||
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
||||||
size_t findPos = 0;
|
size_t findPos = 0;
|
||||||
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
||||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||||
if (*tmpList[iii] > *_list[jjj]) {
|
if (*tmpList[iii] > *_list[jjj]) {
|
||||||
findPos = jjj+1;
|
findPos = jjj+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//EWOL_DEBUG("position="<<findPos);
|
||||||
|
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
||||||
}
|
}
|
||||||
//EWOL_DEBUG("position="<<findPos);
|
|
||||||
_list.insert(_list.begin()+findPos, tmpList[iii]);
|
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> bool from_string<std::u32string>(std::u32string& _variableRet, const std::string& _value) {
|
#if __cplusplus >= 201103L
|
||||||
_variableRet = etk::to_u32string(_value);
|
template<> bool from_string<std::u32string>(std::u32string& _variableRet, const std::string& _value) {
|
||||||
return true;
|
_variableRet = etk::to_u32string(_value);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
template<> bool from_string<std::string>(std::string& _variableRet, const std::string& _value) {
|
template<> bool from_string<std::string>(std::string& _variableRet, const std::string& _value) {
|
||||||
_variableRet = _value;
|
_variableRet = _value;
|
||||||
return true;
|
return true;
|
||||||
@ -1054,55 +1080,56 @@ namespace etk {
|
|||||||
_variableRet = string_to_bool(_value);
|
_variableRet = string_to_bool(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
template<> bool from_string<int8_t>(int8_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<int8_t>(int8_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_int8_t(_value);
|
_variableRet = string_to_int8_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<int16_t>(int16_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<int16_t>(int16_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_int16_t(_value);
|
_variableRet = string_to_int16_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<int32_t>(int32_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<int32_t>(int32_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_int32_t(_value);
|
_variableRet = string_to_int32_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<int64_t>(int64_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<int64_t>(int64_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_int64_t(_value);
|
_variableRet = string_to_int64_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uint8_t>(uint8_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<uint8_t>(uint8_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_uint8_t(_value);
|
_variableRet = string_to_uint8_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uint16_t>(uint16_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<uint16_t>(uint16_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_uint16_t(_value);
|
_variableRet = string_to_uint16_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uint32_t>(uint32_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<uint32_t>(uint32_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_uint32_t(_value);
|
_variableRet = string_to_uint32_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<uint64_t>(uint64_t& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<uint64_t>(uint64_t& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_uint64_t(_value);
|
_variableRet = string_to_uint64_t(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<float>(float& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<float>(float& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_float(_value);
|
_variableRet = string_to_float(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<double>(double& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<double>(double& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_double(_value);
|
_variableRet = string_to_double(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<long double>(long double& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<long double>(long double& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_long_double(_value);
|
_variableRet = string_to_long_double(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<bool>(bool& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<bool>(bool& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet = string_to_bool(_value);
|
_variableRet = string_to_bool(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1122,23 +1149,24 @@ std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::string>
|
|||||||
_os << "}";
|
_os << "}";
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
std::ostream& std::operator <<(std::ostream& _os, const std::u32string& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::u32string& _obj) {
|
||||||
_os << etk::to_string(_obj).c_str();
|
_os << etk::to_string(_obj).c_str();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
|
|
||||||
_os << "{";
|
|
||||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
|
||||||
if (iii>0) {
|
|
||||||
_os << " ~ ";
|
|
||||||
}
|
|
||||||
_os << _obj[iii];
|
|
||||||
}
|
}
|
||||||
_os << "}";
|
|
||||||
return _os;
|
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
|
||||||
}
|
_os << "{";
|
||||||
|
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||||
|
if (iii>0) {
|
||||||
|
_os << " ~ ";
|
||||||
|
}
|
||||||
|
_os << _obj[iii];
|
||||||
|
}
|
||||||
|
_os << "}";
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::ostream& std::operator <<(std::ostream& _os, const std::vector<float>& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::vector<float>& _obj) {
|
||||||
_os << "{";
|
_os << "{";
|
||||||
|
131
etk/stdTools.h
131
etk/stdTools.h
@ -41,7 +41,9 @@ namespace u32char {
|
|||||||
|
|
||||||
char32_t changeOrder(char32_t _val);
|
char32_t changeOrder(char32_t _val);
|
||||||
int8_t convertUtf8(char32_t _val, char _output[5]);
|
int8_t convertUtf8(char32_t _val, char _output[5]);
|
||||||
std::string convertToUtf8(const std::u32string& _input);
|
#if __cplusplus >= 201103L
|
||||||
|
std::string convertToUtf8(const std::u32string& _input);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace utf8 {
|
namespace utf8 {
|
||||||
@ -59,8 +61,9 @@ namespace utf8 {
|
|||||||
bool theoricFirst(const char _input);
|
bool theoricFirst(const char _input);
|
||||||
|
|
||||||
char32_t convertChar32(const char* _input);
|
char32_t convertChar32(const char* _input);
|
||||||
std::u32string convertUnicode(const std::string& _input);
|
#if __cplusplus >= 201103L
|
||||||
|
std::u32string convertUnicode(const std::string& _input);
|
||||||
|
#endif
|
||||||
class iterator {
|
class iterator {
|
||||||
private:
|
private:
|
||||||
char32_t m_value; //!< store vlue to prevent multiple calcule of getting the data
|
char32_t m_value; //!< store vlue to prevent multiple calcule of getting the data
|
||||||
@ -384,88 +387,134 @@ namespace std {
|
|||||||
namespace etk {
|
namespace etk {
|
||||||
// these declaration is to prevent some under template declaration of unknown type
|
// these declaration is to prevent some under template declaration of unknown type
|
||||||
template <class TYPE> std::string to_string(const TYPE& _variable);
|
template <class TYPE> std::string to_string(const TYPE& _variable);
|
||||||
template <class TYPE> std::u32string to_u32string(const TYPE& _variable);
|
#if __cplusplus >= 201103L
|
||||||
|
template <class TYPE> std::u32string to_u32string(const TYPE& _variable);
|
||||||
|
#endif
|
||||||
// these declaration is to prevent some under template declaration of unknown type
|
// these declaration is to prevent some under template declaration of unknown type
|
||||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value);
|
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value);
|
||||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value);
|
#if __cplusplus >= 201103L
|
||||||
|
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value);
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO : Change this in :
|
// TODO : Change this in :
|
||||||
// TODO : template <typename TYPE> TYPE string_to<TYPE>(const std::u32string& _value); ==> check exceptions ...
|
// TODO : template <typename TYPE> TYPE string_to<TYPE>(const std::u32string& _value); ==> check exceptions ...
|
||||||
long double string_to_long_double(const std::string& _str);
|
long double string_to_long_double(const std::string& _str);
|
||||||
long double string_to_long_double(const std::u32string& _str);
|
#if __cplusplus >= 201103L
|
||||||
|
long double string_to_long_double(const std::u32string& _str);
|
||||||
|
#endif
|
||||||
|
|
||||||
double string_to_double(const std::string& _str);
|
double string_to_double(const std::string& _str);
|
||||||
double string_to_double(const std::u32string& _str);
|
#if __cplusplus >= 201103L
|
||||||
|
double string_to_double(const std::u32string& _str);
|
||||||
|
#endif
|
||||||
|
|
||||||
float string_to_float(const std::string& _str);
|
float string_to_float(const std::string& _str);
|
||||||
float string_to_float(const std::u32string& _str);
|
#if __cplusplus >= 201103L
|
||||||
|
float string_to_float(const std::u32string& _str);
|
||||||
|
#endif
|
||||||
|
|
||||||
int8_t string_to_int8_t(const std::string& _str, int _base = 10);
|
int8_t string_to_int8_t(const std::string& _str, int _base = 10);
|
||||||
int8_t string_to_int8_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
int8_t string_to_int8_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
int16_t string_to_int16_t(const std::string& _str, int _base = 10);
|
int16_t string_to_int16_t(const std::string& _str, int _base = 10);
|
||||||
int16_t string_to_int16_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
int16_t string_to_int16_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t string_to_int32_t(const std::string& _str, int _base = 10);
|
int32_t string_to_int32_t(const std::string& _str, int _base = 10);
|
||||||
int32_t string_to_int32_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
int32_t string_to_int32_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
int64_t string_to_int64_t(const std::string& _str, int _base = 10);
|
int64_t string_to_int64_t(const std::string& _str, int _base = 10);
|
||||||
int64_t string_to_int64_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
int64_t string_to_int64_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t string_to_uint8_t(const std::string& _str, int _base = 10);
|
uint8_t string_to_uint8_t(const std::string& _str, int _base = 10);
|
||||||
uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint16_t string_to_uint16_t(const std::string& _str, int _base = 10);
|
uint16_t string_to_uint16_t(const std::string& _str, int _base = 10);
|
||||||
uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t string_to_uint32_t(const std::string& _str, int _base = 10);
|
uint32_t string_to_uint32_t(const std::string& _str, int _base = 10);
|
||||||
uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t string_to_uint64_t(const std::string& _str, int _base = 10);
|
uint64_t string_to_uint64_t(const std::string& _str, int _base = 10);
|
||||||
uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10);
|
#if __cplusplus >= 201103L
|
||||||
|
uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool string_to_bool(const std::string& _str);
|
bool string_to_bool(const std::string& _str);
|
||||||
bool string_to_bool(const std::u32string& _str);
|
#if __cplusplus >= 201103L
|
||||||
|
bool string_to_bool(const std::u32string& _str);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string tolower(std::string _obj);
|
std::string tolower(std::string _obj);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string tolower(std::u32string _obj);
|
//! @previous
|
||||||
|
std::u32string tolower(std::u32string _obj);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string toupper(std::string _obj);
|
std::string toupper(std::string _obj);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string toupper(std::u32string _obj);
|
//! @previous
|
||||||
|
std::u32string toupper(std::u32string _obj);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool compare_no_case(const std::string& _obj, const std::string& _val);
|
bool compare_no_case(const std::string& _obj, const std::string& _val);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val);
|
//! @previous
|
||||||
|
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
//! @previous
|
||||||
|
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
//! @previous
|
||||||
|
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string replace(const std::string& _obj, char _val, char _replace);
|
std::string replace(const std::string& _obj, char _val, char _replace);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
|
//! @previous
|
||||||
|
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string extract_line(const std::string& _obj, int32_t _pos);
|
std::string extract_line(const std::string& _obj, int32_t _pos);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
|
//! @previous
|
||||||
|
std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string& _input, char _val);
|
std::vector<std::string> split(const std::string& _input, char _val);
|
||||||
//! @previous
|
#if __cplusplus >= 201103L
|
||||||
std::vector<std::u32string> split(const std::u32string& _input, char32_t _val);
|
//! @previous
|
||||||
|
std::vector<std::u32string> split(const std::u32string& _input, char32_t _val);
|
||||||
|
#endif
|
||||||
|
|
||||||
void sort(std::vector<std::u32string *>& _list);
|
|
||||||
//! @previous
|
|
||||||
void sort(std::vector<std::string *>& _list);
|
void sort(std::vector<std::string *>& _list);
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
//! @previous
|
||||||
|
void sort(std::vector<std::u32string *>& _list);
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T, typename T2> bool isIn(const T& _val, const std::vector<T2>& _list) {
|
template<typename T, typename T2> bool isIn(const T& _val, const std::vector<T2>& _list) {
|
||||||
for (auto &it : _list) {
|
for (size_t iii=0; iii<_list.size(); ++iii) {
|
||||||
if (it == _val) {
|
if (_list[iii] == _val) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,8 +531,10 @@ namespace std {
|
|||||||
namespace std {
|
namespace std {
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::string& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::string& _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<std::string>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<std::string>& _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::u32string& _obj);
|
#if __cplusplus >= 201103L
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::u32string& _obj);
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj);
|
||||||
|
#endif
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<float>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<float>& _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<double>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<double>& _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<int64_t>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<int64_t>& _obj);
|
||||||
|
@ -41,8 +41,15 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ETK_ENABLE_NULLPTR
|
#if __cplusplus <= 201103L
|
||||||
#define nullptr NULL
|
#define nullptr NULL
|
||||||
|
typedef uint32_t char32_t;
|
||||||
|
namespace boost {
|
||||||
|
// just define
|
||||||
|
}
|
||||||
|
namespace std11 = boost;
|
||||||
|
#else
|
||||||
|
namespace std11 = std;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
17
lutin_etk.py
17
lutin_etk.py
@ -31,9 +31,16 @@ def create(target):
|
|||||||
if target.name=="IOs":
|
if target.name=="IOs":
|
||||||
myModule.add_src_file('etk/logIOs.m')
|
myModule.add_src_file('etk/logIOs.m')
|
||||||
|
|
||||||
# name of the dependency
|
# force old version of C++
|
||||||
myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True)
|
target.xx_version = 4005000
|
||||||
myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP")
|
|
||||||
|
if target.config["compilator"] == "gcc" \
|
||||||
|
and target.xx_version < 4007000:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# name of the dependency
|
||||||
|
myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True)
|
||||||
|
myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP")
|
||||||
|
|
||||||
if target.config["mode"] == "release":
|
if target.config["mode"] == "release":
|
||||||
# TODO : The other way is to remove this ...
|
# TODO : The other way is to remove this ...
|
||||||
@ -48,8 +55,8 @@ def create(target):
|
|||||||
|
|
||||||
if target.config["compilator"] == "gcc" \
|
if target.config["compilator"] == "gcc" \
|
||||||
and target.xx_version < 4007000:
|
and target.xx_version < 4007000:
|
||||||
myModule.add_export_flag_CC("-DETK_ENABLE_NULLPTR")
|
myModule.add_optionnal_module_depend('boost', "ETK_BUILD_BOOST", export=True)
|
||||||
|
myModule.add_export_path(tools.get_current_path(__file__) + "/etk/boost_to_std")
|
||||||
|
|
||||||
if target.name=="Windows":
|
if target.name=="Windows":
|
||||||
None
|
None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user