[DEV] Continue integration of etk::String

This commit is contained in:
Edouard DUPIN 2017-08-23 22:05:29 +02:00
parent 067bed60a5
commit 9db3d1daa9
29 changed files with 879 additions and 723 deletions

View File

@ -9,13 +9,13 @@
#include <etk/Color.hpp>
#include <etk/debug.hpp>
#include <etk/stdTools.hpp>
#include <string>
#include <etk/String.hpp>
#include <sstream>
#include <stdexcept>
class ColorList {
public:
const char * colorName;
const etk::String colorName;
etk::Color<> color;
};
@ -97,18 +97,18 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithRGBGen(const etk::String& _input
outputValue.setG(std::min(0xFF, green));
outputValue.setB(std::min(0xFF, blue));
} else if (sscanf(_input.c_str(), "%f,%f,%f,%f", &float_red, &float_green, &float_blue, &float_alpha) == 4) {
float_red = std::avg(0.0f, float_red, 1.0f);
float_green = std::avg(0.0f, float_green, 1.0f);
float_blue = std::avg(0.0f, float_blue, 1.0f);
float_alpha = std::avg(0.0f, float_alpha, 1.0f);
float_red = etk::avg(0.0f, float_red, 1.0f);
float_green = etk::avg(0.0f, float_green, 1.0f);
float_blue = etk::avg(0.0f, float_blue, 1.0f);
float_alpha = etk::avg(0.0f, float_alpha, 1.0f);
outputValue.setR((uint8_t)(float_red * 255.f));
outputValue.setG((uint8_t)(float_green * 255.f));
outputValue.setB((uint8_t)(float_blue * 255.f));
outputValue.setR((uint8_t)(float_alpha * 255.f));
} else if (sscanf(_input.c_str(), "%f,%f,%f", &float_red, &float_green, &float_blue) == 3) {
float_red = std::avg(0.0f, float_red, 1.0f);
float_green= std::avg(0.0f, float_green, 1.0f);
float_blue = std::avg(0.0f, float_blue, 1.0f);
float_red = etk::avg(0.0f, float_red, 1.0f);
float_green= etk::avg(0.0f, float_green, 1.0f);
float_blue = etk::avg(0.0f, float_blue, 1.0f);
outputValue.setR((uint8_t)(float_red * 255.f));
outputValue.setG((uint8_t)(float_green * 255.f));
outputValue.setB((uint8_t)(float_blue * 255.f));
@ -269,7 +269,7 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithRGBUnsigned8(const etk::String&
etk::Color<uint8_t, 4> etk::parseStringColorNamed(const etk::String& _input) {
// direct named color ...
for (int32_t iii=0; iii<getColorSize(); iii++) {
if (etk::compare_no_case(getColorList()[iii].colorName, _input) == true) {
if (getColorList()[iii].colorName.compare(_input, false) == true) {
return getColorList()[iii].color;
}
}

View File

@ -8,6 +8,7 @@
#pragma once
#include <etk/String.hpp>
#include <iomanip>
namespace etk {

View File

@ -235,157 +235,157 @@ template<> template<> Color<uint16_t,4>::Color(const Color<uint32_t, 4>& _obj) {
// ===========================================================================================================
template<> template<> Color<uint16_t,1>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,2>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = 0;
}
template<> template<> Color<uint16_t,3>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint16_t,4>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,2>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,3>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = 0;
}
template<> template<> Color<uint16_t,4>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,2>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,3>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(std::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(etk::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,4>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(std::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(etk::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,2>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,3>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(std::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(etk::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
}
template<> template<> Color<uint16_t,4>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(std::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(std::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[3] = (uint16_t)(std::avg(0.0f, _obj.a(), 1.0f)*65535.0f);
m_element[0] = (uint16_t)(etk::avg(0.0f, _obj.r(), 1.0f)*65535.0f);
m_element[1] = (uint16_t)(etk::avg(0.0f, _obj.g(), 1.0f)*65535.0f);
m_element[2] = (uint16_t)(etk::avg(0.0f, _obj.b(), 1.0f)*65535.0f);
m_element[3] = (uint16_t)(etk::avg(0.0f, _obj.a(), 1.0f)*65535.0f);
}
// ===========================================================================================================
template<> template<> Color<uint16_t,1>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,2>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = 0;
}
template<> template<> Color<uint16_t,3>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint16_t,4>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,2>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,3>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = 0;
}
template<> template<> Color<uint16_t,4>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,2>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,3>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(std::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(etk::avg(0.0, _obj.b(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,4>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(std::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(etk::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint16_t,1>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,2>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,3>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(std::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(etk::avg(0.0, _obj.b(), 1.0)*65535.0);
}
template<> template<> Color<uint16_t,4>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint16_t)(std::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(std::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(std::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[3] = (uint16_t)(std::avg(0.0, _obj.a(), 1.0)*65535.0);
m_element[0] = (uint16_t)(etk::avg(0.0, _obj.r(), 1.0)*65535.0);
m_element[1] = (uint16_t)(etk::avg(0.0, _obj.g(), 1.0)*65535.0);
m_element[2] = (uint16_t)(etk::avg(0.0, _obj.b(), 1.0)*65535.0);
m_element[3] = (uint16_t)(etk::avg(0.0, _obj.a(), 1.0)*65535.0);
}
// ===========================================================================================================
template<> etk::String to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>& _val) {
template<> etk::String toString<Color<uint16_t, 1> >(const Color<uint16_t, 1>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -394,7 +394,7 @@ template<> etk::String to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>&
}
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>(toString(_value));
return true;
}
#endif
@ -405,7 +405,7 @@ template<> bool from_string<Color<uint16_t, 1> >(Color<uint16_t, 1>& _variableRe
template<> etk::String to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>& _val) {
template<> etk::String toString<Color<uint16_t, 2> >(const Color<uint16_t, 2>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -414,7 +414,7 @@ template<> etk::String to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>&
}
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>(toString(_value));
return true;
}
#endif
@ -425,7 +425,7 @@ template<> bool from_string<Color<uint16_t, 2> >(Color<uint16_t, 2>& _variableRe
template<> etk::String to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>& _val) {
template<> etk::String toString<Color<uint16_t, 3> >(const Color<uint16_t, 3>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -434,7 +434,7 @@ template<> etk::String to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>&
}
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>(toString(_value));
return true;
}
#endif
@ -445,7 +445,7 @@ template<> bool from_string<Color<uint16_t, 3> >(Color<uint16_t, 3>& _variableRe
template<> etk::String to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>& _val) {
template<> etk::String toString<Color<uint16_t, 4> >(const Color<uint16_t, 4>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -454,7 +454,7 @@ template<> etk::String to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>&
}
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>(toString(_value));
return true;
}
#endif

View File

@ -235,157 +235,157 @@ template<> template<> Color<uint32_t,4>::Color(const Color<uint32_t, 4>& _obj) {
// ===========================================================================================================
template<> template<> Color<uint32_t,1>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,2>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = 0;
}
template<> template<> Color<uint32_t,3>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint32_t,4>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint32_t,1>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,2>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,3>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = 0;
}
template<> template<> Color<uint32_t,4>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint32_t,1>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,2>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,3>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(std::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(etk::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,4>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(std::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(etk::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint32_t,1>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,2>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,3>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(std::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(etk::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
}
template<> template<> Color<uint32_t,4>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(std::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(std::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[3] = (uint32_t)(std::avg(0.0f, _obj.a(), 1.0f)*4294967295.0f);
m_element[0] = (uint32_t)(etk::avg(0.0f, _obj.r(), 1.0f)*4294967295.0f);
m_element[1] = (uint32_t)(etk::avg(0.0f, _obj.g(), 1.0f)*4294967295.0f);
m_element[2] = (uint32_t)(etk::avg(0.0f, _obj.b(), 1.0f)*4294967295.0f);
m_element[3] = (uint32_t)(etk::avg(0.0f, _obj.a(), 1.0f)*4294967295.0f);
}
// ===========================================================================================================
template<> template<> Color<uint32_t,1>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,2>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = 0;
}
template<> template<> Color<uint32_t,3>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint32_t,4>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = 0xFFFFFF;
}
template<> template<> Color<uint32_t,1>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,2>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,3>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = 0;
}
template<> template<> Color<uint32_t,4>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = 0;
m_element[3] = 0xFFFFFF;
}
template<> template<> Color<uint32_t,1>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,2>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,3>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(std::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(etk::avg(0.0, _obj.b(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,4>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(std::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(etk::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[3] = 0xFFFFFF;
}
template<> template<> Color<uint32_t,1>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,2>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,3>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(std::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(etk::avg(0.0, _obj.b(), 1.0)*4294967295.0);
}
template<> template<> Color<uint32_t,4>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint32_t)(std::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(std::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(std::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[3] = (uint32_t)(std::avg(0.0, _obj.a(), 1.0)*4294967295.0);
m_element[0] = (uint32_t)(etk::avg(0.0, _obj.r(), 1.0)*4294967295.0);
m_element[1] = (uint32_t)(etk::avg(0.0, _obj.g(), 1.0)*4294967295.0);
m_element[2] = (uint32_t)(etk::avg(0.0, _obj.b(), 1.0)*4294967295.0);
m_element[3] = (uint32_t)(etk::avg(0.0, _obj.a(), 1.0)*4294967295.0);
}
// ===========================================================================================================
template<> etk::String to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>& _val) {
template<> etk::String toString<Color<uint32_t, 1> >(const Color<uint32_t, 1>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -393,7 +393,7 @@ template<> etk::String to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>&
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -402,7 +402,7 @@ template<> bool from_string<Color<uint32_t, 1> >(Color<uint32_t, 1>& _variableRe
return true;
}
template<> etk::String to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>& _val) {
template<> etk::String toString<Color<uint32_t, 2> >(const Color<uint32_t, 2>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -410,7 +410,7 @@ template<> etk::String to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>&
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -421,7 +421,7 @@ template<> bool from_string<Color<uint32_t, 2> >(Color<uint32_t, 2>& _variableRe
template<> etk::String to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>& _val) {
template<> etk::String toString<Color<uint32_t, 3> >(const Color<uint32_t, 3>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -429,7 +429,7 @@ template<> etk::String to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>&
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -440,7 +440,7 @@ template<> bool from_string<Color<uint32_t, 3> >(Color<uint32_t, 3>& _variableRe
template<> etk::String to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>& _val) {
template<> etk::String toString<Color<uint32_t, 4> >(const Color<uint32_t, 4>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -448,7 +448,7 @@ template<> etk::String to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>&
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif

View File

@ -235,156 +235,156 @@ template<> template<> Color<uint8_t,4>::Color(const Color<uint32_t, 4>& _obj) {
// ===========================================================================================================
template<> template<> Color<uint8_t,1>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,2>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = 0;
}
template<> template<> Color<uint8_t,3>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint8_t,4>::Color(const Color<float, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,2>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,3>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = 0;
}
template<> template<> Color<uint8_t,4>::Color(const Color<float, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,2>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,3>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(std::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(etk::avg(0.0f, _obj.b(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,4>::Color(const Color<float, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(std::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(etk::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,2>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,3>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(std::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(etk::avg(0.0f, _obj.b(), 1.0f)*255.0f);
}
template<> template<> Color<uint8_t,4>::Color(const Color<float, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(std::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(std::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[3] = (uint8_t)(std::avg(0.0f, _obj.a(), 1.0f)*255.0f);
m_element[0] = (uint8_t)(etk::avg(0.0f, _obj.r(), 1.0f)*255.0f);
m_element[1] = (uint8_t)(etk::avg(0.0f, _obj.g(), 1.0f)*255.0f);
m_element[2] = (uint8_t)(etk::avg(0.0f, _obj.b(), 1.0f)*255.0f);
m_element[3] = (uint8_t)(etk::avg(0.0f, _obj.a(), 1.0f)*255.0f);
}
// ===========================================================================================================
template<> template<> Color<uint8_t,1>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,2>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = 0;
}
template<> template<> Color<uint8_t,3>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = 0;
m_element[2] = 0;
}
template<> template<> Color<uint8_t,4>::Color(const Color<double, 1>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = 0;
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,2>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,3>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = 0;
}
template<> template<> Color<uint8_t,4>::Color(const Color<double, 2>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = 0;
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,2>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,3>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(std::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(etk::avg(0.0, _obj.b(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,4>::Color(const Color<double, 3>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(std::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(etk::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[3] = defaultAlpha;
}
template<> template<> Color<uint8_t,1>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,2>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,3>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(std::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(etk::avg(0.0, _obj.b(), 1.0)*255.0);
}
template<> template<> Color<uint8_t,4>::Color(const Color<double, 4>& _obj) {
m_element[0] = (uint8_t)(std::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(std::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(std::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[3] = (uint8_t)(std::avg(0.0, _obj.a(), 1.0)*255.0);
m_element[0] = (uint8_t)(etk::avg(0.0, _obj.r(), 1.0)*255.0);
m_element[1] = (uint8_t)(etk::avg(0.0, _obj.g(), 1.0)*255.0);
m_element[2] = (uint8_t)(etk::avg(0.0, _obj.b(), 1.0)*255.0);
m_element[3] = (uint8_t)(etk::avg(0.0, _obj.a(), 1.0)*255.0);
}
// ===========================================================================================================
template<> etk::String to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _val) {
template<> etk::String toString<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -392,7 +392,7 @@ template<> etk::String to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _v
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -404,7 +404,7 @@ template<> bool from_string<Color<uint8_t, 1> >(Color<uint8_t, 1>& _variableRet,
template<> etk::String to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _val) {
template<> etk::String toString<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -412,7 +412,7 @@ template<> etk::String to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _v
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -423,7 +423,7 @@ template<> bool from_string<Color<uint8_t, 2> >(Color<uint8_t, 2>& _variableRet,
template<> etk::String to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _val) {
template<> etk::String toString<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -431,7 +431,7 @@ template<> etk::String to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _v
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif
@ -441,7 +441,7 @@ template<> bool from_string<Color<uint8_t, 3> >(Color<uint8_t, 3>& _variableRet,
}
template<> etk::String to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _val) {
template<> etk::String toString<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -449,7 +449,7 @@ template<> etk::String to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _v
return to_u32string(_val.getString());
}
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>(toString(_value));
return true;
}
#endif

View File

@ -385,7 +385,7 @@ template<> template<> Color<double,4>::Color(const Color<double, 4>& _obj) {
// ===========================================================================================================
template<> etk::String to_string<Color<double, 1> >(const Color<double, 1>& _val) {
template<> etk::String toString<Color<double, 1> >(const Color<double, 1>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -393,7 +393,7 @@ template<> etk::String to_string<Color<double, 1> >(const Color<double, 1>& _val
return to_u32string(_val.getString());
}
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::u32string& _value) {
_variableRet = Color<double, 1>(to_string(_value));
_variableRet = Color<double, 1>(toString(_value));
return true;
}
#endif
@ -405,7 +405,7 @@ template<> bool from_string<Color<double, 1> >(Color<double, 1>& _variableRet, c
template<> etk::String to_string<Color<double, 2> >(const Color<double, 2>& _val) {
template<> etk::String toString<Color<double, 2> >(const Color<double, 2>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -413,7 +413,7 @@ template<> etk::String to_string<Color<double, 2> >(const Color<double, 2>& _val
return to_u32string(_val.getString());
}
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::u32string& _value) {
_variableRet = Color<double, 2>(to_string(_value));
_variableRet = Color<double, 2>(toString(_value));
return true;
}
#endif
@ -425,7 +425,7 @@ template<> bool from_string<Color<double, 2> >(Color<double, 2>& _variableRet, c
template<> etk::String to_string<Color<double, 3> >(const Color<double, 3>& _val) {
template<> etk::String toString<Color<double, 3> >(const Color<double, 3>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -433,7 +433,7 @@ template<> etk::String to_string<Color<double, 3> >(const Color<double, 3>& _val
return to_u32string(_val.getString());
}
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::u32string& _value) {
_variableRet = Color<double, 3>(to_string(_value));
_variableRet = Color<double, 3>(toString(_value));
return true;
}
#endif
@ -444,7 +444,7 @@ template<> bool from_string<Color<double, 3> >(Color<double, 3>& _variableRet, c
template<> etk::String to_string<Color<double, 4> >(const Color<double, 4>& _val) {
template<> etk::String toString<Color<double, 4> >(const Color<double, 4>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -452,7 +452,7 @@ template<> etk::String to_string<Color<double, 4> >(const Color<double, 4>& _val
return to_u32string(_val.getString());
}
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::u32string& _value) {
_variableRet = Color<double, 4>(to_string(_value));
_variableRet = Color<double, 4>(toString(_value));
return true;
}
#endif

View File

@ -383,7 +383,7 @@ template<> template<> Color<float,4>::Color(const Color<double, 4>& _obj) {
}
template<> etk::String to_string<Color<float, 1> >(const Color<float, 1>& _val) {
template<> etk::String toString<Color<float, 1> >(const Color<float, 1>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -391,7 +391,7 @@ template<> etk::String to_string<Color<float, 1> >(const Color<float, 1>& _val)
return to_u32string(_val.getString());
}
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::u32string& _value) {
_variableRet = Color<float, 1>(to_string(_value));
_variableRet = Color<float, 1>(toString(_value));
return true;
}
#endif
@ -401,7 +401,7 @@ template<> bool from_string<Color<float, 1> >(Color<float, 1>& _variableRet, con
}
template<> etk::String to_string<Color<float, 2> >(const Color<float, 2>& _val) {
template<> etk::String toString<Color<float, 2> >(const Color<float, 2>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -409,7 +409,7 @@ template<> etk::String to_string<Color<float, 2> >(const Color<float, 2>& _val)
return to_u32string(_val.getString());
}
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::u32string& _value) {
_variableRet = Color<float, 2>(to_string(_value));
_variableRet = Color<float, 2>(toString(_value));
return true;
}
#endif
@ -419,7 +419,7 @@ template<> bool from_string<Color<float, 2> >(Color<float, 2>& _variableRet, con
}
template<> etk::String to_string<Color<float, 3> >(const Color<float, 3>& _val) {
template<> etk::String toString<Color<float, 3> >(const Color<float, 3>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -427,7 +427,7 @@ template<> etk::String to_string<Color<float, 3> >(const Color<float, 3>& _val)
return to_u32string(_val.getString());
}
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::u32string& _value) {
_variableRet = Color<float, 3>(to_string(_value));
_variableRet = Color<float, 3>(toString(_value));
return true;
}
#endif
@ -437,7 +437,7 @@ template<> bool from_string<Color<float, 3> >(Color<float, 3>& _variableRet, con
}
template<> etk::String to_string<Color<float, 4> >(const Color<float, 4>& _val) {
template<> etk::String toString<Color<float, 4> >(const Color<float, 4>& _val) {
return _val.getString();
}
#if __cplusplus >= 201103L
@ -445,7 +445,7 @@ template<> etk::String to_string<Color<float, 4> >(const Color<float, 4>& _val)
return to_u32string(_val.getString());
}
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::u32string& _value) {
_variableRet = Color<float, 4>(to_string(_value));
_variableRet = Color<float, 4>(toString(_value));
return true;
}
#endif

View File

@ -414,7 +414,7 @@ etk::String etk::regex::autoStr(const etk::String& _data) {
} else if (it == ' ') {
out += " ";
} else if (it <= 0x20) {
out += std::to_string((int32_t)it);
out += etk::toString((int32_t)it);
} else {
out += it;
}
@ -436,7 +436,7 @@ etk::String etk::regex::autoStr(char _data) {
} else if (_data == ' ') {
out += " ";
} else if (_data <= 0x20) {
out += std::to_string((int32_t)_data);
out += etk::toString((int32_t)_data);
} else {
out += _data;
}
@ -455,10 +455,10 @@ etk::String etk::regex::strTick(int32_t _pos) {
namespace etk {
template<> etk::String to_string<etk::RegEx<etk::String>>(const etk::RegEx<etk::String>& _val) {
template<> etk::String toString<etk::RegEx<etk::String>>(const etk::RegEx<etk::String>& _val) {
return _val.getRegEx();
}
template<> etk::String to_string<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
template<> etk::String toString<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
return _val.getRegEx();
}
template<> std::u32string to_u32string<etk::RegEx<etk::String>>(const etk::RegEx<etk::String>& _val) {

View File

@ -10,6 +10,7 @@
#include <etk/types.hpp>
#include <etk/debug.hpp>
#include <etk/stdTools.hpp>
#include <etk/String.hpp>
#include <vector>
#include <memory>
@ -1581,7 +1582,7 @@ template<class CLASS_TYPE> class RegEx {
* @return the string representing the RegEx
*/
etk::String getRegEx() const {
return etk::to_string(m_expressionRequested);
return etk::toString(m_expressionRequested);
};
/**
* @previous

View File

@ -4,49 +4,49 @@
template <>
long double etk::String::to<long double>() {
long double etk::String::to<long double>() const {
long double ret = 0;
sscanf(c_str(), "%Lf", &ret);
return ret;
}
template <>
double etk::String::to<double>() {
double etk::String::to<double>() const {
double ret = 0;
sscanf(c_str(), "%lf", &ret);
return ret;
}
template <>
float etk::String::to<float>() {
float etk::String::to<float>() const {
float ret = 0;
sscanf(c_str(), "%f", &ret);
return ret;
}
template <>
int8_t etk::String::to<int8_t>() {
int8_t etk::String::to<int8_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
int16_t etk::String::to<int16_t>() {
int16_t etk::String::to<int16_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
int32_t etk::String::to<int32_t>() {
int32_t etk::String::to<int32_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
int64_t etk::String::to<int64_t>() {
int64_t etk::String::to<int64_t>() const {
int64_t ret = 0;
#if ( defined(__TARGET_OS__Android) \
|| defined(__TARGET_OS__Windows) \
@ -60,28 +60,28 @@ int64_t etk::String::to<int64_t>() {
}
template <>
uint8_t etk::String::to<uint8_t>() {
uint8_t etk::String::to<uint8_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
uint16_t etk::String::to<uint16_t>() {
uint16_t etk::String::to<uint16_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
uint32_t etk::String::to<uint32_t>() {
uint32_t etk::String::to<uint32_t>() const {
int ret = 0;
sscanf(c_str(), "%d", &ret);
return ret;
}
template <>
uint64_t etk::String::to<uint64_t>() {
uint64_t etk::String::to<uint64_t>() const {
uint64_t ret = 0;
#if ( defined(__TARGET_OS__Android) \
|| defined(__TARGET_OS__Windows) \
@ -100,19 +100,6 @@ std::ostream& etk::operator <<(std::ostream& _os, const etk::String& _obj) {
return _os;
}
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector<etk::String>& _obj) {
_os << "{";
for (size_t iii=0; iii< _obj.size(); iii++) {
if (iii>0) {
_os << " ~ ";
}
_os << _obj[iii];
}
_os << "}";
return _os;
}
void etk::sort(etk::Vector<etk::String *> &_list) {
etk::Vector<etk::String *> tmpList(_list);
_list.clear();
@ -137,103 +124,112 @@ namespace etk {
return true;
}
template<> bool from_string<int8_t>(int8_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_int8_t(_value);
_variableRet = _value.to<int8_t>();
return true;
}
template<> bool from_string<int16_t>(int16_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_int16_t(_value);
_variableRet = _value.to<int16_t>();
return true;
}
template<> bool from_string<int32_t>(int32_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_int32_t(_value);
_variableRet = _value.to<int32_t>();
return true;
}
template<> bool from_string<int64_t>(int64_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_int64_t(_value);
_variableRet = _value.to<int64_t>();
return true;
}
template<> bool from_string<uint8_t>(uint8_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_uint8_t(_value);
_variableRet = _value.to<uint8_t>();
return true;
}
template<> bool from_string<uint16_t>(uint16_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_uint16_t(_value);
_variableRet = _value.to<uint16_t>();
return true;
}
template<> bool from_string<uint32_t>(uint32_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_uint32_t(_value);
_variableRet = _value.to<uint32_t>();
return true;
}
template<> bool from_string<uint64_t>(uint64_t& _variableRet, const etk::String& _value) {
_variableRet = string_to_uint64_t(_value);
_variableRet = _value.to<uint64_t>();
return true;
}
template<> bool from_string<float>(float& _variableRet, const etk::String& _value) {
_variableRet = string_to_float(_value);
_variableRet = _value.to<float>();
return true;
}
template<> bool from_string<double>(double& _variableRet, const etk::String& _value) {
_variableRet = string_to_double(_value);
_variableRet = _value.to<double>();
return true;
}
template<> bool from_string<long double>(long double& _variableRet, const etk::String& _value) {
_variableRet = string_to_long_double(_value);
_variableRet = _value.to<long double>();
return true;
}
template<> bool from_string<bool>(bool& _variableRet, const etk::String& _value) {
_variableRet = string_to_bool(_value);
_variableRet = _value.to<bool>();
return true;
}
}
etk::String etk::toString(bool _val) {
template<>
etk::String etk::toString(const bool& _val) {
if (_val == true) {
return "true";
}
return "false";
}
etk::String etk::toString(int _val) {
template<>
etk::String etk::toString(const int& _val) {
char tmpVal[256];
sprintf(tmpVal, "%d", _val);
return tmpVal;
}
etk::String etk::toString(long _val) {
template<>
etk::String etk::toString(const long& _val) {
char tmpVal[256];
sprintf(tmpVal, "%ld", _val);
return tmpVal;
}
etk::String etk::toString(long long _val) {
template<>
etk::String etk::toString(const long long& _val) {
char tmpVal[256];
sprintf(tmpVal, "%lld", _val);
return tmpVal;
}
etk::String etk::toString(unsigned _val) {
template<>
etk::String etk::toString(const unsigned& _val) {
char tmpVal[256];
sprintf(tmpVal, "%u", _val);
return tmpVal;
}
etk::String etk::toString(unsigned long _val) {
template<>
etk::String etk::toString(const unsigned long& _val) {
char tmpVal[256];
sprintf(tmpVal, "%lu", _val);
return tmpVal;
}
etk::String etk::toString(unsigned long long _val) {
template<>
etk::String etk::toString(const unsigned long long& _val) {
char tmpVal[256];
sprintf(tmpVal, "%llu", _val);
return tmpVal;
}
etk::String etk::toString(float _val) {
template<>
etk::String etk::toString(const float& _val) {
char tmpVal[256];
sprintf(tmpVal, "%f", _val);
return tmpVal;
}
etk::String etk::toString(double _val) {
template<>
etk::String etk::toString(const double& _val) {
char tmpVal[256];
sprintf(tmpVal, "%f", _val);
return tmpVal;
}
etk::String etk::toString(long double _val) {
template<>
etk::String etk::toString(const long double& _val) {
char tmpVal[256];
sprintf(tmpVal, "%Lf", _val);
return tmpVal;
@ -302,23 +298,23 @@ size_t etk::String::rfind(const etk::String& _value, size_t _pos) const {
return etk::String::npos;
}
etk::String& etk::replace(size_t _pos, size_t _len, char _replace) {
etk::String& etk::String::replace(size_t _pos, size_t _len, char _replace) {
erase(_pos, _len);
insert(_pos, _replace);
return *this;
}
etk::String& etk::replace(size_t _pos, size_t _len, const etk::String& _replace) {
etk::String& etk::String::replace(size_t _pos, size_t _len, const etk::String& _replace) {
erase(_pos, _len);
insert(_pos, _replace);
return *this;
}
etk::String& etk::replace(char _val, char _replace) {
etk::String& etk::String::replace(char _val, char _replace) {
size_t pos = 0;
while ((pos = find(_val, pos)) != etk::String::npos) {
replace(pos, _val.size(), _replace);
pos += _replace.size();
replace(pos, 1, _replace);
pos += 1;
}
return *this;
}
@ -367,12 +363,12 @@ etk::Vector<etk::String> etk::String::split(char _val) const {
size_t lastStartPos = 0;
for(size_t iii=0; iii<size(); iii++) {
if (m_data[iii] == _val) {
list.push_back(etk::String(*this, lastStartPos, iii - lastStartPos));
list.pushBack(etk::String(*this, lastStartPos, iii - lastStartPos));
lastStartPos = iii+1;
}
}
if (lastStartPos < size()) {
list.push_back(etk::String(*this, lastStartPos));
list.pushBack(etk::String(*this, lastStartPos));
}
return list;
}
@ -382,13 +378,13 @@ etk::Vector<etk::String> etk::String::split(etk::String _val) const {
size_t lastStartPos = 0;
for(size_t iii=0; iii<size()-_val.size(); iii++) {
if (etk::String(begin()+iii, begin()+iii+_val.size()) ==_val) {
list.push_back(etk::String(*this, lastStartPos, iii - lastStartPos));
list.pushBack(etk::String(*this, lastStartPos, iii - lastStartPos));
lastStartPos = iii+_val.size();
iii += _val.size()-1;
}
}
if (lastStartPos < size()) {
list.push_back(etk::String(*this, lastStartPos));
list.pushBack(etk::String(*this, lastStartPos));
}
return list;
}

View File

@ -112,6 +112,43 @@ namespace etk {
--(*this);
return it;
}
Iterator& operator-= (size_t _offset) {
m_current -= _offset;
return *this;
}
Iterator operator- (size_t _offset) const {
Iterator tmp(*this);
tmp -= _offset;
return tmp;
}
Iterator& operator-= (int64_t _offset) {
m_current -= _offset;
return *this;
}
Iterator operator- (int64_t _offset) const {
Iterator tmp(*this);
tmp -= _offset;
return tmp;
}
Iterator& operator+= (size_t _offset) {
m_current += _offset;
return *this;
}
Iterator operator+ (size_t _offset) const {
Iterator tmp(*this);
tmp += _offset;
return tmp;
}
Iterator& operator+= (int64_t _offset) {
m_current += _offset;
return *this;
}
Iterator operator+ (int64_t _offset) const {
Iterator tmp(*this);
tmp += _offset;
return tmp;
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
@ -161,9 +198,9 @@ namespace etk {
return false;
}
private:
Iterator(String* _obj, int32_t _pos):
Iterator(const String* _obj, int32_t _pos):
m_current(_pos),
m_string(_obj) {
m_string(const_cast<String*>(_obj)) {
// nothing to do ...
}
friend class String;
@ -223,6 +260,13 @@ namespace etk {
m_data[iii] = _obj[iii];
}
}
// TODO : remove this when ready
String(const std::string _obj) {
resize(_obj.size());
for (size_t iii=0; iii<_obj.size(); ++iii) {
m_data[iii] = _obj[iii];
}
}
/**
* @brief Partial copy of the null-terminated C string.
* @param[in] _obj String that might be copyC string that might be copy (end by '\0')
@ -409,7 +453,7 @@ namespace etk {
* @param[in] _pos Position in the string that might be get [0..Size()]
* @return An reference on the selected element
*/
const char operator[] (size_t _pos) const {
const char& operator[] (size_t _pos) const {
return m_data[_pos];
}
/**
@ -517,7 +561,7 @@ namespace etk {
* @param[in] _pos Position to add the elements.
* @param[in] _item Element to add.
*/
void insert(size_t _pos, const etk:::String& _value) {
void insert(size_t _pos, const String& _value) {
insert(_pos, &_value[0], _value.size());
}
/**
@ -601,6 +645,9 @@ namespace etk {
Iterator position(size_t _pos) {
return Iterator(this, _pos);
}
const Iterator position(size_t _pos) const {
return Iterator(this, _pos);
}
/**
* @brief Get an Iterator on the start position of the String
* @return The Iterator
@ -608,6 +655,9 @@ namespace etk {
Iterator begin() {
return position(0);
}
const Iterator begin() const {
return position(0);
}
/**
* @brief Get an Iterator on the end position of the String
* @return The Iterator
@ -615,6 +665,9 @@ namespace etk {
Iterator end() {
return position( size()-1 );
}
const Iterator end() const {
return position( size()-1 );
}
/**
* @brief Change the current size of the string
* @param[in] _newSize New requested size of element in the string
@ -688,8 +741,64 @@ namespace etk {
* @param[in] ETK_STRING_TYPE Template type of the convertion output
*/
template <class ETK_STRING_TYPE>
ETK_STRING_TYPE to();
ETK_STRING_TYPE to() const;
};
bool operator> (const String& _left, const String& _right) {
for (size_t iii=0; iii<_left.size() && iii<_right.size(); ++iii) {
if (_left[iii] > _right[iii]) {
return true;
}
if (_left[iii] < _right[iii]) {
return false;
}
}
if (_left.size() > _right.size()) {
return true;
}
return false;
}
bool operator>= (const String& _left, const String& _right) {
for (size_t iii=0; iii<_left.size() && iii<_right.size(); ++iii) {
if (_left[iii] > _right[iii]) {
return true;
}
if (_left[iii] < _right[iii]) {
return false;
}
}
if (_left.size() >= _right.size()) {
return true;
}
return false;
}
bool operator< (const String& _left, const String& _right) {
for (size_t iii=0; iii<_left.size() && iii<_right.size(); ++iii) {
if (_left[iii] < _right[iii]) {
return true;
}
if (_left[iii] > _right[iii]) {
return false;
}
}
if (_left.size() < _right.size()) {
return true;
}
return false;
}
bool operator<= (const String& _left, const String& _right) {
for (size_t iii=0; iii<_left.size() && iii<_right.size(); ++iii) {
if (_left[iii] < _right[iii]) {
return true;
}
if (_left[iii] > _right[iii]) {
return false;
}
}
if (_left.size() <= _right.size()) {
return true;
}
return false;
}
String operator+ (const String& _left, const String& _right) {
String tmp = _left;
tmp += _right;

View File

@ -6,7 +6,6 @@
#pragma once
#include <etk/types.hpp>
#include <etk/stdTools.hpp>
#include <etk/debug.hpp>
namespace etk {
@ -130,6 +129,42 @@ namespace etk {
--(*this);
return it;
}
Iterator& operator-= (size_t _offset) {
m_current -= _offset;
return *this;
}
Iterator operator- (size_t _offset) const {
Iterator tmp(*this);
tmp -= _offset;
return tmp;
}
Iterator& operator-= (int64_t _offset) {
m_current -= _offset;
return *this;
}
Iterator operator- (int64_t _offset) const {
Iterator tmp(*this);
tmp -= _offset;
return tmp;
}
Iterator& operator+= (size_t _offset) {
m_current += _offset;
return *this;
}
Iterator operator+ (size_t _offset) const {
Iterator tmp(*this);
tmp += _offset;
return tmp;
}
Iterator& operator+= (int64_t _offset) {
m_current += _offset;
return *this;
}
Iterator operator+ (int64_t _offset) const {
Iterator tmp(*this);
tmp += _offset;
return tmp;
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
@ -147,9 +182,9 @@ namespace etk {
return m_vector->get(m_current);
}
private:
Iterator(Vector<ETK_VECTOR_TYPE> * _obj, int32_t _pos):
Iterator(const Vector<ETK_VECTOR_TYPE> * _obj, int32_t _pos):
m_current(_pos),
m_vector(_obj) {
m_vector(const_cast<Vector<ETK_VECTOR_TYPE> *>(_obj)) {
// nothing to do ...
}
friend class Vector;
@ -531,7 +566,10 @@ namespace etk {
* @return The Iterator
*/
Iterator position(size_t _pos) {
return iterator(this, _pos);
return Iterator(this, _pos);
}
const Iterator position(size_t _pos) const {
return Iterator(this, _pos);
}
/**
* @brief Get an Iterator on the start position of the Vector
@ -540,6 +578,9 @@ namespace etk {
Iterator begin() {
return position(0);
}
const Iterator begin() const {
return position(0);
}
/**
* @brief Get an Iterator on the end position of the Vector
* @return The Iterator
@ -547,6 +588,9 @@ namespace etk {
Iterator end() {
return position( size()-1 );
}
const Iterator end() const {
return position( size()-1 );
}
private:
/**
* @brief Change the current size of the vector

View File

@ -12,7 +12,7 @@
static const etk::ArchiveContent g_error;
const std::string& etk::Archive::getName(size_t _id) const {
const etk::String& etk::Archive::getName(size_t _id) const {
std::unique_lock<std::mutex> lock(m_mutex);
size_t id = 0;
for (auto &it : m_content) {
@ -21,7 +21,7 @@ const std::string& etk::Archive::getName(size_t _id) const {
}
++id;
}
static const std::string error("");
static const etk::String error("");
return error;
}
@ -37,7 +37,7 @@ const etk::ArchiveContent& etk::Archive::getContent(size_t _id) const {
return g_error;
}
const etk::ArchiveContent& etk::Archive::getContent(const std::string& _key) const {
const etk::ArchiveContent& etk::Archive::getContent(const etk::String& _key) const {
std::unique_lock<std::mutex> lock(m_mutex);
auto it = m_content.find(_key);
if (it == m_content.end()) {
@ -47,7 +47,7 @@ const etk::ArchiveContent& etk::Archive::getContent(const std::string& _key) con
}
bool etk::Archive::exist(const std::string& _key) const {
bool etk::Archive::exist(const etk::String& _key) const {
std::unique_lock<std::mutex> lock(m_mutex);
return m_content.find(_key) != m_content.end();
}
@ -61,12 +61,12 @@ void etk::Archive::display() {
}
}
etk::Archive* etk::Archive::load(const std::string& _fileName) {
etk::Archive* etk::Archive::load(const etk::String& _fileName) {
etk::Archive* output=nullptr;
std::string tmpName = etk::tolower(_fileName);
etk::String tmpName = _fileName.toLower();
// select the corect Loader :
if( end_with(tmpName, ".zip") == true
|| end_with(tmpName, ".apk") == true ) {
if( tmpName.endWith(".zip") == true
|| tmpName.endWith(".apk") == true ) {
output = new etk::archive::Zip(_fileName);
if (output == nullptr) {
TK_ERROR("An error occured when load archive : " << _fileName);
@ -77,7 +77,7 @@ etk::Archive* etk::Archive::load(const std::string& _fileName) {
return output;
}
etk::Archive* etk::Archive::loadPackage(const std::string& _fileName) {
etk::Archive* etk::Archive::loadPackage(const etk::String& _fileName) {
etk::Archive* output=nullptr;
FILE* file = fopen(_fileName.c_str(), "rb");
if (file == nullptr) {
@ -96,7 +96,7 @@ etk::Archive* etk::Archive::loadPackage(const std::string& _fileName) {
fread(plop, 1, 16, file);
plop[16] = '\0';
// check if we have the mark: "***START DATA***" ==> if not ==> error
if (std::string(plop) != "***START DATA***") {
if (etk::String(plop) != "***START DATA***") {
TK_ERROR("Error in the tag file : '" << plop << "'");
fclose(file);
return nullptr;
@ -111,7 +111,7 @@ etk::Archive* etk::Archive::loadPackage(const std::string& _fileName) {
}
void etk::Archive::open(const std::string& _key) {
void etk::Archive::open(const etk::String& _key) {
std::unique_lock<std::mutex> lock(m_mutex);
auto it = m_content.find(_key);
if (it == m_content.end()) {
@ -125,7 +125,7 @@ void etk::Archive::open(const std::string& _key) {
it->second.increaseRef();
}
void etk::Archive::close(const std::string& _key) {
void etk::Archive::close(const etk::String& _key) {
std::unique_lock<std::mutex> lock(m_mutex);
auto it = m_content.find(_key);
if (it == m_content.end()) {

View File

@ -12,6 +12,7 @@
#include <map>
#include <mutex>
#include <ememory/memory.hpp>
#include <etk/String.hpp>
namespace etk {
/**
@ -95,7 +96,7 @@ namespace etk {
* @brief Contructor of the archive element
* @param[in] _fileName Zip file name (or .apk for android)
*/
Archive(const std::string& _fileName) :
Archive(const etk::String& _fileName) :
m_fileName(_fileName) {
};
@ -104,17 +105,17 @@ namespace etk {
*/
virtual ~Archive() = default;
protected:
std::string m_fileName; //!< File name when it came from an file
etk::String m_fileName; //!< File name when it came from an file
public:
/**
* @brief Get the current file name.
* @return the requested file name.
*/
const std::string& getFileName() {
const etk::String& getFileName() {
return m_fileName;
};
protected:
std::map<std::string, ArchiveContent> m_content; //!< list of element of the zip file
std::map<etk::String, ArchiveContent> m_content; //!< list of element of the zip file
public:
/**
* @brief Get the number of elements
@ -128,7 +129,7 @@ namespace etk {
* @param[in] _id id of the element (must be < Size())
* @return FileName of the requested id
*/
const std::string& getName(size_t _id) const;
const etk::String& getName(size_t _id) const;
/**
* @brief Get the File name of the ID
* @param[in] _id id of the element (must be < Size())
@ -140,23 +141,23 @@ namespace etk {
* @param[in] _key name of the file
* @return FileName of the requested id
*/
const ArchiveContent& getContent(const std::string& _key) const;
const ArchiveContent& getContent(const etk::String& _key) const;
/**
* @brief Check if a file exist
* @param[in] _key Name of the file
* @return true if the file is present
*/
bool exist(const std::string& _key) const;
bool exist(const etk::String& _key) const;
/**
* @brief Load the specific file in the memory
* @param[in] _key Name of the file
*/
void open(const std::string& _key);
void open(const etk::String& _key);
/**
* @brief Un-Load the specific file from the memory
* @param[in] _key Name of the file
*/
void close(const std::string& _key);
void close(const etk::String& _key);
/**
* @brief Display all Element in the archive
*/
@ -166,20 +167,20 @@ namespace etk {
* @brief Request the load in memory of the concerned file.
* @param[in] _it Iterator on the element.
*/
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& _it) { };
virtual void loadFile(const std::map<etk::String, ArchiveContent>::iterator& _it) { };
public:
/**
* @brief Load an Achive with a specific name.
* @param[in] _fileName File name of the specific archive.
* @return A pointer an the specified archive, the user might delete it.
*/
static Archive* load(const std::string& _fileName);
static Archive* load(const etk::String& _fileName);
/**
* @brief Load an Achive with a specific name in package mode ==> this mean the data is associated with the basic binary.
* @param[in] _fileName File name of the specific archive.
* @return A pointer an the specified archive, the user might delete it.
*/
static Archive* loadPackage(const std::string& _fileName);
static Archive* loadPackage(const etk::String& _fileName);
};
}
#endif

View File

@ -10,7 +10,7 @@
#include <etk/types.hpp>
#include <etk/debug.hpp>
etk::archive::Zip::Zip(const std::string& _fileName, uint64_t _offset) :
etk::archive::Zip::Zip(const etk::String& _fileName, uint64_t _offset) :
etk::Archive(_fileName),
m_ctx(nullptr) {
/* Open the zip file */
@ -38,7 +38,7 @@ etk::archive::Zip::Zip(const std::string& _fileName, uint64_t _offset) :
// find directory ...
} else {
TK_INFO("find file : " << tmpFileName);
m_content.insert(std::pair<std::string, etk::ArchiveContent>(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size)));
m_content.insert(std::pair<etk::String, etk::ArchiveContent>(tmpFileName, etk::ArchiveContent(tmpFileInfo.uncompressed_size)));
}
/* Go the the next entry listed in the zip file. */
if((iii+1) < m_info.number_entry) {
@ -57,7 +57,7 @@ etk::archive::Zip::~Zip() {
};
}
void etk::archive::Zip::loadFile(const std::map<std::string, ArchiveContent>::iterator& it) {
void etk::archive::Zip::loadFile(const std::map<etk::String, ArchiveContent>::iterator& it) {
TK_VERBOSE("Real load file : '" << it->first << "'");
unzGoToFirstFile(m_ctx);

View File

@ -28,13 +28,13 @@
* @param[in] _fileName File to parse (.zip / .apk)
* @param[in] _offset Offset in the file where to start the parsing of the "zip"
*/
Zip(const std::string& _fileName, uint64_t _offset = 0LL);
Zip(const etk::String& _fileName, uint64_t _offset = 0LL);
/**
* @brief basic destructor
*/
virtual ~Zip();
protected:
void loadFile(const std::map<std::string, ArchiveContent>::iterator& _it) override;
void loadFile(const std::map<etk::String, ArchiveContent>::iterator& _it) override;
};
}
}

View File

@ -63,7 +63,7 @@ void etk::init(int _argc, const char** _argv) {
TK_PRINT(" X Log level to set [0..6]");
*/
TK_PRINT(" -h/--help: this help");
} else if (etk::start_with(data, "--etk")) {
} else if (data.startWith("--etk")) {
TK_ERROR("Can not parse the argument : '" << data << "'");
}
}

View File

@ -5,7 +5,7 @@
*/
#pragma once
#include <string>
#include <etk/String.hpp>
/**
* @brief basic namespace of the etk library. (it might contain all the etk functions/class/structures without macro)
*/

View File

@ -108,12 +108,12 @@ vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) {
}
namespace etk {
template<> Vector2D<bool>::operator std::string() const {
std::string str;
template<> Vector2D<bool>::operator etk::String() const {
etk::String str;
str = "(";
str += etk::to_string(x());
str += etk::toString(x());
str += ",";
str += etk::to_string(y());
str += etk::toString(y());
str += ")";
return str;
}
@ -129,11 +129,11 @@ namespace etk {
}
#endif
template<> Vector2D<bool>::Vector2D(const std::string& _str) {
template<> Vector2D<bool>::Vector2D(const etk::String& _str) {
m_floats[0] = false;
m_floats[1] = false;
// copy to permit to modify it :
std::string tmpStr = _str;
etk::String tmpStr = _str;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -141,13 +141,13 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_bool(tmpStr);
m_floats[1] = m_floats[0];
} else {
m_floats[0] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
m_floats[0] = etk::string_to_bool(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0, posComa+1);
m_floats[1] = etk::string_to_bool(tmpStr);
}
@ -166,7 +166,7 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_bool(tmpStr);
@ -180,12 +180,12 @@ namespace etk {
}
#endif
template<> Vector2D<int32_t>::operator std::string() const {
std::string str;
template<> Vector2D<int32_t>::operator etk::String() const {
etk::String str;
str = "(";
str += etk::to_string(x());
str += etk::toString(x());
str += ",";
str += etk::to_string(y());
str += etk::toString(y());
str += ")";
return str;
}
@ -201,11 +201,11 @@ namespace etk {
}
#endif
template<> Vector2D<int32_t>::Vector2D(const std::string& _str) {
template<> Vector2D<int32_t>::Vector2D(const etk::String& _str) {
m_floats[0] = 0;
m_floats[1] = 0;
// copy to permit to modify it :
std::string tmpStr = _str;
etk::String tmpStr = _str;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -214,13 +214,13 @@ namespace etk {
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_int32_t(tmpStr);
m_floats[1] = m_floats[0];
} else {
m_floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
m_floats[0] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
m_floats[1] = etk::string_to_int32_t(tmpStr);
}
@ -254,12 +254,12 @@ namespace etk {
}
#endif
template<> Vector2D<uint32_t>::operator std::string() const {
std::string str;
template<> Vector2D<uint32_t>::operator etk::String() const {
etk::String str;
str = "(";
str += etk::to_string(x());
str += etk::toString(x());
str += ",";
str += etk::to_string(y());
str += etk::toString(y());
str += ")";
return str;
}
@ -275,11 +275,11 @@ namespace etk {
}
#endif
template<> Vector2D<uint32_t>::Vector2D(const std::string& _str) {
template<> Vector2D<uint32_t>::Vector2D(const etk::String& _str) {
m_floats[0] = 0;
m_floats[1] = 0;
// copy to permit to modify it :
std::string tmpStr = _str;
etk::String tmpStr = _str;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -287,13 +287,13 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_int32_t(tmpStr);
m_floats[1] = m_floats[0];
} else {
m_floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
m_floats[0] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
m_floats[1] = etk::string_to_int32_t(tmpStr);
}
@ -312,7 +312,7 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_int32_t(tmpStr);
@ -326,12 +326,12 @@ namespace etk {
}
#endif
template<> Vector2D<float>::operator std::string() const {
std::string str;
template<> Vector2D<float>::operator etk::String() const {
etk::String str;
str = "(";
str += etk::to_string(x());
str += etk::toString(x());
str += ",";
str += etk::to_string(y());
str += etk::toString(y());
str += ")";
return str;
}
@ -347,11 +347,11 @@ namespace etk {
}
#endif
template<> Vector2D<float>::Vector2D(const std::string& _str) {
template<> Vector2D<float>::Vector2D(const etk::String& _str) {
m_floats[0] = 0;
m_floats[1] = 0;
// copy to permit to modify it :
std::string tmpStr = _str;
etk::String tmpStr = _str;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -359,13 +359,13 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_float(tmpStr);
m_floats[1] = m_floats[0];
} else {
m_floats[0] = etk::string_to_float(std::string(tmpStr, 0, posComa));
m_floats[0] = etk::string_to_float(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
m_floats[1] = etk::string_to_float(tmpStr);
}
@ -384,7 +384,7 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
m_floats[0] = etk::string_to_float(tmpStr);
@ -398,103 +398,103 @@ namespace etk {
}
#endif
template<> std::string to_string<vec2>(const vec2& _obj) {
std::string str;
template<> etk::String to_string<vec2>(const vec2& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<vec2>(const vec2& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<ivec2>(const ivec2& _obj) {
std::string str;
template<> etk::String to_string<ivec2>(const ivec2& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<ivec2>(const ivec2& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<uivec2>(const uivec2& _obj) {
std::string str;
template<> etk::String to_string<uivec2>(const uivec2& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<uivec2>(const uivec2& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<bvec2>(const bvec2& _obj) {
std::string str;
template<> etk::String to_string<bvec2>(const bvec2& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<bvec2>(const bvec2& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> bool from_string<vec2>(vec2& _variableRet, const std::string& _value) {
template<> bool from_string<vec2>(vec2& _variableRet, const etk::String& _value) {
_variableRet = vec2(_value);
return true;
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::string& _value) {
template<> bool from_string<ivec2>(ivec2& _variableRet, const etk::String& _value) {
_variableRet = ivec2(_value);
return true;
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::string& _value) {
template<> bool from_string<uivec2>(uivec2& _variableRet, const etk::String& _value) {
_variableRet = uivec2(_value);
return true;
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::string& _value) {
template<> bool from_string<bvec2>(bvec2& _variableRet, const etk::String& _value) {
_variableRet = bvec2(_value);
return true;
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
};

View File

@ -6,6 +6,7 @@
#include <etk/math/Vector3D.hpp>
#include <etk/types.hpp>
#include <etk/String.hpp>
#pragma once
@ -68,7 +69,7 @@ namespace etk {
* @brief Constructor with string data
* @param[in] _str Sting containing the value to parse
*/
Vector2D(const std::string& _str);
Vector2D(const etk::String& _str);
#if __CPP_VERSION__ >= 2011
Vector2D(const std::u32string& _str);
#endif
@ -545,7 +546,7 @@ namespace etk {
* @brief String caster of the object.
* @return the Object cated in string (x.x,y.y)
*/
operator std::string() const;
operator etk::String() const;
#if __CPP_VERSION__ >= 2011
/**
* @brief String caster of the object.

View File

@ -138,81 +138,81 @@ vec3 quaternionToEulerXYZ(const btQuaternion& _quat) {
#endif
namespace etk {
template<> std::string to_string<vec3>(const vec3& _obj) {
std::string str;
template<> etk::String to_string<vec3>(const vec3& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ",";
str += etk::to_string(_obj.z());
str += etk::toString(_obj.z());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<vec3>(const vec3& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<ivec3>(const ivec3& _obj) {
std::string str;
template<> etk::String to_string<ivec3>(const ivec3& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ",";
str += etk::to_string(_obj.z());
str += etk::toString(_obj.z());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<ivec3>(const ivec3& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<uivec3>(const uivec3& _obj) {
std::string str;
template<> etk::String to_string<uivec3>(const uivec3& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ",";
str += etk::to_string(_obj.z());
str += etk::toString(_obj.z());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<uivec3>(const uivec3& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> std::string to_string<bvec3>(const bvec3& _obj) {
std::string str;
template<> etk::String to_string<bvec3>(const bvec3& _obj) {
etk::String str;
str = "(";
str += etk::to_string(_obj.x());
str += etk::toString(_obj.x());
str += ",";
str += etk::to_string(_obj.y());
str += etk::toString(_obj.y());
str += ",";
str += etk::to_string(_obj.z());
str += etk::toString(_obj.z());
str += ")";
return str;
}
#if __CPP_VERSION__ >= 2011
template<> std::u32string to_u32string<bvec3>(const bvec3& _obj) {
return etk::to_u32string(etk::to_string(_obj));
return etk::to_u32string(etk::toString(_obj));
}
#endif
template<> bool from_string<vec3>(vec3& _variableRet, const std::string& _value) {
template<> bool from_string<vec3>(vec3& _variableRet, const etk::String& _value) {
float floats[3];
floats[0] = 0;
floats[1] = 0;
floats[2] = 0;
// copy to permit to modify it :
std::string tmpStr = _value;
etk::String tmpStr = _value;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -220,23 +220,23 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[0] = etk::string_to_float(tmpStr);
floats[1] = floats[0];
floats[2] = floats[1];
} else {
floats[0] = etk::string_to_float(std::string(tmpStr, 0, posComa));
floats[0] = etk::string_to_float(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[1] = etk::string_to_float(tmpStr);
floats[2] = floats[1];
} else {
floats[1] = etk::string_to_float(std::string(tmpStr, 0, posComa));
floats[1] = etk::string_to_float(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
floats[2] = etk::string_to_float(tmpStr);
}
@ -247,17 +247,17 @@ namespace etk {
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::string& _value) {
template<> bool from_string<ivec3>(ivec3& _variableRet, const etk::String& _value) {
int32_t floats[3];
floats[0] = 0;
floats[1] = 0;
floats[2] = 0;
// copy to permit to modify it :
std::string tmpStr = _value;
etk::String tmpStr = _value;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -265,23 +265,23 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[0] = etk::string_to_int32_t(tmpStr);
floats[1] = floats[0];
floats[2] = floats[1];
} else {
floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
floats[0] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[1] = etk::string_to_int32_t(tmpStr);
floats[2] = floats[1];
} else {
floats[1] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
floats[1] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
floats[2] = etk::string_to_int32_t(tmpStr);
}
@ -292,17 +292,17 @@ namespace etk {
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::string& _value) {
template<> bool from_string<uivec3>(uivec3& _variableRet, const etk::String& _value) {
uint32_t floats[3];
floats[0] = 0;
floats[1] = 0;
floats[2] = 0;
// copy to permit to modify it :
std::string tmpStr = _value;
etk::String tmpStr = _value;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -310,23 +310,23 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[0] = etk::string_to_int32_t(tmpStr);
floats[1] = floats[0];
floats[2] = floats[1];
} else {
floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
floats[0] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[1] = etk::string_to_int32_t(tmpStr);
floats[2] = floats[1];
} else {
floats[1] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
floats[1] = etk::string_to_int32_t(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
floats[2] = etk::string_to_int32_t(tmpStr);
}
@ -337,17 +337,17 @@ namespace etk {
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::string& _value) {
template<> bool from_string<bvec3>(bvec3& _variableRet, const etk::String& _value) {
bool floats[3];
floats[0] = false;
floats[1] = false;
floats[2] = false;
// copy to permit to modify it :
std::string tmpStr = _value;
etk::String tmpStr = _value;
if (tmpStr[0] == '(') {
tmpStr.erase(tmpStr.begin());
}
@ -355,23 +355,23 @@ namespace etk {
tmpStr.erase(tmpStr.end()-1);
}
size_t posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[0] = etk::string_to_bool(tmpStr);
floats[1] = floats[0];
floats[2] = floats[1];
} else {
floats[0] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
floats[0] = etk::string_to_bool(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
posComa = tmpStr.find(',');
if (posComa == std::string::npos) {
if (posComa == etk::String::npos) {
// no coma ...
// in every case, we parse the first element :
floats[1] = etk::string_to_bool(tmpStr);
floats[2] = floats[1];
} else {
floats[1] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
floats[1] = etk::string_to_bool(etk::String(tmpStr, 0, posComa));
tmpStr.erase(0,posComa+1);
floats[2] = etk::string_to_bool(tmpStr);
}
@ -382,7 +382,7 @@ namespace etk {
}
#if __CPP_VERSION__ >= 2011
template<> bool from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
return from_string(_variableRet, etk::toString(_value));
}
#endif
};

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
#pragma once
#include <etk/os/FSNodeRight.hpp>
#include <etk/stdTools.hpp>
/**
* @brief Local maximum file name size
*/
@ -40,28 +41,28 @@ namespace etk {
* @brief Set the firt argument of the application start (this permit to get the real position of the execution path and executable position
* @param[in] _val First parameter.
*/
void setArgZero(const std::string& _val);
void setArgZero(const etk::String& _val);
/**
* @brief Simplify a path with all the complication that mean ".." or "///\//"
* @param[in] _input Parth to simplify
* @return the simplified path.
*/
std::string simplifyPath(std::string _input);
etk::String simplifyPath(etk::String _input);
/**
* @brief Get application name.
* @return The application name
*/
std::string FSNodeGetApplicationName();
etk::String FSNodeGetApplicationName();
/**
* @brief Get application binary path.
* @return The application path
*/
std::string FSNodeGetApplicationPath();
etk::String FSNodeGetApplicationPath();
/**
* @brief Get the user Home path.
* @return The Home path: "~"
*/
std::string FSNodeGetHomePath();
etk::String FSNodeGetHomePath();
/**
* @brief List of Type that a node can have (this wrap some type that not exist on Windows)
*/
@ -176,9 +177,9 @@ namespace etk {
*/
class FSNode {
private:
std::string m_libSearch; //!< the name Of the subLib that system must church subData
std::string m_userFileName; //!< the name requested by the User
std::string m_systemFileName; //!< the compleate filename for the system
etk::String m_libSearch; //!< the name Of the subLib that system must church subData
etk::String m_userFileName; //!< the name requested by the User
etk::String m_systemFileName; //!< the compleate filename for the system
enum FSNType m_type; //!< the Type of data requested by the User
enum typeNode m_typeNode; //!< type of the current file/Folder/Link
etk::FSNodeRight m_rights; //!< IO right of the current file
@ -194,7 +195,7 @@ namespace etk {
* @brief Constructor
* @param[in] _path Path of the curent file /folder ...
*/
FSNode(const std::string& _path = "~");
FSNode(const etk::String& _path = "~");
#if __CPP_VERSION__ >= 2011
FSNode(const std::u32string& _path);
#endif
@ -216,7 +217,7 @@ namespace etk {
* @brief Common set name of the Node (if the user decide to change the node selection
* @param[in] _newName Name of the Node
*/
void privateSetName(std::string _newName);
void privateSetName(etk::String _newName);
#if __CPP_VERSION__ >= 2011
void privateSetName(const std::u32string& _newName);
#endif
@ -267,7 +268,7 @@ namespace etk {
* @return true action done
* @return false action not done
*/
void setName(const std::string& _newName);
void setName(const etk::String& _newName);
#if __CPP_VERSION__ >= 2011
void setName(const std::u32string& _newName);
#endif
@ -275,7 +276,7 @@ namespace etk {
* @brief Get the Generate FileSystem name
* @return the requested filename
*/
std::string getFileSystemName() const;
etk::String getFileSystemName() const;
#if __CPP_VERSION__ >= 2011
std::u32string getUFileSystemName() const;
#endif
@ -284,7 +285,7 @@ namespace etk {
* @return the common name define (like /xxxxx/xxxxx/ or c:/xxxxx/xxxxx/)
* @note Auto remove of ../../../ and //
*/
std::string getNameFolder() const;
etk::String getNameFolder() const;
#if __CPP_VERSION__ >= 2011
std::u32string getUNameFolder() const;
#endif
@ -293,7 +294,7 @@ namespace etk {
* @return All the user name definition (like /xxxxx/xxxxx/myFile.kkk or c:/xxxxx/xxxxx/myFile.kkk)
* @note Auto remove of ../../../ and //
*/
std::string getName() const;
etk::String getName() const;
#if __CPP_VERSION__ >= 2011
std::u32string getUName() const;
#endif
@ -301,7 +302,7 @@ namespace etk {
* @brief Get the file or current file name (if it was a file)
* @return the name of the node (like myFile.kkk)
*/
std::string getNameFile() const;
etk::String getNameFile() const;
#if __CPP_VERSION__ >= 2011
std::u32string getUNameFile() const;
#endif
@ -310,7 +311,7 @@ namespace etk {
* @return the common name define (like DATA:xxxxx/xxxxx/)
* @note Auto remove of ../../../ and //
*/
std::string getRelativeFolder() const;
etk::String getRelativeFolder() const;
#if __CPP_VERSION__ >= 2011
std::u32string getURelativeFolder() const;
#endif
@ -326,7 +327,7 @@ namespace etk {
* @return true : action done
* @return false : action not done
*/
bool move(const std::string& _path);
bool move(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool move(const std::u32string& _path);
#endif
@ -352,7 +353,7 @@ namespace etk {
* @brief Get the creating time of the File
* @return The time requested (in string)
*/
std::string timeCreatedString() const;
etk::String timeCreatedString() const;
#if __CPP_VERSION__ >= 2011
std::u32string timeUCreatedString() const;
#endif
@ -365,7 +366,7 @@ namespace etk {
* @brief Get the modifying time of the File
* @return The time requested (in string)
*/
std::string timeModifiedString() const;
etk::String timeModifiedString() const;
#if __CPP_VERSION__ >= 2011
std::u32string timeUModifiedString() const;
#endif
@ -378,7 +379,7 @@ namespace etk {
* @brief Get the Accessed time of the File
* @return The time requested (in string)
*/
std::string timeAccessedString() const;
etk::String timeAccessedString() const;
#if __CPP_VERSION__ >= 2011
std::u32string timeUAccessedString() const;
#endif
@ -437,7 +438,7 @@ namespace etk {
std::vector<etk::FSNode*> folderGetSubList(bool _showHidenFile = true,
bool _getFolderAndOther = true,
bool _getFile = true,
const std::string& _filter = ".*");
const etk::String& _filter = ".*");
/**
* @brief Get the List of all node inside a node (folder only)
* @param[in] _getFolder get folder
@ -445,7 +446,7 @@ namespace etk {
* @param[in] _filter Generic regex string to filter file names
* @return The requested list
*/
std::vector<std::string> folderGetSub(bool _getFolder, bool _getFile, const std::string& _filter);
std::vector<etk::String> folderGetSub(bool _getFolder, bool _getFile, const etk::String& _filter);
/**
* @brief Get the father node of this node
* @return The requested node
@ -456,7 +457,7 @@ namespace etk {
* @param[out] _output List of all the File names (You must clear it before set it in)
* @param[in] _recursiveEnable Activate the recursive mode (enable by default)
*/
void folderGetRecursiveFiles(std::vector<std::string>& _output, bool _recursiveEnable=true);
void folderGetRecursiveFiles(std::vector<etk::String>& _output, bool _recursiveEnable=true);
#if __CPP_VERSION__ >= 2011
void folderGetRecursiveFiles(std::vector<std::u32string>& _output, bool _recursiveEnable=true);
#endif
@ -470,7 +471,7 @@ namespace etk {
* @brief Get the extention of the Node
* @return the requested extention
*/
std::string fileGetExtention();
etk::String fileGetExtention();
#if __CPP_VERSION__ >= 2011
std::u32string fileUGetExtention();
#endif
@ -529,7 +530,7 @@ namespace etk {
* @return true The file is not ended.
* @return false The file is ended.
*/
bool fileGets(std::string& _output);
bool fileGets(etk::String& _output);
/**
* @brief Write data on the file
* @param[in] _input data to write.
@ -543,7 +544,7 @@ namespace etk {
* @return true Write done corectly.
* @return false ErrorOn write.
*/
bool filePuts(const std::string& _input);
bool filePuts(const etk::String& _input);
/**
* @brief Read data from the file
* @param[in,out] _data Pointer on the buffer that might be set the data
@ -568,15 +569,15 @@ namespace etk {
* @note not stable API ...
*/
etk::FSNode& operator<< (const std::stringstream& _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const std::string& _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
//! @copydoc etk::FSNode::operator<<(const etk::Stringstream&)
etk::FSNode& operator<< (const etk::String& _data);
//! @copydoc etk::FSNode::operator<<(const etk::Stringstream&)
etk::FSNode& operator<< (const char* _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
//! @copydoc etk::FSNode::operator<<(const etk::Stringstream&)
etk::FSNode& operator<< (const int32_t _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
//! @copydoc etk::FSNode::operator<<(const etk::Stringstream&)
etk::FSNode& operator<< (const uint32_t _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
//! @copydoc etk::FSNode::operator<<(const etk::Stringstream&)
etk::FSNode& operator<< (const float _data);
/**
* @brief Get the position in the file.
@ -606,11 +607,11 @@ namespace etk {
return value;
}
/**
* @brief Read all element in a file and set it in a generic std::string
* @brief Read all element in a file and set it in a generic etk::String
* @return the read string
*/
std::string fileReadAllString() {
std::string value;
etk::String fileReadAllString() {
etk::String value;
value.resize(fileSize());
fileRead(&value[0], sizeof(char), fileSize()/sizeof(char));
return value;
@ -632,7 +633,7 @@ namespace etk {
* @brief Write all the vector in a file
* @param[in] _value String data to write in the File
*/
void fileWriteAll(const std::string& _value) {
void fileWriteAll(const etk::String& _value) {
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char));
}
#if __CPP_VERSION__ >= 2011
@ -675,7 +676,7 @@ namespace etk {
* @brief Get the home folder of the user
* @return the home folder : like : "/home/machin/"
*/
std::string getUserHomeFolder();
etk::String getUserHomeFolder();
#if __CPP_VERSION__ >= 2011
std::u32string getUUserHomeFolder();
#endif
@ -683,7 +684,7 @@ namespace etk {
* @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)
*/
std::string getUserRunFolder();
etk::String getUserRunFolder();
#if __CPP_VERSION__ >= 2011
std::u32string getUUserRunFolder();
#endif
@ -695,7 +696,7 @@ namespace etk {
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @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 etk::String& _refName, const etk::String& _folderName);
#if __CPP_VERSION__ >= 2011
//! @previous
void setName(const std::u32string& _refName, const std::u32string& _folderName);
@ -705,7 +706,7 @@ namespace etk {
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme
*/
std::string getName(const std::string& _refName);
etk::String getName(const etk::String& _refName);
#if __CPP_VERSION__ >= 2011
//! @previous
std::u32string getName(const std::u32string& _refName);
@ -715,7 +716,7 @@ namespace etk {
* @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 std::string& _refName, const std::string& _folderName);
void setNameDefault(const etk::String& _refName, const etk::String& _folderName);
#if __CPP_VERSION__ >= 2011
//! @previous
void setNameDefault(const std::u32string& _refName, const std::u32string& _folderName);
@ -725,7 +726,7 @@ namespace etk {
* @param[in] _refName Theme cathegorie ex : "GUI" "SHADER" "DEFAULT"
* @return the path of the theme
*/
std::string getNameDefault(const std::string& _refName);
etk::String getNameDefault(const etk::String& _refName);
#if __CPP_VERSION__ >= 2011
//! @previous
std::u32string getNameDefault(const std::u32string& _refName);
@ -734,7 +735,7 @@ namespace etk {
* @brief Get the list of all the theme folder availlable in the user Home/appl
* @return The list of elements
*/
std::vector<std::string> list();
std::vector<etk::String> list();
#if __CPP_VERSION__ >= 2011
//! @previous
std::vector<std::u32string> listU();
@ -745,7 +746,7 @@ namespace etk {
* @param[in] _path Folder/File/Pipe path of the node
* @return size of the file
*/
uint64_t FSNodeGetSize(const std::string& _path);
uint64_t FSNodeGetSize(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetSize(const std::u32string& _path);
#endif
@ -756,7 +757,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeRemove(const std::string& _path);
bool FSNodeRemove(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeRemove(const std::u32string& _path);
#endif
@ -766,7 +767,7 @@ namespace etk {
* @return number of File inside
* @return -1 : An error occured
*/
int64_t FSNodeGetCount(const std::string& _path);
int64_t FSNodeGetCount(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
int64_t FSNodeGetCount(const std::u32string& _path);
#endif
@ -778,7 +779,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
bool FSNodeCreate(const etk::String& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#if __CPP_VERSION__ >= 2011
bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#endif
@ -788,7 +789,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeExist(const std::string& _path);
bool FSNodeExist(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeExist(const std::u32string& _path);
#endif
@ -799,7 +800,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeMove(const std::string& _path1, const std::string& _path2);
bool FSNodeMove(const etk::String& _path1, const etk::String& _path2);
#if __CPP_VERSION__ >= 2011
bool FSNodeMove(const std::u32string& _path1, const std::u32string& _path2);
#endif
@ -809,7 +810,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
etk::FSNodeRight FSNodeGetRight(const std::string& _path);
etk::FSNodeRight FSNodeGetRight(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
etk::FSNodeRight FSNodeGetRight(const std::u32string& _path);
#endif
@ -819,7 +820,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
enum etk::typeNode FSNodeGetType(const std::string& _path);
enum etk::typeNode FSNodeGetType(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
enum etk::typeNode FSNodeGetType(const std::u32string& _path);
#endif
@ -829,7 +830,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeCreated(const std::string& _path);
uint64_t FSNodeGetTimeCreated(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeCreated(const std::u32string& _path);
#endif
@ -839,7 +840,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeModified(const std::string& _path);
uint64_t FSNodeGetTimeModified(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeModified(const std::u32string& _path);
#endif
@ -849,7 +850,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
uint64_t FSNodeGetTimeAccessed(const std::string& _path);
uint64_t FSNodeGetTimeAccessed(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
uint64_t FSNodeGetTimeAccessed(const std::u32string& _path);
#endif
@ -859,7 +860,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeTouch(const std::string& _path);
bool FSNodeTouch(const etk::String& _path);
#if __CPP_VERSION__ >= 2011
bool FSNodeTouch(const std::u32string& _path);
#endif
@ -870,7 +871,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeEcho(const std::string& _path, const std::string& _dataTowrite);
bool FSNodeEcho(const etk::String& _path, const etk::String& _dataTowrite);
#if __CPP_VERSION__ >= 2011
bool FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite);
#endif
@ -881,7 +882,7 @@ namespace etk {
* @return true : Action done corectly
* @return false : An error occured
*/
bool FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite);
bool FSNodeEchoAdd(const etk::String& _path, const etk::String& _dataTowrite);
#if __CPP_VERSION__ >= 2011
bool FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite);
#endif
@ -890,7 +891,7 @@ namespace etk {
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _historyCount number of saved file in the history (-xxx)
*/
void FSNodeHistory(const std::string& _path, int32_t _historyCount);
void FSNodeHistory(const etk::String& _path, int32_t _historyCount);
#if __CPP_VERSION__ >= 2011
void FSNodeHistory(const std::u32string& _path, int32_t _historyCount);
#endif
@ -899,19 +900,19 @@ namespace etk {
* @param[in] _path Folder/File/Pipe path of the node
* @return all the data of the file in a string
*/
std::string FSNodeReadAllData(const std::string& _path);
etk::String FSNodeReadAllData(const etk::String& _path);
/**
* @brief Write all the data in a file
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _data All the data of the file in a string
*/
void FSNodeWriteAllData(const std::string& _path, const std::string& _data);
void FSNodeWriteAllData(const etk::String& _path, const etk::String& _data);
/**
* @brief Read all the data from a file
* @param[in] _path Folder/File/Pipe path of the node
* @return all the data of the file in a typed vector
*/
template<typename TTT> std::vector<TTT> FSNodeReadAllDataType(const std::string& _path) {
template<typename TTT> std::vector<TTT> FSNodeReadAllDataType(const etk::String& _path) {
std::vector<TTT> out;
etk::FSNode node(_path);
if (node.fileOpenRead() == false) {
@ -932,7 +933,7 @@ namespace etk {
* @param[in] _path Folder/File/Pipe path of the node
* @param[in] _data All the data of the file in a vector Typed bits ...
*/
template<typename TTT> void FSNodeWriteAllDataType(const std::string& _path, const std::vector<TTT>& _data) {
template<typename TTT> void FSNodeWriteAllDataType(const etk::String& _path, const std::vector<TTT>& _data) {
etk::FSNode node(_path);
if (node.fileOpenWrite() == false) {
//TK_ERROR("can not open file : '" << node << "'");
@ -946,7 +947,7 @@ namespace etk {
* @param[in] _path "DATA:xxx" etk file name.
* @return return real file name "/aaa/bbb/ccc/xxx"
*/
std::string FSNodeGetRealName(const std::string& _path);
etk::String FSNodeGetRealName(const etk::String& _path);
/**
* @brief Get all the Path contain in the specidy path:
@ -961,7 +962,7 @@ namespace etk {
* // out contain: {"{@ewol}DATA:font"}
* @endcode
*/
std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path);
std::vector<etk::String> FSNodeExplodeMultiplePath(const etk::String& _path);
};

View File

@ -152,8 +152,8 @@ void etk::FSNodeRight::setOtherRunable(bool _newStatus) {
}
#endif
std::string etk::FSNodeRight::getRight() const {
std::string tmp;
etk::String etk::FSNodeRight::getRight() const {
etk::String tmp;
if (isUserReadable() == true) {
tmp += "r";
} else {

View File

@ -147,7 +147,7 @@ namespace etk {
* @brief Get the write written in a string mode (like in linux rw-r-----)
* @return String with the right in string
*/
std::string getRight() const;
etk::String getRight() const;
};
//! @not_in_doc
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);

View File

@ -224,9 +224,9 @@ bool utf8::first(const char _input) {
return false;
}
#if __CPP_VERSION__ >= 2011
std::u32string utf8::convertUnicode(const std::string& _input) {
std::u32string utf8::convertUnicode(const etk::String& _input) {
TK_TODO("implement this function ...");
return U"TODO ... std::u32string utf8::convertUnicode(const std::string& _input)";
return U"TODO ... std::u32string utf8::convertUnicode(const etk::String& _input)";
}
#endif

View File

@ -6,6 +6,8 @@
#pragma once
#include <etk/types.hpp>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <vector>
#include <sstream>
#include <iostream>
@ -94,7 +96,7 @@ namespace utf8 {
*/
char32_t convertChar32(const char* _input);
#if __CPP_VERSION__ >= 2011
std::u32string convertUnicode(const std::string& _input);
std::u32string convertUnicode(const etk::String& _input);
#endif
/**
* @brief Iterator on a simple std::string that contain utf8 value
@ -475,24 +477,7 @@ namespace etk {
}
};
namespace etk {
template <class TYPE> const TYPE& min(const TYPE& _val1, const TYPE& _val2) {
return (_val1 > _val2) ? _val2 : _val1;
}
template <class TYPE> const TYPE& max(const TYPE& _val1, const TYPE& _val2) {
return (_val1 > _val2) ? _val1 : _val2;
}
/**
* @brief in std, we have min, max but not avg ==> it is missing... the Define of avg template.
* @param[in] _min Minimum value of the range
* @param[in] _val The value that we want a min/max
* @param[in] _max Maximum value of the range
* @return Value that min/max applied
*/
template <class TYPE> const TYPE& avg(const TYPE& _min, const TYPE& _val, const TYPE& _max) {
return std::min(std::max(_min,_val),_max);
}
};
namespace std {
#if __CPP_VERSION__ >= 2011

View File

@ -39,8 +39,6 @@
#endif
#endif
#include <etk/stdTools.hpp>
#ifndef ETK_BUILD_LINEARMATH
//! @brief If not using linear math from bullet lib, we need to define the basic element of a btScalar (float)
using btScalar = float;
@ -67,3 +65,21 @@
#define ETK_EXPORT_VISIBILITY __attribute__ ((visibility ("default")))
#endif
namespace etk {
template <class TYPE> const TYPE& min(const TYPE& _val1, const TYPE& _val2) {
return (_val1 > _val2) ? _val2 : _val1;
}
template <class TYPE> const TYPE& max(const TYPE& _val1, const TYPE& _val2) {
return (_val1 > _val2) ? _val1 : _val2;
}
/**
* @brief in std, we have min, max but not avg ==> it is missing... the Define of avg template.
* @param[in] _min Minimum value of the range
* @param[in] _val The value that we want a min/max
* @param[in] _max Maximum value of the range
* @return Value that min/max applied
*/
template <class TYPE> const TYPE& avg(const TYPE& _min, const TYPE& _val, const TYPE& _max) {
return std::min(std::max(_min,_val),_max);
}
};

View File

@ -29,6 +29,7 @@ def configure(target, my_module):
# add the file to compile:
my_module.add_src_file([
'etk/debug.cpp',
'etk/String.cpp',
'etk/etk.cpp',
'etk/stdTools.cpp',
'etk/tool.cpp',
@ -81,7 +82,7 @@ def configure(target, my_module):
my_module.compile_version("c++", 2011)
# add dependency of the generic C++ library:
my_module.add_depend([
'cxx',
'c',
'm',
'elog',
'ememory'