diff --git a/etk-core/Buffer.hpp b/etk/Buffer.hpp similarity index 96% rename from etk-core/Buffer.hpp rename to etk/Buffer.hpp index a2fa16e..53777d1 100644 --- a/etk-core/Buffer.hpp +++ b/etk/Buffer.hpp @@ -7,7 +7,8 @@ */ #pragma once -#include +#include +#include #include // minimum gapSize when allocated @@ -93,17 +94,15 @@ namespace etk { * @return true if the data correctly stored * @return false if an error occurred */ - bool dumpIn(const etk::String& _file) { - etk::FSNode file(_file); - if (false == file.fileOpenWrite()) { + bool dumpIn(const etk::Path& _file) { + etk::io::File fileIO(_file); + if (fileIO.open(etk::io::OpenMode::Write) == false) { 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; + fileIO.write(m_data, sizeof(int8_t), m_gapStart); + fileIO.write(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd); + fileIO.close(); + return true; } /** * @brief Load data from a selected file name. @@ -111,13 +110,12 @@ namespace etk { * @return true if the data correctly stored * @return false if an error occurred */ - bool dumpFrom(const etk::String& _file) { - etk::FSNode file(_file); - if (false == file.fileOpenRead()) { + bool dumpFrom(const etk::Path& _file) { + etk::io::File fileIO(_file); + if (fileIO.open(etk::io::OpenMode::Read) == false) { return false; } - bool ret = true; - int64_t length = file.fileSize(); + int64_t length = fileIO.size(); // error case ... if (length > 2000000000) { return false; @@ -125,9 +123,10 @@ namespace etk { // 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); + int32_t nbReadData = fileIO.read(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length); TK_INFO("load data : fileSize=" << length << ", readData=" << nbReadData); // check ERROR + bool ret = true; if (nbReadData != length) { TK_ERROR("load data error: fileSize=" << length << ", readData=" << nbReadData); ret = false; @@ -135,7 +134,7 @@ namespace etk { // set the gap size at the buffer ... m_gapStart = 0; m_gapEnd = GAP_SIZE_MIN; - file.fileClose(); + fileIO.close(); return ret; } diff --git a/etk/path/Path.cpp b/etk/path/Path.cpp index f07ca46..d355ad6 100644 --- a/etk/path/Path.cpp +++ b/etk/path/Path.cpp @@ -463,3 +463,24 @@ bool etk::operator<= (const Path& _left, const Path& _right) { return _left.getString() <= _right.getString(); } +#include +namespace etk { + template<> etk::String toString(const etk::Path& _val) { + return _val.getString(); + } + #if __cplusplus >= 201103L + template<> etk::UString toUString(const etk::Path& _val) { + return toUString(_val.getString()); + } + + template<> bool from_string(etk::Path& _variableRet, const etk::UString& _value) { + _variableRet = etk::Path(toString(_value)); + return true; + } + #endif + template<> bool from_string(etk::Path& _variableRet, const etk::String& _value) { + _variableRet = etk::Path(_value); + return true; + } +} + diff --git a/etk/uri/Query.cpp b/etk/uri/Query.cpp index 7065345..ff7d2a6 100644 --- a/etk/uri/Query.cpp +++ b/etk/uri/Query.cpp @@ -5,6 +5,8 @@ */ #include #include +#include +ETK_DECLARE_TYPE(etk::uri::Query); static const etk::String hexData = "0123456789ABCDEF"; diff --git a/etk/uri/Uri.cpp b/etk/uri/Uri.cpp index 2577e14..d6e0fa1 100644 --- a/etk/uri/Uri.cpp +++ b/etk/uri/Uri.cpp @@ -6,6 +6,8 @@ #include #include +#include +ETK_DECLARE_TYPE(etk::Uri); etk::Uri::Uri() { @@ -302,3 +304,25 @@ void etk::Uri::display() const { TK_PRINT(" m_fragment = '" << m_fragment << "'"); } + +#include +namespace etk { + template<> etk::String toString(const etk::Uri& _val) { + return _val.get(); + } + #if __cplusplus >= 201103L + template<> etk::UString toUString(const etk::Uri& _val) { + return toUString(_val.get()); + } + + template<> bool from_string(etk::Uri& _variableRet, const etk::UString& _value) { + _variableRet = etk::Uri(toString(_value)); + return true; + } + #endif + template<> bool from_string(etk::Uri& _variableRet, const etk::String& _value) { + _variableRet = etk::Uri(_value); + return true; + } +} + diff --git a/lutin_etk-core.py b/lutin_etk-core.py index a08278e..4e5452e 100644 --- a/lutin_etk-core.py +++ b/lutin_etk-core.py @@ -44,7 +44,6 @@ def configure(target, my_module): 'etk-core/Allocator.hpp', 'etk-core/types.hpp', 'etk-core/stdTools.hpp', - 'etk-core/Buffer.hpp', 'etk-core/String.hpp', 'etk-core/UString.hpp', 'etk-core/utf8.hpp', diff --git a/lutin_etk.py b/lutin_etk.py index c194db5..5b6f9d8 100644 --- a/lutin_etk.py +++ b/lutin_etk.py @@ -65,6 +65,7 @@ def configure(target, my_module): my_module.add_header_file([ 'etk/etk.hpp', 'etk/debug.hpp', + 'etk/Buffer.hpp', 'etk/tool.hpp', 'etk/Noise.hpp', 'etk/Color.hpp',