[DEV] continue removing STL

This commit is contained in:
Edouard DUPIN 2017-08-29 01:22:26 +02:00
parent 45fbda3786
commit 3cd626eb9d
18 changed files with 120 additions and 735 deletions

View File

@ -1,278 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#pragma once
#include <etk/String.hpp>
namespace etk {
/**
* @brief Internal data of the [class[etk::hash]] class, it contain
* the name and the value of the hash vector.
* @internal
*/
template<class MY_TYPE> class HashData {
public:
etk::String m_key; //!< name of the current hash
MY_TYPE m_value; //!< data of the current Hash
/**
* @brief Constructor of the data for hash table.
* @param[in] _key name of the hash table.
* @param[in] _val Value of the hash element.
*/
HashData(const etk::String& _key, const MY_TYPE& _val) :
m_key(_key),
m_value(_val) {
// nothing to do ...
}
};
/**
* @brief Hash table template is a simple classical hash interface.
* A hash table is a equivalent of the dictionary in python, this is a
* simple interface between a name and a value:
* - "name" : 19
* - "name 2" : 99
*
* @note The name is unique and the value is what you want
*
* @todo check if something else exist in the generic library. (not the etk::Map and the std::unordered_map
*
* @note The index are all time available since they are created. The order is the the one created
*
* A simple example of use:
* @code{.cpp}
* // Create a integer hash table
* Hash<int> myValue;
* // add some element (note add and set is the same function)
* myValue.add("example", 98837);
* myValue.add("plop", 88);
* // Display an element:
* printf("my value is : %d", myValue["example"]);
* // Change value of an element:
* myValue.set("example", 99);
* // Remove an element:
* myValue.remove("plop");
* //Clean all the table:
* myValue.clear();
* @endcode
*/
template<class MY_TYPE> class Hash {
private:
etk::Vector<HashData<MY_TYPE>* > m_data; //!< Data of the hash ==> the Hash table is composed of pointer, this permit to have high speed when resize the vector ...
public:
/**
* @brief Constructor of the Hash table.
* @param[in] _count Number of basic element in the table.
*/
Hash(int32_t _count = 0) :
m_data(_count) {
// nothing to do
}
/**
* @brief Destructor of the Hash table (clear all element in the table)
*/
~Hash() {
clear();
}
/**
* @brief Remove all entry in the Hash table.
* @note It does not delete pointer if your value is a pointer type...
*/
void clear() {
for (auto &it : m_data) {
if (it != nullptr) {
delete(it);
it=nullptr;
}
}
m_data.clear();
}
/**
* @brief Get a current element ID in the Hash table
* @param[in] _key Name of the hash requested
* @return Id of the element in the table or -1 of it does not existed
*/
int64_t getId(const etk::String& _key) const {
for (size_t iii=0; iii<m_data.size(); iii++) {
if (m_data[iii] != nullptr) {
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
if (m_data[iii]->m_key == _key) {
return iii;
}
}
}
//TK_ERROR(" ==> not fund key '" << _key << "'" );
return -1;
}
/**
* @brief Check if an element exist or not
* @param[in] _name Name of the hash requested
* @return true if the element exist
*/
bool exist(const etk::String& _name) const {
int64_t elementId = getId(_name);
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
if (elementId<0) {
//TK_INFO(" ==> return false" );
return false;
}
//TK_INFO(" ==> return true" );
return true;
}
/**
* @brief Get a current element in the hash table, with his name.
* @param[in] _key Name of the hash requested
* @return Reference on the Element
*/
MY_TYPE& get(const etk::String& _key) const {
static MY_TYPE g_error;
int64_t elementId = getId(_key);
if (elementId<0) {
//TK_ERROR("try to access at an inexistent hash element : " << _key);
return g_error;
}
return m_data[elementId]->m_value;
}
/**
* @brief Get an copy Element an a special position
* @param[in] _key Name of the hash requested
* @return An reference on the copy of selected element
*/
MY_TYPE& operator[] (const etk::String& _key) {
return get(_key);
}
/**
* @brief Get an copy Element an a special position
* @param[in] _key Name of the hash requested
* @return An reference on the copy of selected element
*/
const MY_TYPE& operator[] (const etk::String& _key) const {
return get(_key);
}
/**
* @brief Add an element OR set an element value
* @note add and set is the same function.
* @param[in] _key Name of the value to set in the hash table.
* @param[in] _value Value to set in the hash table.
*/
void add(const etk::String& _key, const MY_TYPE& _value) {
int64_t elementId = getId(_key);
if (elementId <0) {
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
if (tmp == nullptr) {
//TK_ERROR("allocation error in Hash table : '" << _key << "'");
return;
}
m_data.pushBack(tmp);
return;
}
m_data[elementId]->m_value = _value;
}
/**
* @brief Set an element value
* @note add and set is the same function.
* @param[in] _key Name of the value to set in the hash table.
* @param[in] _value Value to set in the hash table.
*/
void set(const etk::String& _key, const MY_TYPE& _value) {
add(_key, _value);
}
/**
* @brief Remove an element in the hash table.
* @param[in] _key Name of the element to remove.
*/
void remove(const etk::String& _key) {
int64_t elementId = getId(_key);
if (elementId <0) {
//nothing to do ==> not existed
return;
}
delete(m_data[elementId]);
m_data[elementId] = nullptr;
m_data.erase(m_data.begin()+elementId);
}
/**
* @brief Get the number of element in the hash table
* @return number of elements
*/
size_t size() const {
return m_data.size();
}
/**
* @brief get an element with his id.
* @param[in] _pos Position on the element in the hash table.
* @return requested element at this position.
* @note this is a dangerous use of the hash table. Maybe you will use a simple vector.
*/
MY_TYPE& operator[] (size_t _pos) {
return getValue(_pos);
}
/**
* @brief get an element with his id.
* @param[in] _pos Position on the element in the hash table.
* @return requested element at this position.
* @note this is a dangerous use of the hash table. Maybe you will use a simple vector.
*/
const MY_TYPE& operator[] (size_t _pos) const {
return getValue(_pos);
}
/**
* @brief Get the name of the element at a specific position.
* @param[in] _pos Position of the element in the hash table.
* @return name of the element (key).
*/
const etk::String& getKey(size_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
//TK_CRITICAL("Access to an inexistent data in hash : " << _pos << "/ " << m_data.size());
}
#endif
return m_data[_pos]->m_key;
}
/**
* @brief Get all the element name (keys).
* @return a vector of all name (key).
*/
etk::Vector<etk::String> getKeys() const {
etk::Vector<etk::String> keys;
for (auto &it : m_data) {
if (it != nullptr) {
keys.pushBack(it->m_key);
}
}
return keys;
}
/**
* @brief Get a value of the hash table at a specific position.
* @param[in] _pos of the element in the hash table.
* @return Value available at this position.
*/
const MY_TYPE& getValue(size_t _pos) const {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
//TK_CRITICAL("Access to an inexistent data in hash : " << _pos << "/ " << m_data.size());
}
#endif
return m_data[_pos]->m_value;
}
/**
* @copydoc getValue (size_t)
*/
MY_TYPE& getValue(size_t _pos) {
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if(_pos>m_data.size()){
//TK_CRITICAL("Access to an inexistent data in hash : " << _pos << "/ " << m_data.size());
}
#endif
return m_data[_pos]->m_value;
}
};
}

