[DEV] WORK on a port for BOOST

This commit is contained in:
Edouard DUPIN 2015-02-24 22:20:11 +01:00
parent 26ce81aec5
commit 2fb4b79749
29 changed files with 1463 additions and 1609 deletions

View File

@ -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

View File

@ -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
template<> std::u32string to_u32string<Color<uint16_t, 1>>(const Color<uint16_t, 1>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint16_t, 2>>(const Color<uint16_t, 2>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint16_t, 3>>(const Color<uint16_t, 3>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint16_t, 4>>(const Color<uint16_t, 4>& _val) {
return to_u32string(_val.getString()); 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;
} }

View File

@ -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
template<> std::u32string to_u32string<Color<uint32_t, 1>>(const Color<uint32_t, 1>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint32_t, 2>>(const Color<uint32_t, 2>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint32_t, 3>>(const Color<uint32_t, 3>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint32_t, 4>>(const Color<uint32_t, 4>& _val) {
return to_u32string(_val.getString()); 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;
} }

View File

@ -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
template<> std::u32string to_u32string<Color<uint8_t, 1>>(const Color<uint8_t, 1>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint8_t, 2>>(const Color<uint8_t, 2>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint8_t, 3>>(const Color<uint8_t, 3>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<uint8_t, 4>>(const Color<uint8_t, 4>& _val) {
return to_u32string(_val.getString()); 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;
} }

View File

@ -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
template<> std::u32string to_u32string<Color<double, 1>>(const Color<double, 1>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<double, 2>>(const Color<double, 2>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<double, 3>>(const Color<double, 3>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<double, 4>>(const Color<double, 4>& _val) {
return to_u32string(_val.getString()); 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;
} }

View File

@ -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
template<> std::u32string to_u32string<Color<float, 1>>(const Color<float, 1>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<float, 2>>(const Color<float, 2>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<float, 3>>(const Color<float, 3>& _val) {
return to_u32string(_val.getString()); 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
template<> std::u32string to_u32string<Color<float, 4>>(const Color<float, 4>& _val) {
return to_u32string(_val.getString()); 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;
} }

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -14,16 +14,12 @@
extern "C" { extern "C" {
#include <minizip/unzip.h> #include <minizip/unzip.h>
} }
#endif namespace etk {
namespace etk {
namespace archive { namespace archive {
class Zip : public etk::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();
@ -31,7 +27,9 @@ namespace etk {
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

View File

@ -0,0 +1,7 @@
#ifndef __ETK_CHRONO_FROM_BOOST_H__
#define __ETK_CHRONO_FROM_BOOST_H__
#include <boost/chrono.hpp>
#endif

View 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

View 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

View 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

View 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

View File

@ -0,0 +1,7 @@
#ifndef __ETK_THREAD_FROM_BOOST_H__
#define __ETK_THREAD_FROM_BOOST_H__
#include <boost/thread/thread.hpp>
#endif

View File

@ -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,10 +228,11 @@ static std::map<uint32_t, std::string>& getThreadList() {
} }
std::string etk::log::getThreadName() { std::string etk::log::getThreadName() {
#if __cplusplus >= 201103L
std::map<uint32_t,std::string>& list = getThreadList(); std::map<uint32_t,std::string>& list = getThreadList();
uint32_t threadID = getThreadID(); uint32_t threadID = getThreadID();
std::string out; std::string out;
static std::mutex g_lock; static std11::mutex g_lock;
g_lock.lock(); g_lock.lock();
auto it = list.find(threadID); auto it = list.find(threadID);
if (it != list.end()) { if (it != list.end()) {
@ -235,13 +240,17 @@ std::string etk::log::getThreadName() {
} }
g_lock.unlock(); g_lock.unlock();
return out; return out;
#else
return "";
#endif
} }
void etk::log::setThreadName(const std::string& _name) { void etk::log::setThreadName(const std::string& _name) {
#if __cplusplus >= 201103L
std::map<uint32_t,std::string>& list = getThreadList(); std::map<uint32_t,std::string>& list = getThreadList();
uint32_t threadID = getThreadID(); uint32_t threadID = getThreadID();
static std::mutex g_lock; static std11::mutex g_lock;
g_lock.lock(); g_lock.lock();-Wc++0x-compat
auto it = list.find(threadID); auto it = list.find(threadID);
if (it == list.end()) { if (it == list.end()) {
list.insert(std::pair<uint32_t, std::string>(threadID,_name)); list.insert(std::pair<uint32_t, std::string>(threadID,_name));
@ -249,13 +258,15 @@ void etk::log::setThreadName(const std::string& _name) {
it->second = _name; it->second = _name;
} }
g_lock.unlock(); g_lock.unlock();
#endif
} }
uint32_t etk::log::getThreadID() { uint32_t etk::log::getThreadID() {
#if __cplusplus >= 201103L
uint32_t out = 0; uint32_t out = 0;
std::thread::id this_id = std::this_thread::get_id(); std::thread::id this_id = std::this_thread::get_id();
uint64_t iddd = std::hash<std::thread::id>()(this_id); uint64_t iddd = std::hash<std::thread::id>()(this_id);
static std::mutex g_lock; static std11::mutex g_lock;
g_lock.lock(); g_lock.lock();
static std::map<uint64_t, uint32_t> g_list; static std::map<uint64_t, uint32_t> g_list;
auto it = g_list.find(iddd); auto it = g_list.find(iddd);
@ -270,6 +281,9 @@ uint32_t etk::log::getThreadID() {
} }
g_lock.unlock(); g_lock.unlock();
return out; 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,6 +407,7 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
*pointer++ = ' '; *pointer++ = ' ';
*pointer = '\0'; *pointer = '\0';
} }
#if __cplusplus >= 201103L
if(getThreadId() == true) { if(getThreadId() == true) {
// display thread ID // display thread ID
uint32_t iddd = etk::log::getThreadID(); uint32_t iddd = etk::log::getThreadID();
@ -417,6 +432,7 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
*pointer++ = ' '; *pointer++ = ' ';
*pointer = '\0'; *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);

View File

@ -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,6 +118,7 @@ namespace etk {
str += ")"; str += ")";
return str; return str;
} }
#if __cplusplus >= 201103L
template<> Vector2D<bool>::operator std::u32string() const { template<> Vector2D<bool>::operator std::u32string() const {
std::u32string str; std::u32string str;
str = U"("; str = U"(";
@ -127,6 +128,7 @@ namespace etk {
str += U")"; str += U")";
return str; 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,6 +154,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this); TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
} }
#if __cplusplus >= 201103L
template<> Vector2D<bool>::Vector2D(const std::u32string& _str) { template<> Vector2D<bool>::Vector2D(const std::u32string& _str) {
m_floats[0] = false; m_floats[0] = false;
m_floats[1] = false; m_floats[1] = false;
@ -176,6 +179,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this); TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
} }
#endif
template<> Vector2D<int32_t>::operator std::string() const { template<> Vector2D<int32_t>::operator std::string() const {
std::string str; std::string str;
@ -186,6 +190,7 @@ namespace etk {
str += ")"; str += ")";
return str; return str;
} }
#if __cplusplus >= 201103L
template<> Vector2D<int32_t>::operator std::u32string() const { template<> Vector2D<int32_t>::operator std::u32string() const {
std::u32string str; std::u32string str;
str = U"("; str = U"(";
@ -195,6 +200,7 @@ namespace etk {
str += U")"; str += U")";
return str; 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,6 +227,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
#if __cplusplus >= 201103L
template<> Vector2D<int32_t>::Vector2D(const std::u32string& _str) { template<> Vector2D<int32_t>::Vector2D(const std::u32string& _str) {
m_floats[0] = 0; m_floats[0] = 0;
m_floats[1] = 0; m_floats[1] = 0;
@ -246,6 +253,7 @@ namespace etk {
} }
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,7 +264,7 @@ 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"(";
@ -266,6 +274,7 @@ namespace etk {
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,8 +300,8 @@ 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 :
@ -316,6 +325,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
#endif
template<> Vector2D<float>::operator std::string() const { template<> Vector2D<float>::operator std::string() const {
std::string str; std::string str;
@ -326,6 +336,7 @@ namespace etk {
str += ")"; str += ")";
return str; return str;
} }
#if __cplusplus >= 201103L
template<> Vector2D<float>::operator std::u32string() const { template<> Vector2D<float>::operator std::u32string() const {
std::u32string str; std::u32string str;
str = U"("; str = U"(";
@ -335,6 +346,7 @@ namespace etk {
str += U")"; str += U")";
return str; 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,6 +372,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
#if __cplusplus >= 201103L
template<> Vector2D<float>::Vector2D(const std::u32string& _str) { template<> Vector2D<float>::Vector2D(const std::u32string& _str) {
m_floats[0] = 0; m_floats[0] = 0;
m_floats[1] = 0; m_floats[1] = 0;
@ -384,6 +397,7 @@ namespace etk {
} }
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
} }
#endif
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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<vec2>(const vec2& _obj) { template<> std::u32string to_u32string<vec2>(const vec2& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<ivec2>(const ivec2& _obj) { template<> std::u32string to_u32string<ivec2>(const ivec2& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<uivec2>(const uivec2& _obj) { template<> std::u32string to_u32string<uivec2>(const uivec2& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<bvec2>(const bvec2& _obj) { template<> std::u32string to_u32string<bvec2>(const bvec2& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<vec2>(vec2& _variableRet, const std::u32string& _value) { template<> bool from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) { template<> bool from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) { template<> bool from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) { template<> bool from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value)); return from_string(_variableRet, etk::to_string(_value));
} }
#endif
}; };

View File

@ -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);
#if __cplusplus >= 201103L
Vector2D(const std::u32string& _str); 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;
#if __cplusplus >= 201103L
operator std::u32string() const; 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

View File

@ -124,9 +124,11 @@ namespace etk {
str += ")"; str += ")";
return str; return str;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<vec3>(const vec3& _obj) { template<> std::u32string to_u32string<vec3>(const vec3& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<ivec3>(const ivec3& _obj) { template<> std::u32string to_u32string<ivec3>(const ivec3& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<uivec3>(const uivec3& _obj) { template<> std::u32string to_u32string<uivec3>(const uivec3& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> std::u32string to_u32string<bvec3>(const bvec3& _obj) { template<> std::u32string to_u32string<bvec3>(const bvec3& _obj) {
return etk::to_u32string(etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<vec3>(vec3& _variableRet, const std::u32string& _value) { template<> bool from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) { template<> bool from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) { template<> bool from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_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;
} }
#if __cplusplus >= 201103L
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) { template<> bool from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value)); return from_string(_variableRet, etk::to_string(_value));
} }
#endif
}; };

View File

@ -159,7 +159,11 @@ namespace etk {
#ifdef ETK_BUILD_LINEARMATH #ifdef ETK_BUILD_LINEARMATH
return btSqrt(length2()); return btSqrt(length2());
#else #else
#if __cplusplus >= 201103L
return std::sqrt(length2()); return std::sqrt(length2());
#else
return sqrt(length2());
#endif
#endif #endif
} }

View File

@ -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
std::u32string getUApplicationPath() {
return etk::to_u32string(getApplicationPath()); 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
std::u32string etk::getUUserHomeFolder() {
return etk::to_u32string(baseFolderHome); 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
std::u32string etk::getUUserRunFolder() {
return etk::to_u32string(baseRunPath); return etk::to_u32string(baseRunPath);
} }
#endif
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
@ -484,8 +490,8 @@ 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),
@ -493,13 +499,14 @@ etk::FSNode::FSNode(const std::u32string& _nodeName) :
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 #endif
{ {
privateSetName(_nodeName); privateSetName(_nodeName);
} }
#endif
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
void etk::FSNode::privateSetName(const std::u32string& _newName) {
privateSetName(etk::to_string(_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
bool directCheckFile(std::u32string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
return directCheckFile(etk::to_string(_tmpFileNameDirect)); 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
void etk::FSNode::setName(const std::u32string& _newName) {
privateSetName(_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
std::u32string etk::FSNode::getUNameFolder() const {
return etk::to_u32string(getNameFolder()); 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
std::u32string etk::FSNode::getUFileSystemName() const {
return etk::to_u32string(getFileSystemName()); 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
std::u32string etk::FSNode::getUName() const {
return etk::to_u32string(getName()); 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
std::u32string etk::FSNode::getUNameFile() const {
return etk::to_u32string(getNameFile()); 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
std::u32string etk::FSNode::getURelativeFolder() const {
return etk::to_u32string(getRelativeFolder()); 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
bool etk::FSNode::move(const std::u32string& _path) {
return move(etk::to_string(_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
std::u32string etk::FSNode::timeUCreatedString() const {
return etk::to_u32string(timeCreatedString()); 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
std::u32string etk::FSNode::timeUModifiedString() const {
return etk::to_u32string(timeModifiedString()); 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
std::u32string etk::FSNode::timeUAccessedString() const {
return etk::to_u32string(timeAccessedString()); 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
void etk::FSNode::folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable) {
_output.clear(); _output.clear();
std::vector<std::string> tmpVal; std::vector<std::string> tmpVal;
folderGetRecursiveFiles(tmpVal, _recursiveEnable); folderGetRecursiveFiles(tmpVal, _recursiveEnable);
for (size_t iii=0; iii<tmpVal.size(); ++iii) { for (size_t iii=0; iii<tmpVal.size(); ++iii) {
_output.push_back(to_u32string(tmpVal[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
std::u32string etk::FSNode::fileUGetExtention() {
return etk::to_u32string(fileGetExtention()); 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 << "'");
#if __cplusplus >= 201103L
auto it = g_listTheme.find(_refName); 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
void etk::theme::setName(const std::u32string& _refName, const std::u32string& _folderName) {
setName(etk::to_string(_refName), etk::to_string(_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
std::u32string etk::theme::getName(const std::u32string& _refName) {
return etk::to_u32string(getName(etk::to_string(_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;
#if __cplusplus >= 201103L
for (auto &it : g_listTheme) { for (auto &it : g_listTheme) {
keys.push_back(it.first); 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> etk::theme::listU() {
std::vector<std::u32string> keys; std::vector<std::u32string> keys;
for (auto &it : g_listTheme) { for (auto &it : g_listTheme) {
keys.push_back(etk::to_u32string(it.first)); 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) {
#if __cplusplus >= 201103L
auto it = g_listThemeDefault.find(_refName); 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
void etk::theme::setNameDefault(const std::u32string& _refName, const std::u32string& _folderName) {
setNameDefault(etk::to_string(_refName), etk::to_string(_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) {
#if __cplusplus >= 201103L
auto it=g_listThemeDefault.find(_refName); 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
std::u32string etk::theme::getNameDefault(const std::u32string& _refName) {
return etk::to_u32string(getNameDefault(etk::to_string(_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
bool etk::FSNodeRemove(const std::u32string& _path) {
return FSNodeRemove(etk::to_string(_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
int64_t etk::FSNodeGetCount(const std::u32string& _path) {
return FSNodeGetCount(etk::to_string(_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
bool etk::FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
return FSNodeCreate(etk::to_string(_path), _right, _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
bool etk::FSNodeExist(const std::u32string& _path) {
return FSNodeExist(etk::to_string(_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
bool etk::FSNodeMove(const std::u32string& _path1, const std::u32string& _path2) {
return FSNodeMove(etk::to_string(_path1), etk::to_string(_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
etk::FSNodeRight etk::FSNodeGetRight(const std::u32string& _path) {
return FSNodeGetRight(etk::to_string(_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
enum etk::typeNode etk::FSNodeGetType(const std::u32string& _path) {
return FSNodeGetType(etk::to_string(_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
uint64_t etk::FSNodeGetTimeCreated(const std::u32string& _path) {
return FSNodeGetTimeCreated(etk::to_string(_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
uint64_t etk::FSNodeGetTimeModified(const std::u32string& _path) {
return FSNodeGetTimeModified(etk::to_string(_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
uint64_t etk::FSNodeGetTimeAccessed(const std::u32string& _path) {
return FSNodeGetTimeAccessed(etk::to_string(_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
bool etk::FSNodeTouch(const std::u32string& _path) {
return FSNodeTouch(etk::to_string(_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
bool etk::FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite) {
return FSNodeEcho(etk::to_string(_path), etk::to_string(_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
bool etk::FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite) {
return FSNodeEchoAdd(etk::to_string(_path), etk::to_string(_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
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
return FSNodeHistory(etk::to_string(_path), _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;

View File

@ -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 = "~");
#if __cplusplus >= 201103L
FSNode(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
void privateSetName(const std::u32string& _newName); 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);
#if __cplusplus >= 201103L
void setName(const std::u32string& _newName); 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;
#if __cplusplus >= 201103L
std::u32string getUFileSystemName() const; 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;
#if __cplusplus >= 201103L
std::u32string getUNameFolder() const; 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;
#if __cplusplus >= 201103L
std::u32string getUName() const; 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;
#if __cplusplus >= 201103L
std::u32string getUNameFile() const; 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;
#if __cplusplus >= 201103L
std::u32string getURelativeFolder() const; 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);
#if __cplusplus >= 201103L
bool move(const std::u32string& _path); 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;
#if __cplusplus >= 201103L
std::u32string timeUCreatedString() const; 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;
#if __cplusplus >= 201103L
std::u32string timeUModifiedString() const; 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;
#if __cplusplus >= 201103L
std::u32string timeUAccessedString() const; 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);
#if __cplusplus >= 201103L
void folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable=true); 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();
#if __cplusplus >= 201103L
std::u32string fileUGetExtention(); 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));
} }
#if __cplusplus >= 201103L
void fileWriteAll(const std::u32string& _value) { void fileWriteAll(const std::u32string& _value) {
fileWriteAll(u32char::convertToUtf8(_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();
#if __cplusplus >= 201103L
std::u32string getUUserHomeFolder(); 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();
#if __cplusplus >= 201103L
std::u32string getUUserRunFolder(); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
void setName(const std::u32string& _refName, const std::u32string& _folderName); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string getName(const std::u32string& _refName); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
void setNameDefault(const std::u32string& _refName, const std::u32string& _folderName); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string getNameDefault(const std::u32string& _refName); 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();
#if __cplusplus >= 201103L
//! @previous //! @previous
std::vector<std::u32string> listU(); 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);
#if __cplusplus >= 201103L
bool FSNodeRemove(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
int64_t FSNodeGetCount(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
bool FSNodeCreate(const std::u32string& _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);
#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);
#if __cplusplus >= 201103L
bool FSNodeExist(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
bool FSNodeMove(const std::u32string& _path1, const std::u32string& _path2); 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);
#if __cplusplus >= 201103L
etk::FSNodeRight FSNodeGetRight(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
enum etk::typeNode FSNodeGetType(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
uint64_t FSNodeGetTimeCreated(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
uint64_t FSNodeGetTimeModified(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
uint64_t FSNodeGetTimeAccessed(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
bool FSNodeTouch(const std::u32string& _path); 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);
#if __cplusplus >= 201103L
bool FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite); 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);
#if __cplusplus >= 201103L
bool FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite); 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);
#if __cplusplus >= 201103L
void FSNodeHistory(const std::u32string& _path, int32_t _historyCount); 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

View File

@ -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;

View File

@ -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);

View File

@ -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,6 +312,7 @@ char32_t utf8::iterator::operator* () {
#undef __class__ #undef __class__
#define __class__ "etk" #define __class__ "etk"
namespace etk { namespace etk {
#if __cplusplus >= 201103L
template<> std::string to_string<std::u32string>(const std::u32string& _input) { template<> std::string to_string<std::u32string>(const std::u32string& _input) {
std::string out; std::string out;
for (size_t iii=0; iii<_input.size(); ++iii) { for (size_t iii=0; iii<_input.size(); ++iii) {
@ -327,6 +329,7 @@ namespace etk {
out += output; out += output;
return out; 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,7 +418,8 @@ namespace etk {
} }
}; };
static std::u32string transform_to_u32string(const char* _input) { #if __cplusplus >= 201103L
static std::u32string transform_to_u32string(const char* _input) {
if (_input == NULL) { if (_input == NULL) {
return U""; return U"";
} }
@ -465,9 +469,10 @@ static std::u32string transform_to_u32string(const char* _input) {
out += utf8::convertChar32(tmpData); out += utf8::convertChar32(tmpData);
} }
return out; return out;
} }
#endif
namespace etk { #if __cplusplus >= 201103L
namespace etk {
template<> std::u32string to_u32string<char*>(char* const & _input) { template<> std::u32string to_u32string<char*>(char* const & _input) {
return transform_to_u32string(_input); return transform_to_u32string(_input);
} }
@ -513,9 +518,9 @@ namespace etk {
} }
return U"false"; 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")
@ -523,53 +528,59 @@ bool etk::string_to_bool(const std::u32string& _str) {
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; return false;
} }
@ -579,7 +590,8 @@ bool etk::compare_no_case(const std::u32string& _obj, const std::u32string& _val
} }
} }
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
std::u32string etk::tolower(std::u32string _obj) {
for(size_t iii=0 ; iii<_obj.size() ; iii++) { for(size_t iii=0 ; iii<_obj.size() ; iii++) {
_obj[iii] = localToLower(_obj[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,8 +716,8 @@ 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;
} }
@ -725,7 +742,8 @@ bool etk::end_with(const std::u32string& _obj, const std::u32string& _val, bool
} }
} }
return true; return true;
} }
#endif
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,8 +771,8 @@ 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;
} }
@ -779,9 +797,9 @@ bool etk::start_with(const std::u32string& _obj, const std::u32string& _val, boo
} }
} }
return true; 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();
@ -791,7 +809,8 @@ std::u32string etk::replace(const std::u32string& _obj, char32_t _val, char32_t
} }
} }
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,8 +852,8 @@ 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) {
@ -861,7 +880,8 @@ std::u32string etk::extract_line(const std::u32string& _obj, int32_t _pos) {
stopPos = _obj.size(); stopPos = _obj.size();
} }
return std::u32string(_obj, startPos, stopPos - startPos); return std::u32string(_obj, startPos, stopPos - startPos);
} }
#endif
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,7 +898,8 @@ 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> etk::split(const std::u32string& _input, char32_t _val) {
std::vector<std::u32string> list; std::vector<std::u32string> list;
size_t lastStartPos = 0; size_t lastStartPos = 0;
for(size_t iii=0; iii<_input.size(); iii++) { for(size_t iii=0; iii<_input.size(); iii++) {
@ -891,7 +912,8 @@ std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _v
list.push_back(std::u32string(_input, lastStartPos)); list.push_back(std::u32string(_input, lastStartPos));
} }
return list; return list;
} }
#endif
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,8 +1003,8 @@ 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++) {
@ -996,12 +1018,16 @@ void etk::sort(std::vector<std::u32string *> &_list) {
//EWOL_DEBUG("position="<<findPos); //EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]); _list.insert(_list.begin()+findPos, tmpList[iii]);
} }
} }
#endif
namespace etk { namespace etk {
#if __cplusplus >= 201103L
template<> bool from_string<std::u32string>(std::u32string& _variableRet, const std::string& _value) { template<> bool from_string<std::u32string>(std::u32string& _variableRet, const std::string& _value) {
_variableRet = etk::to_u32string(_value); _variableRet = etk::to_u32string(_value);
return true; 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,7 +1080,7 @@ 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;
@ -1103,6 +1129,7 @@ namespace etk {
_variableRet = string_to_bool(_value); _variableRet = string_to_bool(_value);
return true; return true;
} }
#endif
}; };
@ -1122,13 +1149,13 @@ 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) { std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
_os << "{"; _os << "{";
for (size_t iii=0; iii< _obj.size(); iii++) { for (size_t iii=0; iii< _obj.size(); iii++) {
if (iii>0) { if (iii>0) {
@ -1138,7 +1165,8 @@ std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32stri
} }
_os << "}"; _os << "}";
return _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 << "{";

View File

@ -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]);
#if __cplusplus >= 201103L
std::string convertToUtf8(const std::u32string& _input); 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);
#if __cplusplus >= 201103L
std::u32string convertUnicode(const std::string& _input); 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);
#if __cplusplus >= 201103L
template <class TYPE> std::u32string to_u32string(const TYPE& _variable); 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);
#if __cplusplus >= 201103L
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value); 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);
#if __cplusplus >= 201103L
long double string_to_long_double(const std::u32string& _str); 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);
#if __cplusplus >= 201103L
double string_to_double(const std::u32string& _str); 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);
#if __cplusplus >= 201103L
float string_to_float(const std::u32string& _str); 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);
#if __cplusplus >= 201103L
int8_t string_to_int8_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
int16_t string_to_int16_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
int32_t string_to_int32_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
int64_t string_to_int64_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10); 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);
#if __cplusplus >= 201103L
bool string_to_bool(const std::u32string& _str); bool string_to_bool(const std::u32string& _str);
#endif
std::string tolower(std::string _obj); std::string tolower(std::string _obj);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string tolower(std::u32string _obj); std::u32string tolower(std::u32string _obj);
#endif
std::string toupper(std::string _obj); std::string toupper(std::string _obj);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string toupper(std::u32string _obj); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::u32string extract_line(const std::u32string& _obj, int32_t _pos); 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);
#if __cplusplus >= 201103L
//! @previous //! @previous
std::vector<std::u32string> split(const std::u32string& _input, char32_t _val); 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);
#if __cplusplus >= 201103L
std::ostream& operator <<(std::ostream& _os, const 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); 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);

View File

@ -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

View File

@ -31,6 +31,13 @@ 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')
# force old version of C++
target.xx_version = 4005000
if target.config["compilator"] == "gcc" \
and target.xx_version < 4007000:
pass
else:
# name of the dependency # name of the dependency
myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True) myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True)
myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP") myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP")
@ -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