View File

@ -187,16 +187,16 @@ namespace etk {
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
ETK_MAP_TYPE_DATA& operator-> () const {
etk::Pair<ETK_MAP_TYPE_KEY, ETK_MAP_TYPE_DATA>* operator-> () const {
//TK_CHECK_INOUT(m_current < m_map->size());
return &m_map->getValue(m_current);
return &m_map->getContent(m_current);
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
ETK_MAP_TYPE_DATA& operator* () const {
return m_map->getValue(m_current);
etk::Pair<ETK_MAP_TYPE_KEY, ETK_MAP_TYPE_DATA>& operator* () const {
return m_map->getContent(m_current);
}
/**
* @brief Get Key on the current Element
@ -219,7 +219,14 @@ namespace etk {
ETK_MAP_TYPE_DATA& getValue () {
return m_map->getValue(m_current);
}
bool operator== (const Iterator& _obj) const{
return m_map == _obj.m_map
&& m_current == _obj.m_current;
}
bool operator!= (const Iterator& _obj) const {
return m_map != _obj.m_map
|| m_current != _obj.m_current;
}
private:
Iterator(const etk::Map<ETK_MAP_TYPE_KEY, ETK_MAP_TYPE_DATA> * _obj, int32_t _pos):
m_current(_pos),
@ -312,7 +319,7 @@ namespace etk {
//TK_ERROR("try to access at an inexistent Map element : " << _key);
return g_error;
}
return m_data[elementId]->m_value;
return m_data[elementId]->second;
}
/**
* @brief Get an copy Element an a special position
@ -393,13 +400,19 @@ namespace etk {
size_t size() const {
return m_data.size();
}
const etk::Pair<ETK_MAP_TYPE_KEY, ETK_MAP_TYPE_DATA>& getContent(size_t _pos) const {
return *m_data[_pos];
}
etk::Pair<ETK_MAP_TYPE_KEY, ETK_MAP_TYPE_DATA>& getContent(size_t _pos) {
return *m_data[_pos];
}
/**
* @brief Get the name of the element at a specific position.
* @param[in] _pos Position of the element in the Map table.
* @return name of the element (key).
*/
const ETK_MAP_TYPE_KEY& getKey(size_t _pos) const {
return m_data[_pos]->m_key;
return m_data[_pos]->first;
}
/**
* @brief Get all the element name (keys).
@ -409,7 +422,7 @@ namespace etk {
etk::Vector<ETK_MAP_TYPE_KEY> keys;
for (auto &it : m_data) {
if (it != nullptr) {
keys.pushBack(it->m_key);
keys.pushBack(it->first);
}
}
return etk::move(keys);
@ -455,10 +468,10 @@ namespace etk {
* @return The Iterator
*/
Iterator end() {
return position(size()-1);
return position(size());
}
const Iterator end() const {
return position(size()-1);
return position(size());
}
Iterator find(const ETK_MAP_TYPE_KEY& _key) {

View File

@ -12,6 +12,7 @@ namespace etk {
template<class ETK_PAIR_TYPE_1, class ETK_PAIR_TYPE_2>
class Pair {
public:
// this is bad for coding rules, but an idiom of c++ pair imposed by the STL
ETK_PAIR_TYPE_1 first;
ETK_PAIR_TYPE_2 second;
Pair():
@ -30,6 +31,14 @@ namespace etk {
second(_pair.second) {
}
bool operator== (const Pair<ETK_PAIR_TYPE_1, ETK_PAIR_TYPE_2>& _obj) const{
return first == _obj.first
&& second == _obj.second;
}
bool operator!= (const Pair<ETK_PAIR_TYPE_1, ETK_PAIR_TYPE_2>& _obj) const{
return first != _obj.first
|| second != _obj.second;
}
};
template<class ETK_PAIR_TYPE_1, class ETK_PAIR_TYPE_2>
Pair<ETK_PAIR_TYPE_1, ETK_PAIR_TYPE_2> makePair(ETK_PAIR_TYPE_1 _obj1, ETK_PAIR_TYPE_2 _obj2) {

View File

@ -12,7 +12,7 @@
#include <etk/stdTools.hpp>
#include <etk/String.hpp>
#include <etk/UString.hpp>
#include <etk/pair.hpp>
#include <etk/Pair.hpp>
#include <memory>
#define TK_REG_DEBUG TK_HIDDEN

View File

@ -933,6 +933,13 @@ etk::Vector<etk::String> etk::String::split(etk::String _val) const {
return list;
}
void etk::String::append(Iterator _start, Iterator _stop) {
while (_stop != _start) {
pushBack(*_start);
++_start;
}
}
namespace etk {
long double string_to_long_double(const etk::String& _obj) {
return _obj.to<long double>();

View File

@ -420,6 +420,7 @@ namespace etk {
* @param[in] _value Value to set at the new element
*/
void resize(size_t _newSize, char _value = '\0');
void append(Iterator _start, Iterator _stop);
/*****************************************************
* == operator
*****************************************************/

View File

@ -189,7 +189,7 @@ namespace etk {
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
ETK_VECTOR_TYPE & operator-> () const {
ETK_VECTOR_TYPE* operator-> () const {
//TK_CHECK_INOUT(m_current < m_vector->size());
return &m_vector->get(m_current);
}
@ -626,10 +626,10 @@ namespace etk {
* @return The Iterator
*/
Iterator end() {
return position( size()-1 );
return position(size());
}
const Iterator end() const {
return position( size()-1 );
return position(size());
}
/**

View File

@ -17,7 +17,7 @@ const etk::String& etk::Archive::getName(size_t _id) const {
size_t id = 0;
for (auto &it : m_content) {
if (id == _id) {
return it.getKey();
return it.first;
}
++id;
}
@ -30,7 +30,7 @@ const etk::ArchiveContent& etk::Archive::getContent(size_t _id) const {
size_t id = 0;
for (auto &it : m_content) {
if (id == _id) {
return it.getValue();
return it.second;
}
++id;
}
@ -43,7 +43,7 @@ const etk::ArchiveContent& etk::Archive::getContent(const etk::String& _key) con
if (it == m_content.end()) {
return g_error;
}
return it->getValue();
return it->second;
}
@ -55,9 +55,9 @@ bool etk::Archive::exist(const etk::String& _key) const {
void etk::Archive::display() {
std::unique_lock<std::mutex> lock(m_mutex);
for (auto &it : m_content) {
int32_t size = it.getValue().getTheoricSize();
int32_t sizeR = it.getValue().size();
TK_INFO(" element : " << it.getKey() << " size=" << size << " allocated=" << sizeR);
int32_t size = it.second.getTheoricSize();
int32_t sizeR = it.second.size();
TK_INFO(" element : " << it.first << " size=" << size << " allocated=" << sizeR);
}
}
@ -118,11 +118,11 @@ void etk::Archive::open(const etk::String& _key) {
TK_ERROR("Try open an unexistant file : '" << _key << "'");
return;
}
if (it->getValue().getNumberOfRef()==-1) {
if (it->second.getNumberOfRef()==-1) {
loadFile(it);
it->getValue().increaseRef();
it->second.increaseRef();
}
it->getValue().increaseRef();
it->second.increaseRef();
}
void etk::Archive::close(const etk::String& _key) {
@ -132,10 +132,10 @@ void etk::Archive::close(const etk::String& _key) {
TK_ERROR("Try close an unexistant file : '" << _key << "'");
return;
}
if (it->getValue().getNumberOfRef()==0){
if (it->second.getNumberOfRef()==0){
TK_ERROR("Try close one more time the file : '" << _key << "'");
} else {
it->getValue().decreaseRef();
it->second.decreaseRef();
}
}

View File

@ -38,7 +38,7 @@ etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) :
// find directory ...
} else {
TK_INFO("find file : " << tmpFileName);
m_content.insert(etk::Pair<etk::String, etk::ArchiveContent>(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size)));
m_content.set(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size));
}
/* Go the the next entry listed in the zip file. */
if((iii+1) < m_info.number_entry) {

View File

@ -1 +1,32 @@
https://stackoverflow.com/questions/7510182/how-does-stdmove-transfer-values-into-rvalues
/**
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL-2 (see license file)
*/
#pragma once
namespace etk {
template<class ETK_MOVE_TYPE>
struct _Remove_reference {
// remove reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE>
struct _Remove_reference<ETK_MOVE_TYPE&> {
// remove reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE>
struct _Remove_reference<ETK_MOVE_TYPE&&> {
// remove rvalue reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE> inline
typename etk::_Remove_reference<ETK_MOVE_TYPE>::m_type&& move(ETK_MOVE_TYPE&& _obj) {
// forward _Arg as movable
return ((typename etk::_Remove_reference<ETK_MOVE_TYPE>::m_type&&)_obj);
}
}

View File

@ -489,11 +489,6 @@ etk::String getApplicationPath() {
TK_INFO("Binary name : " << binaryName);
return binaryName;
}
#if __CPP_VERSION__ >= 2011
etk::UString getUApplicationPath() {
return etk::toUString(getApplicationPath());
}
#endif
void etk::initDefaultFolder(const char* _applName) {
baseApplName = _applName;
@ -652,20 +647,10 @@ void etk::initDefaultFolder(const char* _applName) {
etk::String etk::getUserHomeFolder() {
return baseFolderHome;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::getUUserHomeFolder() {
return etk::toUString(baseFolderHome);
}
#endif
etk::String etk::getUserRunFolder() {
return baseRunPath;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::getUUserRunFolder() {
return etk::toUString(baseRunPath);
}
#endif
#ifdef HAVE_ZIP_DATA
@ -704,23 +689,6 @@ etk::FSNode::FSNode(const etk::String& _nodeName) :
{
privateSetName(_nodeName);
}
#if __CPP_VERSION__ >= 2011
etk::FSNode::FSNode(const etk::UString& _nodeName) :
m_userFileName(""),
m_type(etk::FSNType_unknow),
m_typeNode(etk::typeNode_unknow),
m_PointerFile(nullptr),
m_timeCreate(0),
m_timeModify(0),
m_timeAccess(0)
#ifdef HAVE_ZIP_DATA
, m_zipContent(nullptr),
m_zipReadingOffset(-1)
#endif
{
privateSetName(_nodeName);
}
#endif
etk::FSNode::~FSNode() {
@ -939,11 +907,6 @@ void etk::FSNode::privateSetName(etk::String _newName) {
updateFileSystemProperty();
TK_DBG_MODE("6 : type : [" << m_typeNode << "] right :" << m_rights);
}
#if __CPP_VERSION__ >= 2011
void etk::FSNode::privateSetName(const etk::UString& _newName) {
privateSetName(etk::toString(_newName));
}
#endif
bool directCheckFile(etk::String _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
#ifdef HAVE_ZIP_DATA
@ -962,11 +925,6 @@ bool directCheckFile(etk::String _tmpFileNameDirect, bool _checkInAPKIfNeeded =
}
return true;
}
#if __CPP_VERSION__ >= 2011
bool directCheckFile(etk::UString _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
return directCheckFile(etk::toString(_tmpFileNameDirect));
}
#endif
// Now we generate the real FS path:
void etk::FSNode::generateFileSystemPath() {
bool forceLibFolder(false);
@ -1026,7 +984,6 @@ void etk::FSNode::generateFileSystemPath() {
case etk::FSNType_theme:
case etk::FSNType_themeData:
{
//etk::UString myCompleateName=baseFolderData + "/theme/";
etk::String themeName("");
etk::String basicName(m_userFileName);
size_t firstPos = m_userFileName.find(':');
@ -1230,11 +1187,6 @@ bool etk::FSNode::setRight(etk::FSNodeRight _newRight) {
void etk::FSNode::setName(const etk::String& _newName) {
privateSetName(_newName);
}
#if __CPP_VERSION__ >= 2011
void etk::FSNode::setName(const etk::UString& _newName) {
privateSetName(_newName);
}
#endif
etk::String etk::FSNode::getNameFolder() const {
size_t lastPos = m_systemFileName.rfind('/');
@ -1243,20 +1195,10 @@ etk::String etk::FSNode::getNameFolder() const {
}
return "";
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::getUNameFolder() const {
return etk::toUString(getNameFolder());
}
#endif
etk::String etk::FSNode::getFileSystemName() const {
return m_systemFileName;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::getUFileSystemName() const {
return etk::toUString(getFileSystemName());
}
#endif
etk::String etk::FSNode::getName() const {
etk::String output("");
@ -1296,11 +1238,6 @@ etk::String etk::FSNode::getName() const {
output += m_userFileName;
return output;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::getUName() const {
return etk::toUString(getName());
}
#endif
etk::String etk::FSNode::getNameFile() const {
size_t lastPos = m_systemFileName.rfind('/');
@ -1309,11 +1246,6 @@ etk::String etk::FSNode::getNameFile() const {
}
return "";
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::getUNameFile() const {
return etk::toUString(getNameFile());
}
#endif
etk::String etk::FSNode::getRelativeFolder() const {
etk::String tmppp = getName();
@ -1353,11 +1285,6 @@ etk::String etk::FSNode::getRelativeFolder() const {
TK_DBG_MODE(" ==> : ''" );
return "";
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::getURelativeFolder() const {
return etk::toUString(getRelativeFolder());
}
#endif
bool etk::FSNode::touch() {
@ -1389,11 +1316,6 @@ bool etk::FSNode::move(const etk::String& _path) {
return true;
}
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNode::move(const etk::UString& _path) {
return move(etk::toString(_path));
}
#endif
bool etk::FSNode::remove() {
if (getNodeType()==etk::typeNode_folder) {
@ -1426,11 +1348,6 @@ etk::String etk::FSNode::timeCreatedString() const {
}
return tmpTime;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::timeUCreatedString() const {
return etk::toUString(timeCreatedString());
}
#endif
uint64_t etk::FSNode::timeModified() const {
return m_timeModify;
@ -1444,11 +1361,6 @@ etk::String etk::FSNode::timeModifiedString() const {
}
return tmpTime;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::timeUModifiedString() const {
return etk::toUString(timeModifiedString());
}
#endif
uint64_t etk::FSNode::timeAccessed() const {
return m_timeAccess;
@ -1462,11 +1374,6 @@ etk::String etk::FSNode::timeAccessedString() const {
}
return tmpTime;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::timeUAccessedString() const {
return etk::toUString(timeAccessedString());
}
#endif
/*
Operator :
*/
@ -1903,16 +1810,6 @@ void etk::FSNode::folderGetRecursiveFiles(etk::Vector<etk::String>& _output, boo
}
return;
}
#if __CPP_VERSION__ >= 2011
void etk::FSNode::folderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable) {
_output.clear();
etk::Vector<etk::String> tmpVal;
folderGetRecursiveFiles(tmpVal, _recursiveEnable);
for (size_t iii=0; iii<tmpVal.size(); ++iii) {
_output.pushBack(toUString(tmpVal[iii]));
}
}
#endif
/*
File Specific :
@ -1936,11 +1833,6 @@ etk::String etk::FSNode::fileGetExtention() {
}
return "";
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNode::fileUGetExtention() {
return etk::toUString(fileGetExtention());
}
#endif
uint64_t etk::FSNode::fileSize() {
if (m_typeNode != etk::typeNode_file) {
@ -2317,99 +2209,43 @@ static etk::Map<etk::String, etk::String> g_listTheme;
void etk::theme::setName(const etk::String& _refName, const etk::String& _folderName) {
TK_WARNING("Change theme : '" << _refName << "' : '" << _folderName << "'");
#if __CPP_VERSION__ >= 2011
auto it = g_listTheme.find(_refName);
#else
etk::Map<etk::String, etk::String>::iterator it = g_listTheme.find(_refName);
#endif
if (it != g_listTheme.end()) {
it->second = _folderName;
return;
g_listTheme.set(_refName, _folderName);
}
g_listTheme.insert(etk::Pair<etk::String,etk::String>(_refName, _folderName));
}
#if __CPP_VERSION__ >= 2011
void etk::theme::setName(const etk::UString& _refName, const etk::UString& _folderName) {
setName(etk::toString(_refName), etk::toString(_folderName));
}
#endif
etk::String etk::theme::getName(const etk::String& _refName) {
#if __CPP_VERSION__ >= 2011
auto it = g_listTheme.find(_refName);
#else
etk::Map<etk::String, etk::String>::iterator it = g_listTheme.find(_refName);
#endif
if (it != g_listTheme.end()) {
return it->second;
}
return _refName;
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::theme::getName(const etk::UString& _refName) {
return etk::toUString(getName(etk::toString(_refName)));
}
#endif
// get the list of all the theme folder availlable in the user Home/appl
etk::Vector<etk::String> etk::theme::list() {
etk::Vector<etk::String> keys;
#if __CPP_VERSION__ >= 2011
for (auto &it : g_listTheme) {
keys.pushBack(it.first);
}
#else
for (etk::Map<etk::String, etk::String>::iterator it(g_listTheme.begin()); it != g_listTheme.end(); ++it) {
keys.pushBack(it->first);
}
#endif
return keys;
}
#if __CPP_VERSION__ >= 2011
etk::Vector<etk::UString> etk::theme::listU() {
etk::Vector<etk::UString> keys;
for (auto &it : g_listTheme) {
keys.pushBack(etk::toUString(it.first));
}
return keys;
}
#endif
static etk::Map<etk::String, etk::String> g_listThemeDefault;
void etk::theme::setNameDefault(const etk::String& _refName, const etk::String& _folderName) {
#if __CPP_VERSION__ >= 2011
auto it = g_listThemeDefault.find(_refName);
#else
etk::Map<etk::String, etk::String>::iterator it = g_listThemeDefault.find(_refName);
#endif
if (it != g_listThemeDefault.end()) {
it->second = _folderName;
return;
}
g_listThemeDefault.insert(etk::Pair<etk::String,etk::String>(_refName, _folderName));
g_listThemeDefault.set(_refName, _folderName);
}
#if __CPP_VERSION__ >= 2011
void etk::theme::setNameDefault(const etk::UString& _refName, const etk::UString& _folderName) {
setNameDefault(etk::toString(_refName), etk::toString(_folderName));
}
#endif
etk::String etk::theme::getNameDefault(const etk::String& _refName) {
#if __CPP_VERSION__ >= 2011
auto it = g_listThemeDefault.find(_refName);
#else
etk::Map<etk::String, etk::String>::iterator it = g_listThemeDefault.find(_refName);
#endif
if (it != g_listThemeDefault.end()) {
return it->second;
}
return "default";
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::theme::getNameDefault(const etk::UString& _refName) {
return etk::toUString(getNameDefault(etk::toString(_refName)));
}
#endif
@ -2420,16 +2256,11 @@ etk::String etk::theme::getNameDefault(const etk::String& _refName) {
* -------------------------------------------------------------------------- */
uint64_t etk::FSNodeGetSize(const etk::String& _path) {
etk::FSNode tmpNode(_path);
if (false==tmpNode.exist()) {
if (tmpNode.exist() == false) {
return 0;
}
return tmpNode.fileSize();
}
#if __CPP_VERSION__ >= 2011
uint64_t etk::FSNodeGetSize(const etk::UString& _path) {
return FSNodeGetSize(etk::toString(_path));
}
#endif
bool etk::FSNodeRemove(const etk::String& _path) {
etk::FSNode tmpNode(_path);
@ -2438,11 +2269,6 @@ bool etk::FSNodeRemove(const etk::String& _path) {
}
return tmpNode.remove();
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeRemove(const etk::UString& _path) {
return FSNodeRemove(etk::toString(_path));
}
#endif
int64_t etk::FSNodeGetCount(const etk::String& _path) {
etk::FSNode tmpNode(_path);
@ -2451,31 +2277,16 @@ int64_t etk::FSNodeGetCount(const etk::String& _path) {
}
return tmpNode.folderCount();
}
#if __CPP_VERSION__ >= 2011
int64_t etk::FSNodeGetCount(const etk::UString& _path) {
return FSNodeGetCount(etk::toString(_path));
}
#endif
bool etk::FSNodeCreate(const etk::String& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
// TODO :
return false;
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
return FSNodeCreate(etk::toString(_path), _right, _type);
}
#endif
bool etk::FSNodeExist(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.exist();
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeExist(const etk::UString& _path) {
return FSNodeExist(etk::toString(_path));
}
#endif
bool etk::FSNodeMove(const etk::String& _path1, const etk::String& _path2) {
etk::FSNode tmpNode(_path1);
@ -2488,71 +2299,36 @@ bool etk::FSNodeMove(const etk::String& _path1, const etk::String& _path2) {
//move the node
return tmpNode.move(_path2);
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeMove(const etk::UString& _path1, const etk::UString& _path2) {
return FSNodeMove(etk::toString(_path1), etk::toString(_path2));
}
#endif
etk::FSNodeRight etk::FSNodeGetRight(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.getRight();
}
#if __CPP_VERSION__ >= 2011
etk::FSNodeRight etk::FSNodeGetRight(const etk::UString& _path) {
return FSNodeGetRight(etk::toString(_path));
}
#endif
enum etk::typeNode etk::FSNodeGetType(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.getNodeType();
}
#if __CPP_VERSION__ >= 2011
enum etk::typeNode etk::FSNodeGetType(const etk::UString& _path) {
return FSNodeGetType(etk::toString(_path));
}
#endif
uint64_t etk::FSNodeGetTimeCreated(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.timeCreated();
}
#if __CPP_VERSION__ >= 2011
uint64_t etk::FSNodeGetTimeCreated(const etk::UString& _path) {
return FSNodeGetTimeCreated(etk::toString(_path));
}
#endif
uint64_t etk::FSNodeGetTimeModified(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.timeModified();
}
#if __CPP_VERSION__ >= 2011
uint64_t etk::FSNodeGetTimeModified(const etk::UString& _path) {
return FSNodeGetTimeModified(etk::toString(_path));
}
#endif
uint64_t etk::FSNodeGetTimeAccessed(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.timeAccessed();
}
#if __CPP_VERSION__ >= 2011
uint64_t etk::FSNodeGetTimeAccessed(const etk::UString& _path) {
return FSNodeGetTimeAccessed(etk::toString(_path));
}
#endif
bool etk::FSNodeTouch(const etk::String& _path) {
etk::FSNode tmpNode(_path);
return tmpNode.touch();
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeTouch(const etk::UString& _path) {
return FSNodeTouch(etk::toString(_path));
}
#endif
bool etk::FSNodeEcho(const etk::String& _path, const etk::String& _dataTowrite) {
etk::FSNode tmpNode(_path);
@ -2572,11 +2348,6 @@ bool etk::FSNodeEcho(const etk::String& _path, const etk::String& _dataTowrite)
}
return tmpNode.fileClose();
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeEcho(const etk::UString& _path, const etk::UString& _dataTowrite) {
return FSNodeEcho(etk::toString(_path), etk::toString(_dataTowrite));
}
#endif
bool etk::FSNodeEchoAdd(const etk::String& _path, const etk::String& _dataTowrite) {
etk::FSNode tmpNode(_path);
@ -2596,11 +2367,6 @@ bool etk::FSNodeEchoAdd(const etk::String& _path, const etk::String& _dataTowrit
}
return tmpNode.fileClose();
}
#if __CPP_VERSION__ >= 2011
bool etk::FSNodeEchoAdd(const etk::UString& _path, const etk::UString& _dataTowrite) {
return FSNodeEchoAdd(etk::toString(_path), etk::toString(_dataTowrite));
}
#endif
void etk::FSNodeHistory(const etk::String& _path, int32_t _historyCount) {
// step 1 : Move the file to prevent writing error
@ -2614,11 +2380,6 @@ void etk::FSNodeHistory(const etk::String& _path, int32_t _historyCount) {
etk::FSNodeMove(_path, _path + "-1");
}
}
#if __CPP_VERSION__ >= 2011
void etk::FSNodeHistory(const etk::UString& _path, int32_t _historyCount) {
return FSNodeHistory(etk::toString(_path), _historyCount);
}
#endif
etk::String etk::FSNodeReadAllData(const etk::String& _path) {
etk::String output;

View File

@ -196,9 +196,6 @@ namespace etk {
* @param[in] _path Path of the curent file /folder ...
*/
FSNode(const etk::String& _path = "~");
#if __CPP_VERSION__ >= 2011
FSNode(const etk::UString& _path);
#endif
/**
* @brief Destructor
* @note you will have some warning if you did not close your files
@ -218,9 +215,6 @@ namespace etk {
* @param[in] _newName Name of the Node
*/
void privateSetName(etk::String _newName);
#if __CPP_VERSION__ >= 2011
void privateSetName(const etk::UString& _newName);
#endif
private:
#ifdef HAVE_ZIP_DATA
/**
@ -269,52 +263,34 @@ namespace etk {
* @return false action not done
*/
void setName(const etk::String& _newName);
#if __CPP_VERSION__ >= 2011
void setName(const etk::UString& _newName);
#endif
/**
* @brief Get the Generate FileSystem name
* @return the requested filename
*/
etk::String getFileSystemName() const;
#if __CPP_VERSION__ >= 2011
etk::UString getUFileSystemName() const;
#endif
/**
* @brief Get the current folder of the Node. (file system name)
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
* @note Auto remove of ../../../ and //
*/
etk::String getNameFolder() const;
#if __CPP_VERSION__ >= 2011
etk::UString getUNameFolder() const;
#endif
/**
* @brief Get the current compleate node name (file system name)
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
* @note Auto remove of ../../../ and //
*/
etk::String getName() const;
#if __CPP_VERSION__ >= 2011
etk::UString getUName() const;
#endif
/**
* @brief Get the file or current file name (if it was a file)
* @return the name of the node (like myFile.kkk)
*/
etk::String getNameFile() const;
#if __CPP_VERSION__ >= 2011
etk::UString getUNameFile() const;
#endif
/**
* @brief Get the current folder of the Node.
* @return the common name define (like DATA:xxxxx/xxxxx/)
* @note Auto remove of ../../../ and //
*/
etk::String getRelativeFolder() const;
#if __CPP_VERSION__ >= 2011
etk::UString getURelativeFolder() const;
#endif
/**
* @brief update the Time of the file with the current time
* @return true : action done
@ -328,9 +304,6 @@ namespace etk {
* @return false : action not done
*/
bool move(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool move(const etk::UString& _path);
#endif
/**
* @brief Get the node type (DATA/DIRECT...)
* @return the requested type
@ -354,9 +327,6 @@ namespace etk {
* @return The time requested (in string)
*/
etk::String timeCreatedString() const;
#if __CPP_VERSION__ >= 2011
etk::UString timeUCreatedString() const;
#endif
/**
* @brief Get the modifying time of the File
* @return The time requested
@ -367,9 +337,6 @@ namespace etk {
* @return The time requested (in string)
*/
etk::String timeModifiedString() const;
#if __CPP_VERSION__ >= 2011
etk::UString timeUModifiedString() const;
#endif
/**
* @brief Get the Accessed time of the File
* @return The time requested
@ -380,9 +347,6 @@ namespace etk {
* @return The time requested (in string)
*/
etk::String timeAccessedString() const;
#if __CPP_VERSION__ >= 2011
etk::UString timeUAccessedString() const;
#endif
/**
* @brief copy the other FSnode ==> for vector
* @param[in] _obj input node
@ -458,9 +422,6 @@ namespace etk {
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
*/
void folderGetRecursiveFiles(etk::Vector<etk::String>& _output, bool _recursiveEnable=true);
#if __CPP_VERSION__ >= 2011
void folderGetRecursiveFiles(etk::Vector<etk::UString>& _output, bool _recursiveEnable=true);
#endif
/**
* @brief Check if the file have an extention ( ***.ccc)
* @return true The file have an extention.
@ -472,9 +433,6 @@ namespace etk {
* @return the requested extention
*/
etk::String fileGetExtention();
#if __CPP_VERSION__ >= 2011
etk::UString fileUGetExtention();
#endif
/**
* @brief Get the File size
* @return the requested size
@ -616,11 +574,6 @@ namespace etk {
fileRead(&value[0], sizeof(char), fileSize()/sizeof(char));
return value;
}
#if __CPP_VERSION__ >= 2011
etk::UString fileReadAllU32String() {
return utf8::convertUnicode(fileReadAllString());
}
#endif
/**
* @brief Write all the vector in a file
* @param[in] _value Data to write in the File
@ -636,11 +589,6 @@ namespace etk {
void fileWriteAll(const etk::String& _value) {
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char));
}
#if __CPP_VERSION__ >= 2011
void fileWriteAll(const etk::UString& _value) {
fileWriteAll(u32char::convertToUtf8(_value));
}
#endif
private:
/**
* @brief Order the list of subnode the folder first and the alphabetical order
@ -677,17 +625,11 @@ namespace etk {
* @return the home folder : like : "/home/machin/"
*/
etk::String getUserHomeFolder();
#if __CPP_VERSION__ >= 2011
etk::UString getUUserHomeFolder();
#endif
/**
* @brief Get the folder of the Program is running
* @return the basic folder name (ex : run ./appl in the pwd=/home/machin/sousFolder ==> this return the pwd folder)
*/
etk::String getUserRunFolder();
#if __CPP_VERSION__ >= 2011
etk::UString getUUserRunFolder();
#endif
namespace theme {
// TODO : Add an INIT ...
@ -697,49 +639,29 @@ namespace etk {
* @param[in] _folderName The associated folder of the Theme (like "myTheme/folder/folder2/")
*/
void setName(const etk::String& _refName, const etk::String& _folderName);
#if __CPP_VERSION__ >= 2011
//! @previous
void setName(const etk::UString& _refName, const etk::UString& _folderName);
#endif
/**
* @brief get the folder from a Reference theme
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme
*/
etk::String getName(const etk::String& _refName);
#if __CPP_VERSION__ >= 2011
//! @previous
etk::UString getName(const etk::UString& _refName);
#endif
/**
* @brief Set the default folder of a subset of a theme ...
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @param[in] _folderName The associated default folder of the Theme (like "myTheme/color/default/")
*/
void setNameDefault(const etk::String& _refName, const etk::String& _folderName);
#if __CPP_VERSION__ >= 2011
//! @previous
void setNameDefault(const etk::UString& _refName, const etk::UString& _folderName);
#endif
/**
* @brief get the default folder from a Reference theme
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme
*/
etk::String getNameDefault(const etk::String& _refName);
#if __CPP_VERSION__ >= 2011
//! @previous
etk::UString getNameDefault(const etk::UString& _refName);
#endif
/**
* @brief Get the list of all the theme folder availlable in the user Home/appl
* @return The list of elements
*/
etk::Vector<etk::String> list();
#if __CPP_VERSION__ >= 2011
//! @previous
etk::Vector<etk::UString> listU();
#endif
};
/**
* @brief Get the size of a specific file
@ -747,9 +669,6 @@ namespace etk {
* @return size of the file
*/
uint64_t FSNodeGetSize(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetSize(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Remove folder and subFolder, files pipes ...
@ -758,9 +677,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeRemove(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeRemove(const etk::UString& _path);
#endif
/**
* @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
@ -768,9 +684,6 @@ namespace etk {
* @return -1 : An error occured
*/
int64_t FSNodeGetCount(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
int64_t FSNodeGetCount(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Create a file or a folder depending of the request
* @param[in] _path Folder/File/Pipe path of the node
@ -780,9 +693,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeCreate(const etk::String& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#if __CPP_VERSION__ >= 2011
bool FSNodeCreate(const etk::UString& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#endif
/**
* @brief Simple access for : chexk the exestance of an element
* @param[in] _path Folder/File/Pipe path of the node
@ -790,9 +700,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeExist(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeExist(const etk::UString& _path);
#endif
/**
* @brief Simple access for : chexk the exestance of an element
* @param[in] _path1 Folder/File/Pipe path of the node sources
@ -801,9 +708,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeMove(const etk::String& _path1, const etk::String& _path2);
#if __CPP_VERSION__ >= 2011
bool FSNodeMove(const etk::UString& _path1, const etk::UString& _path2);
#endif
/**
* @brief Simple access for : Get right of the current Node
* @param[in] _path Folder/File/Pipe path of the node
@ -811,9 +715,6 @@ namespace etk {
* @return false : An error occured
*/
etk::FSNodeRight FSNodeGetRight(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
etk::FSNodeRight FSNodeGetRight(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Get type of the current node
* @param[in] _path Folder/File/Pipe path of the node
@ -821,9 +722,6 @@ namespace etk {
* @return false : An error occured
*/
enum etk::typeNode FSNodeGetType(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
enum etk::typeNode FSNodeGetType(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Getting creation time of the current node
* @param[in] _path Folder/File/Pipe path of the node
@ -831,9 +729,6 @@ namespace etk {
* @return false : An error occured
*/
uint64_t FSNodeGetTimeCreated(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeCreated(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Getting Modification time of the current node
* @param[in] _path Folder/File/Pipe path of the node
@ -841,9 +736,6 @@ namespace etk {
* @return false : An error occured
*/
uint64_t FSNodeGetTimeModified(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeModified(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Getting Accessing time of the current node
* @param[in] _path Folder/File/Pipe path of the node
@ -851,9 +743,6 @@ namespace etk {
* @return false : An error occured
*/
uint64_t FSNodeGetTimeAccessed(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeAccessed(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Update Modification time with the current time of the node (>)
* @param[in] _path Folder/File/Pipe path of the node
@ -861,9 +750,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeTouch(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeTouch(const etk::UString& _path);
#endif
/**
* @brief Simple access for : Basic write on the node (like console echo)
* @param[in] _path Folder/File/Pipe path of the node
@ -872,9 +758,6 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeEcho(const etk::String& _path, const etk::String& _dataTowrite);
#if __CPP_VERSION__ >= 2011
bool FSNodeEcho(const etk::UString& _path, const etk::UString& _dataTowrite);
#endif
/**
* @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
@ -883,18 +766,12 @@ namespace etk {
* @return false : An error occured
*/
bool FSNodeEchoAdd(const etk::String& _path, const etk::String& _dataTowrite);
#if __CPP_VERSION__ >= 2011
bool FSNodeEchoAdd(const etk::UString& _path, const etk::UString& _dataTowrite);
#endif
/**
* @brief move file to generate an history of the current file
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _historyCount number of saved file in the history (-xxx)
*/
void FSNodeHistory(const etk::String& _path, int32_t _historyCount);
#if __CPP_VERSION__ >= 2011
void FSNodeHistory(const etk::UString& _path, int32_t _historyCount);
#endif
/**
* @brief Read all the data from a file
* @param[in] _path Folder/File/Pipe path of the node

View File

@ -147,11 +147,6 @@ void etk::FSNodeRight::setOtherRunable(bool _newStatus) {
m_rights |= right_other_execute;
}
}
#if __CPP_VERSION__ >= 2011
etk::UString etk::FSNodeRight::getURight() const {
return etk::toUString(getRight());
}
#endif
etk::String etk::FSNodeRight::getRight() const {
etk::String tmp;

View File

@ -9,7 +9,6 @@
#pragma once
#include <etk/String.hpp>
#include <etk/UString.hpp>
namespace etk {
/**
@ -139,13 +138,6 @@ namespace etk {
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setOtherRunable(bool _newStatus);
#if __CPP_VERSION__ >= 2011
/**
* @brief Get the write written in a string mode (like in linux rw-r-----)
* @return String with the right in string
*/
etk::UString getURight() const;
#endif
/**
* @brief Get the write written in a string mode (like in linux rw-r-----)
* @return String with the right in string

View File

@ -97,30 +97,7 @@ namespace etk {
}
return out;
}
template<class ETK_MOVE_TYPE>
struct _Remove_reference {
// remove reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE>
struct _Remove_reference<ETK_MOVE_TYPE&> {
// remove reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE>
struct _Remove_reference<ETK_MOVE_TYPE&&> {
// remove rvalue reference
typedef ETK_MOVE_TYPE m_type;
};
template<class ETK_MOVE_TYPE> inline
typename etk::_Remove_reference<ETK_MOVE_TYPE>::m_type&& move(ETK_MOVE_TYPE&& _obj) {
// forward _Arg as movable
return ((typename etk::_Remove_reference<ETK_MOVE_TYPE>::m_type&&)_obj);
}
}
#include <etk/move.hpp>
#include <etk/Stream.hpp>

View File

@ -136,7 +136,7 @@ etk::String u32char::convertToUtf8(const etk::UString& _input) {
size_t u32char::strlen(const char32_t* _input) {
uint32_t out = 0;
while (_input != 0) {
while (*_input != 0) {
out++;
_input++;
}

View File

@ -39,7 +39,6 @@ def configure(target, my_module):
'etk/types.hpp',
'etk/stdTools.hpp',
'etk/Buffer.hpp',
'etk/Hash.hpp',
'etk/String.hpp',
'etk/UString.hpp',
'etk/utf8.hpp',
@ -47,6 +46,7 @@ def configure(target, my_module):
'etk/Stream.hpp',
'etk/Pair.hpp',
'etk/Map.hpp',
'etk/move.hpp',
])
# build in C++ mode

View File

@ -8,17 +8,17 @@
#include <gtest/gtest.h>
#include <etk/Hash.hpp>
#include <etk/Map.hpp>
#include <test-debug/debug.hpp>
#define NAME "Hash"
#define NAME "MAP_unorderer"
TEST(TestEtkHash, Creation) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, Creation) {
etk::Map<etk::String, etk::String> testData(0,false);
EXPECT_EQ(testData.size(), 0);
}
TEST(TestEtkHash, AddElement) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, AddElement) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "testData");
testData.add("TEST2", "22222222222222222");
testData.add("TEST4", "4444444444444444444");
@ -30,8 +30,8 @@ TEST(TestEtkHash, AddElement) {
EXPECT_EQ(testData["TEST3"], "3333333333");
}
TEST(TestEtkHash, OverWriteElement) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, OverWriteElement) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "testData");
testData.add("TEST2", "22222222222222222");
testData.add("TEST4", "4444444444444444444");
@ -44,8 +44,8 @@ TEST(TestEtkHash, OverWriteElement) {
EXPECT_EQ(testData["TEST"], "testData22");
}
TEST(TestEtkHash, RemoveElement) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, RemoveElement) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "testData");
testData.add("TEST2", "22222222222222222");
testData.add("TEST4", "4444444444444444444");
@ -53,20 +53,20 @@ TEST(TestEtkHash, RemoveElement) {
testData.add("TEST1", "11111111111");
testData.add("TEST55", "555555555555555((((5555");
EXPECT_EQ(testData.size(), 6);
testData.remove("TEST1");
testData.erase("TEST1");
EXPECT_EQ(testData.size(), 5);
}
TEST(TestEtkHash, ExistElement) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, ExistElement) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "testData");
testData.add("TEST2", "22222222222222222");
EXPECT_EQ(testData.exist("TEST"), true);
EXPECT_EQ(testData.exist("Tlskdfjgmsqlkdfjgmlqskdfg"), false);
}
TEST(TestEtkHash, clear) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, clear) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "1");
testData.add("TEST2", "2");
EXPECT_EQ(testData.size(), 2);
@ -74,16 +74,16 @@ TEST(TestEtkHash, clear) {
EXPECT_EQ(testData.size(), 0);
}
TEST(TestEtkHash, getKey) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, getKey) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "1");
testData.add("TEST2", "2");
testData.add("TEST3", "3");
EXPECT_EQ(testData.getKey(1), "TEST2");
}
TEST(TestEtkHash, getKeys) {
etk::Hash<etk::String> testData;
TEST(TestEtkMap_unordered, getKeys) {
etk::Map<etk::String, etk::String> testData(0,false);
testData.add("TEST", "1");
testData.add("TEST2", "2");
testData.add("TEST3", "3");