[DEV] change the std::to string properties ...
This commit is contained in:
parent
28c433bb4e
commit
4c20238d3c
@ -187,7 +187,7 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithRGBUnsigned8(const std::string&
|
||||
etk::Color<uint8_t, 4> etk::parseStringColorNamed(const std::string& _input) {
|
||||
// direct named color ...
|
||||
for (int32_t iii=0; iii<getColorSize(); iii++) {
|
||||
if (std::compare_no_case(getColorList()[iii].colorName, _input) == true) {
|
||||
if (etk::compare_no_case(getColorList()[iii].colorName, _input) == true) {
|
||||
return getColorList()[iii].color;
|
||||
}
|
||||
}
|
||||
|
59
etk/Color.h
59
etk/Color.h
@ -307,29 +307,29 @@ namespace etk {
|
||||
&& inputData[0] == '#') {
|
||||
Color<uint8_t, 4> value = etk::parseStringStartWithSharp(std::string(_input, 1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb(", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb(", false) == true) {
|
||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(std::string(_input, 4, _input.size()-1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb[FLOAT](", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb[FLOAT](", false) == true) {
|
||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 11, _input.size()-1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb[DOUBLE](", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb[DOUBLE](", false) == true) {
|
||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 12, _input.size()-1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb[U32](", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb[U32](", false) == true) {
|
||||
Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(std::string(_input, 9, _input.size()-1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb[U16](", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb[U16](", false) == true) {
|
||||
Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(std::string(_input, 9, _input.size()-1));
|
||||
*this = value;
|
||||
} else if(std::start_with(_input, "rgb[U8](", false) == true) {
|
||||
} else if(etk::start_with(_input, "rgb[U8](", false) == true) {
|
||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(std::string(_input, 8, _input.size()-1));
|
||||
*this = value;
|
||||
} else {
|
||||
Color<uint8_t, 4> value = etk::parseStringColorNamed(_input);
|
||||
*this = value;
|
||||
}
|
||||
TK_VERBOSE(" ==> converted color string : '" << _input << "' ==> " << *this);
|
||||
//TK_VERBOSE(" ==> converted color string : '" << _input << "' ==> " << *this);
|
||||
};
|
||||
|
||||
|
||||
@ -337,15 +337,15 @@ namespace etk {
|
||||
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
|
||||
if (MY_TYPE_SIZE >= 3) {
|
||||
_os << "#";
|
||||
_os << (std::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
|
||||
_os << (etk::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
|
||||
if (MY_TYPE_SIZE >= 2) {
|
||||
_os << (std::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
|
||||
_os << (etk::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 3) {
|
||||
_os << (std::to_string_format<uint32_t, 2>(_obj.b(), std::hex)).c_str();
|
||||
_os << (etk::to_string_format<uint32_t, 2>(_obj.b(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 4) {
|
||||
_os << (std::to_string_format<uint32_t, 2>(_obj.a(), std::hex)).c_str();
|
||||
_os << (etk::to_string_format<uint32_t, 2>(_obj.a(), std::hex)).c_str();
|
||||
}
|
||||
} else {
|
||||
if (MY_TYPE_SIZE >= 2) {
|
||||
@ -354,10 +354,10 @@ namespace etk {
|
||||
_os << "Mono";
|
||||
}
|
||||
_os << "[U8](";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
|
||||
if (MY_TYPE_SIZE >= 2) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
|
||||
}
|
||||
_os << ")";
|
||||
}
|
||||
@ -375,18 +375,18 @@ namespace etk {
|
||||
_os << "Mono";
|
||||
}
|
||||
_os << "[U16](";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 4>(_obj.r(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.r(), std::hex)).c_str();
|
||||
if (MY_TYPE_SIZE >= 2) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 4>(_obj.g(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.g(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 3) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 4>(_obj.b(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.b(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 4) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 4>(_obj.a(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.a(), std::hex)).c_str();
|
||||
}
|
||||
_os << ")";
|
||||
return _os;
|
||||
@ -403,18 +403,18 @@ namespace etk {
|
||||
_os << "Mono";
|
||||
}
|
||||
_os << "[U32](";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 8>(_obj.r(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.r(), std::hex)).c_str();
|
||||
if (MY_TYPE_SIZE >= 2) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 8>(_obj.g(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.g(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 3) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 8>(_obj.b(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.b(), std::hex)).c_str();
|
||||
}
|
||||
if (MY_TYPE_SIZE >= 4) {
|
||||
_os << ",";
|
||||
_os << "0x" << (std::to_string_format<uint32_t, 8>(_obj.a(), std::hex)).c_str();
|
||||
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.a(), std::hex)).c_str();
|
||||
}
|
||||
_os << ")";
|
||||
return _os;
|
||||
@ -639,6 +639,23 @@ namespace etk {
|
||||
extern const Color<> yellow; //!< ++ [color=yellow] yellow color [/color] ++
|
||||
extern const Color<> yellowGreen; //!< ++ [color=yellowGreen] yellowGreen color [/color] ++
|
||||
};
|
||||
/*
|
||||
template<> std::string etk::to_string<Color<MY_TYPE, MY_TYPE_SIZE>>(const Color<MY_TYPE, MY_TYPE_SIZE>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string etk::to_u32string<Color<MY_TYPE, MY_TYPE_SIZE>>(const Color<MY_TYPE, MY_TYPE_SIZE>& _val) {
|
||||
return etk::to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool etk::from_string<Color<MY_TYPE, MY_TYPE_SIZE>>(Color<MY_TYPE, MY_TYPE_SIZE>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<MY_TYPE, MY_TYPE_SIZE>(etk::to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool etk::from_string<Color<MY_TYPE, MY_TYPE_SIZE>>(Color<MY_TYPE, MY_TYPE_SIZE>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<MY_TYPE, MY_TYPE_SIZE>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -384,3 +384,74 @@ template<> template<> Color<uint16_t,4>::Color(const Color<double, 4>& _obj) {
|
||||
|
||||
// ===========================================================================================================
|
||||
|
||||
/*
|
||||
template<> std::string to_string<Color<int16_t, 1>>(const Color<int16_t, 1>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int16_t, 1>>(const Color<int16_t, 1>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int16_t, 1>>(Color<int16_t, 1>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int16_t, 1>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int16_t, 1>>(Color<int16_t, 1>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int16_t, 1>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int16_t, 2>>(const Color<int16_t, 2>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int16_t, 2>>(const Color<int16_t, 2>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int16_t, 2>>(Color<int16_t, 2>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int16_t, 2>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int16_t, 2>>(Color<int16_t, 2>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int16_t, 2>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int16_t, 3>>(const Color<int16_t, 3>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int16_t, 3>>(const Color<int16_t, 3>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int16_t, 3>>(Color<int16_t, 3>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int16_t, 3>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int16_t, 3>>(Color<int16_t, 3>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int16_t, 3>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int16_t, 4>>(const Color<int16_t, 4>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int16_t, 4>>(const Color<int16_t, 4>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int16_t, 4>>(Color<int16_t, 4>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int16_t, 4>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int16_t, 4>>(Color<int16_t, 4>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int16_t, 4>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
@ -384,3 +384,72 @@ template<> template<> Color<uint32_t,4>::Color(const Color<double, 4>& _obj) {
|
||||
|
||||
// ===========================================================================================================
|
||||
|
||||
/*
|
||||
template<> std::string to_string<Color<int32_t, 1>>(const Color<int32_t, 1>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int32_t, 1>>(const Color<int32_t, 1>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int32_t, 1>>(Color<int32_t, 1>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int32_t, 1>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int32_t, 1>>(Color<int32_t, 1>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int32_t, 1>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<> std::string to_string<Color<int32_t, 2>>(const Color<int32_t, 2>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int32_t, 2>>(const Color<int32_t, 2>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int32_t, 2>>(Color<int32_t, 2>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int32_t, 2>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int32_t, 2>>(Color<int32_t, 2>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int32_t, 2>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int32_t, 3>>(const Color<int32_t, 3>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int32_t, 3>>(const Color<int32_t, 3>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int32_t, 3>>(Color<int32_t, 3>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int32_t, 3>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int32_t, 3>>(Color<int32_t, 3>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int32_t, 3>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int32_t, 4>>(const Color<int32_t, 4>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int32_t, 4>>(const Color<int32_t, 4>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int32_t, 4>>(Color<int32_t, 4>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int32_t, 4>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int32_t, 4>>(Color<int32_t, 4>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int32_t, 4>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
@ -383,4 +383,75 @@ template<> template<> Color<uint8_t,4>::Color(const Color<double, 4>& _obj) {
|
||||
}
|
||||
|
||||
// ===========================================================================================================
|
||||
/*
|
||||
template<> std::string to_string<Color<int8_t, 1>>(const Color<int8_t, 1>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int8_t, 1>>(const Color<int8_t, 1>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int8_t, 1>>(Color<int8_t, 1>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int8_t, 1>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int8_t, 1>>(Color<int8_t, 1>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int8_t, 1>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int8_t, 2>>(const Color<int8_t, 2>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int8_t, 2>>(const Color<int8_t, 2>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int8_t, 2>>(Color<int8_t, 2>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int8_t, 2>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int8_t, 2>>(Color<int8_t, 2>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int8_t, 2>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int8_t, 3>>(const Color<int8_t, 3>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int8_t, 3>>(const Color<int8_t, 3>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int8_t, 3>>(Color<int8_t, 3>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int8_t, 3>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int8_t, 3>>(Color<int8_t, 3>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int8_t, 3>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<> std::string to_string<Color<int8_t, 4>>(const Color<int8_t, 4>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<int8_t, 4>>(const Color<int8_t, 4>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<int8_t, 4>>(Color<int8_t, 4>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<int8_t, 4>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<int8_t, 4>>(Color<int8_t, 4>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<int8_t, 4>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -383,3 +383,77 @@ template<> template<> Color<double,4>::Color(const Color<double, 4>& _obj) {
|
||||
}
|
||||
|
||||
// ===========================================================================================================
|
||||
|
||||
/*
|
||||
template<> std::string to_string<Color<double, 1>>(const Color<double, 1>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<double, 1>>(const Color<double, 1>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<double, 1>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<double, 1>>(Color<double, 1>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<double, 1>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<double, 2>>(const Color<double, 2>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<double, 2>>(const Color<double, 2>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<double, 2>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<double, 2>>(Color<double, 2>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<double, 2>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<double, 3>>(const Color<double, 3>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<double, 3>>(const Color<double, 3>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<double, 3>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<double, 3>>(Color<double, 3>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<double, 3>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> std::string to_string<Color<double, 4>>(const Color<double, 4>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<double, 4>>(const Color<double, 4>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<double, 4>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<double, 4>>(Color<double, 4>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<double, 4>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
@ -381,3 +381,72 @@ template<> template<> Color<float,4>::Color(const Color<double, 4>& _obj) {
|
||||
m_element[2] = (float)_obj.b();
|
||||
m_element[3] = (float)_obj.a();
|
||||
}
|
||||
|
||||
/*
|
||||
template<> std::string to_string<Color<float, 1>>(const Color<float, 1>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<float, 1>>(const Color<float, 1>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<float, 1>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<float, 1>>(Color<float, 1>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<float, 1>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<> std::string to_string<Color<float, 2>>(const Color<float, 2>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<float, 2>>(const Color<float, 2>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<float, 2>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<float, 2>>(Color<float, 2>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<float, 2>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<> std::string to_string<Color<float, 3>>(const Color<float, 3>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<float, 3>>(const Color<float, 3>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<float, 3>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<float, 3>>(Color<float, 3>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<float, 3>(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<> std::string to_string<Color<float, 4>>(const Color<float, 4>& _val) {
|
||||
return _val.getString();
|
||||
}
|
||||
template<> std::u32string to_u32string<Color<float, 4>>(const Color<float, 4>& _val) {
|
||||
return to_u32string(_val.getString());
|
||||
}
|
||||
|
||||
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = Color<float, 4>(to_string(_value));
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<Color<float, 4>>(Color<float, 4>& _variableRet, const std::string& _value) {
|
||||
_variableRet = Color<float, 4>(_value);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
@ -423,4 +423,37 @@ std::string etk::regexp::strTick(int32_t _pos) {
|
||||
}
|
||||
out += "^";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<> std::string etk::to_string<etk::RegExp<std::string>>(const etk::RegExp<std::string>& _val) {
|
||||
return _val.getRegExp();
|
||||
}
|
||||
template<> std::string etk::to_string<etk::RegExp<std::u32string>>(const etk::RegExp<std::u32string>& _val) {
|
||||
return _val.getRegExp();
|
||||
}
|
||||
template<> std::u32string etk::to_u32string<etk::RegExp<std::string>>(const etk::RegExp<std::string>& _val) {
|
||||
return _val.getURegExp();
|
||||
}
|
||||
template<> std::u32string etk::to_u32string<etk::RegExp<std::u32string>>(const etk::RegExp<std::u32string>& _val) {
|
||||
return _val.getURegExp();
|
||||
}
|
||||
|
||||
template<> bool etk::from_string<etk::RegExp<std::string>>(etk::RegExp<std::string>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet.compile(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool etk::from_string<etk::RegExp<std::u32string>>(etk::RegExp<std::u32string>& _variableRet, const std::u32string& _value) {
|
||||
_variableRet.compile(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool etk::from_string<etk::RegExp<std::string>>(etk::RegExp<std::string>& _variableRet, const std::string& _value) {
|
||||
_variableRet.compile(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool etk::from_string<etk::RegExp<std::u32string>>(etk::RegExp<std::u32string>& _variableRet, const std::string& _value) {
|
||||
_variableRet.compile(_value);
|
||||
return true;
|
||||
}
|
||||
|
13
etk/RegExp.h
13
etk/RegExp.h
@ -1344,7 +1344,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
m_areaFind.start=0;
|
||||
m_areaFind.stop=0;
|
||||
if (_exp.size() != 0) {
|
||||
compile(std::to_u32string(_exp));
|
||||
compile(etk::to_u32string(_exp));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1362,7 +1362,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
void compile(const std::string &_exp) {
|
||||
if (_exp.size() != 0) {
|
||||
TK_REG_DEBUG("normal string parse : '" << _exp << "'");
|
||||
compile(std::to_u32string(_exp));
|
||||
compile(etk::to_u32string(_exp));
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -1506,7 +1506,7 @@ template<class CLASS_TYPE> class RegExp {
|
||||
* @return the string representing the RegExp
|
||||
*/
|
||||
std::string getRegExp() const {
|
||||
return std::to_string(m_expressionRequested);
|
||||
return etk::to_string(m_expressionRequested);
|
||||
};
|
||||
/**
|
||||
* @previous
|
||||
@ -1856,6 +1856,13 @@ template<class CLASS_TYPE> class RegExp {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
public:
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const RegExp<CLASS_TYPE>& _obj) const {
|
||||
return _obj.m_expressionRequested == m_expressionRequested;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ void etk::Archive::display()
|
||||
|
||||
etk::Archive* etk::Archive::load(const std::string& _fileName) {
|
||||
etk::Archive* output=NULL;
|
||||
std::string tmpName = std::tolower(_fileName);
|
||||
std::string tmpName = etk::tolower(_fileName);
|
||||
// select the corect Loader :
|
||||
if( true == end_with(tmpName, ".zip")
|
||||
|| true == end_with(tmpName, ".apk") ) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/stdTools.h>
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector2D<int32_t>& _obj) {
|
||||
_os << "(";
|
||||
@ -88,18 +89,18 @@ namespace etk {
|
||||
template<> Vector2D<bool>::operator std::string() const {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(x());
|
||||
str += etk::to_string(x());
|
||||
str += ",";
|
||||
str += std::to_string(y());
|
||||
str += etk::to_string(y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> Vector2D<bool>::operator std::u32string() const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += std::to_u32string(x());
|
||||
str += etk::to_u32string(x());
|
||||
str += U",";
|
||||
str += std::to_u32string(y());
|
||||
str += etk::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -119,12 +120,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stob(tmpStr);
|
||||
m_floats[0] = etk::string_to_bool(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stob(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0, posComa+1);
|
||||
m_floats[1] = std::stob(tmpStr);
|
||||
m_floats[1] = etk::string_to_bool(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
||||
}
|
||||
@ -143,12 +144,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stob(tmpStr);
|
||||
m_floats[0] = etk::string_to_bool(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stob(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_bool(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0, posComa+1);
|
||||
m_floats[1] = std::stob(tmpStr);
|
||||
m_floats[1] = etk::string_to_bool(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
||||
}
|
||||
@ -156,18 +157,18 @@ namespace etk {
|
||||
template<> Vector2D<int32_t>::operator std::string() const {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(x());
|
||||
str += etk::to_string(x());
|
||||
str += ",";
|
||||
str += std::to_string(y());
|
||||
str += etk::to_string(y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> Vector2D<int32_t>::operator std::u32string() const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += std::to_u32string(x());
|
||||
str += etk::to_u32string(x());
|
||||
str += U",";
|
||||
str += std::to_u32string(y());
|
||||
str += etk::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -188,12 +189,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -213,12 +214,12 @@ namespace etk {
|
||||
if (posComa == 0) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stoi(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -226,9 +227,9 @@ namespace etk {
|
||||
template<> Vector2D<uint32_t>::operator std::string() const {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(x());
|
||||
str += etk::to_string(x());
|
||||
str += ",";
|
||||
str += std::to_string(y());
|
||||
str += etk::to_string(y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
@ -236,9 +237,9 @@ namespace etk {
|
||||
template<> Vector2D<uint32_t>::operator std::u32string() const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += std::to_u32string(x());
|
||||
str += etk::to_u32string(x());
|
||||
str += U",";
|
||||
str += std::to_u32string(y());
|
||||
str += etk::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -258,12 +259,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -283,12 +284,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stoi(tmpStr);
|
||||
m_floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stoi(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_int32_t(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stoi(tmpStr);
|
||||
m_floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -296,18 +297,18 @@ namespace etk {
|
||||
template<> Vector2D<float>::operator std::string() const {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(x());
|
||||
str += etk::to_string(x());
|
||||
str += ",";
|
||||
str += std::to_string(y());
|
||||
str += etk::to_string(y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> Vector2D<float>::operator std::u32string() const {
|
||||
std::u32string str;
|
||||
str = U"(";
|
||||
str += std::to_u32string(x());
|
||||
str += etk::to_u32string(x());
|
||||
str += U",";
|
||||
str += std::to_u32string(y());
|
||||
str += etk::to_u32string(y());
|
||||
str += U")";
|
||||
return str;
|
||||
}
|
||||
@ -327,12 +328,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stof(tmpStr);
|
||||
m_floats[0] = etk::string_to_float(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stof(std::string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_float(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stof(tmpStr);
|
||||
m_floats[1] = etk::string_to_float(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -351,12 +352,12 @@ namespace etk {
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
m_floats[0] = std::stof(tmpStr);
|
||||
m_floats[0] = etk::string_to_float(tmpStr);
|
||||
m_floats[1] = m_floats[0];
|
||||
} else {
|
||||
m_floats[0] = std::stof(std::u32string(tmpStr, 0, posComa));
|
||||
m_floats[0] = etk::string_to_float(std::u32string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
m_floats[1] = std::stof(tmpStr);
|
||||
m_floats[1] = etk::string_to_float(tmpStr);
|
||||
}
|
||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
||||
}
|
||||
@ -365,87 +366,87 @@ namespace etk {
|
||||
|
||||
|
||||
|
||||
template<> std::string std::to_string<vec2>(const vec2& _obj) {
|
||||
template<> std::string etk::to_string<vec2>(const vec2& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<vec2>(const vec2& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<vec2>(const vec2& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<ivec2>(const ivec2& _obj) {
|
||||
template<> std::string etk::to_string<ivec2>(const ivec2& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<ivec2>(const ivec2& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<ivec2>(const ivec2& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<uivec2>(const uivec2& _obj) {
|
||||
template<> std::string etk::to_string<uivec2>(const uivec2& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<uivec2>(const uivec2& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<uivec2>(const uivec2& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<bvec2>(const bvec2& _obj) {
|
||||
template<> std::string etk::to_string<bvec2>(const bvec2& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<bvec2>(const bvec2& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<bvec2>(const bvec2& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<vec2>(vec2& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<vec2>(vec2& _variableRet, const std::string& _value) {
|
||||
_variableRet = vec2(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<vec2>(vec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<ivec2>(ivec2& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<ivec2>(ivec2& _variableRet, const std::string& _value) {
|
||||
_variableRet = ivec2(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<ivec2>(ivec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<uivec2>(uivec2& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uivec2>(uivec2& _variableRet, const std::string& _value) {
|
||||
_variableRet = uivec2(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<uivec2>(uivec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<bvec2>(bvec2& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<bvec2>(bvec2& _variableRet, const std::string& _value) {
|
||||
_variableRet = bvec2(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<bvec2>(bvec2& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/stdTools.h>
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const ivec3& _obj) {
|
||||
_os << "(";
|
||||
@ -110,67 +111,67 @@ vec3 quaternionToEulerXYZ(const btQuaternion& _quat) {
|
||||
}
|
||||
|
||||
|
||||
template<> std::string std::to_string<vec3>(const vec3& _obj) {
|
||||
template<> std::string etk::to_string<vec3>(const vec3& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.z());
|
||||
str += etk::to_string(_obj.z());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<vec3>(const vec3& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<vec3>(const vec3& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<ivec3>(const ivec3& _obj) {
|
||||
template<> std::string etk::to_string<ivec3>(const ivec3& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.z());
|
||||
str += etk::to_string(_obj.z());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<ivec3>(const ivec3& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<ivec3>(const ivec3& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<uivec3>(const uivec3& _obj) {
|
||||
template<> std::string etk::to_string<uivec3>(const uivec3& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.z());
|
||||
str += etk::to_string(_obj.z());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<uivec3>(const uivec3& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<uivec3>(const uivec3& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> std::string std::to_string<bvec3>(const bvec3& _obj) {
|
||||
template<> std::string etk::to_string<bvec3>(const bvec3& _obj) {
|
||||
std::string str;
|
||||
str = "(";
|
||||
str += std::to_string(_obj.x());
|
||||
str += etk::to_string(_obj.x());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.y());
|
||||
str += etk::to_string(_obj.y());
|
||||
str += ",";
|
||||
str += std::to_string(_obj.z());
|
||||
str += etk::to_string(_obj.z());
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
template<> std::u32string std::to_u32string<bvec3>(const bvec3& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
template<> std::u32string etk::to_u32string<bvec3>(const bvec3& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<vec3>(vec3& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<vec3>(vec3& _variableRet, const std::string& _value) {
|
||||
float floats[3];
|
||||
floats[0] = 0;
|
||||
floats[1] = 0;
|
||||
@ -187,33 +188,33 @@ template<> bool std::from_string<vec3>(vec3& _variableRet, const std::string& _v
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[0] = std::stof(tmpStr);
|
||||
floats[0] = etk::string_to_float(tmpStr);
|
||||
floats[1] = floats[0];
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[0] = std::stof(std::string(tmpStr, 0, posComa));
|
||||
floats[0] = etk::string_to_float(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
posComa = tmpStr.find(',');
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[1] = std::stof(tmpStr);
|
||||
floats[1] = etk::string_to_float(tmpStr);
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[1] = std::stof(std::string(tmpStr, 0, posComa));
|
||||
floats[1] = etk::string_to_float(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
floats[2] = std::stof(tmpStr);
|
||||
floats[2] = etk::string_to_float(tmpStr);
|
||||
}
|
||||
}
|
||||
_variableRet.setValue(floats[0], floats[1], floats[2]);
|
||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<vec3>(vec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<ivec3>(ivec3& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<ivec3>(ivec3& _variableRet, const std::string& _value) {
|
||||
int32_t floats[3];
|
||||
floats[0] = 0;
|
||||
floats[1] = 0;
|
||||
@ -230,33 +231,33 @@ template<> bool std::from_string<ivec3>(ivec3& _variableRet, const std::string&
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[0] = std::stoi(tmpStr);
|
||||
floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
floats[1] = floats[0];
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
posComa = tmpStr.find(',');
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[1] = std::stoi(tmpStr);
|
||||
floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[1] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
floats[1] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
floats[2] = std::stoi(tmpStr);
|
||||
floats[2] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
}
|
||||
_variableRet.setValue(floats[0], floats[1], floats[2]);
|
||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<ivec3>(ivec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<uivec3>(uivec3& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uivec3>(uivec3& _variableRet, const std::string& _value) {
|
||||
uint32_t floats[3];
|
||||
floats[0] = 0;
|
||||
floats[1] = 0;
|
||||
@ -273,33 +274,33 @@ template<> bool std::from_string<uivec3>(uivec3& _variableRet, const std::string
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[0] = std::stoi(tmpStr);
|
||||
floats[0] = etk::string_to_int32_t(tmpStr);
|
||||
floats[1] = floats[0];
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[0] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
floats[0] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
posComa = tmpStr.find(',');
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[1] = std::stoi(tmpStr);
|
||||
floats[1] = etk::string_to_int32_t(tmpStr);
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[1] = std::stoi(std::string(tmpStr, 0, posComa));
|
||||
floats[1] = etk::string_to_int32_t(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
floats[2] = std::stoi(tmpStr);
|
||||
floats[2] = etk::string_to_int32_t(tmpStr);
|
||||
}
|
||||
}
|
||||
_variableRet.setValue(floats[0], floats[1], floats[2]);
|
||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<uivec3>(uivec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
||||
|
||||
template<> bool std::from_string<bvec3>(bvec3& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<bvec3>(bvec3& _variableRet, const std::string& _value) {
|
||||
bool floats[3];
|
||||
floats[0] = false;
|
||||
floats[1] = false;
|
||||
@ -316,28 +317,28 @@ template<> bool std::from_string<bvec3>(bvec3& _variableRet, const std::string&
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[0] = std::stob(tmpStr);
|
||||
floats[0] = etk::string_to_bool(tmpStr);
|
||||
floats[1] = floats[0];
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[0] = std::stob(std::string(tmpStr, 0, posComa));
|
||||
floats[0] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
posComa = tmpStr.find(',');
|
||||
if (posComa == std::string::npos) {
|
||||
// no coma ...
|
||||
// in every case, we parse the first element :
|
||||
floats[1] = std::stob(tmpStr);
|
||||
floats[1] = etk::string_to_bool(tmpStr);
|
||||
floats[2] = floats[1];
|
||||
} else {
|
||||
floats[1] = std::stob(std::string(tmpStr, 0, posComa));
|
||||
floats[1] = etk::string_to_bool(std::string(tmpStr, 0, posComa));
|
||||
tmpStr.erase(0,posComa+1);
|
||||
floats[2] = std::stob(tmpStr);
|
||||
floats[2] = etk::string_to_bool(tmpStr);
|
||||
}
|
||||
}
|
||||
_variableRet.setValue(floats[0], floats[1], floats[2]);
|
||||
TK_VERBOSE("Parse : '" << _value << "' ==> " << _variableRet);
|
||||
return true;
|
||||
}
|
||||
template<> bool std::from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
template<> bool etk::from_string<bvec3>(bvec3& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
}
|
@ -275,7 +275,7 @@ std::string getApplicationPath() {
|
||||
return binaryName;
|
||||
}
|
||||
std::u32string getUApplicationPath() {
|
||||
return to_u32string(getApplicationPath());
|
||||
return etk::to_u32string(getApplicationPath());
|
||||
}
|
||||
|
||||
void etk::initDefaultFolder(const char* _applName) {
|
||||
@ -387,14 +387,14 @@ std::string etk::getUserHomeFolder() {
|
||||
return baseFolderHome;
|
||||
}
|
||||
std::u32string etk::getUUserHomeFolder() {
|
||||
return to_u32string(baseFolderHome);
|
||||
return etk::to_u32string(baseFolderHome);
|
||||
}
|
||||
|
||||
std::string etk::getUserRunFolder() {
|
||||
return baseRunPath;
|
||||
}
|
||||
std::u32string etk::getUUserRunFolder() {
|
||||
return to_u32string(baseRunPath);
|
||||
return etk::to_u32string(baseRunPath);
|
||||
}
|
||||
|
||||
|
||||
@ -522,7 +522,7 @@ void etk::FSNode::sortElementList(std::vector<etk::FSNode *>& _list) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (_list[jjj]!=NULL) {
|
||||
// TODO : Do something better : this methode is a litthe hard!!!
|
||||
if (std::toupper(tmpList[iii]->getNameFile()) > std::toupper(_list[jjj]->getNameFile())) {
|
||||
if (etk::toupper(tmpList[iii]->getNameFile()) > etk::toupper(_list[jjj]->getNameFile())) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
@ -701,7 +701,7 @@ void etk::FSNode::privateSetName(const std::string& _newName) {
|
||||
TK_DBG_MODE("6 : type : [" << m_typeNode << "] right :" << m_rights);
|
||||
}
|
||||
void etk::FSNode::privateSetName(const std::u32string& _newName) {
|
||||
privateSetName(std::to_string(_newName));
|
||||
privateSetName(etk::to_string(_newName));
|
||||
}
|
||||
|
||||
bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||
@ -722,7 +722,7 @@ bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded =
|
||||
return true;
|
||||
}
|
||||
bool directCheckFile(std::u32string _tmpFileNameDirect, bool _checkInAPKIfNeeded = false) {
|
||||
return directCheckFile(std::to_string(_tmpFileNameDirect));
|
||||
return directCheckFile(etk::to_string(_tmpFileNameDirect));
|
||||
}
|
||||
// Now we generate the real FS path:
|
||||
void etk::FSNode::generateFileSystemPath() {
|
||||
@ -926,14 +926,14 @@ std::string etk::FSNode::getNameFolder() const {
|
||||
return "";
|
||||
}
|
||||
std::u32string etk::FSNode::getUNameFolder() const {
|
||||
return to_u32string(getNameFolder());
|
||||
return etk::to_u32string(getNameFolder());
|
||||
}
|
||||
|
||||
std::string etk::FSNode::getFileSystemName() const {
|
||||
return m_systemFileName;
|
||||
}
|
||||
std::u32string etk::FSNode::getUFileSystemName() const {
|
||||
return to_u32string(getFileSystemName());
|
||||
return etk::to_u32string(getFileSystemName());
|
||||
}
|
||||
|
||||
std::string etk::FSNode::getName() const {
|
||||
@ -970,7 +970,7 @@ std::string etk::FSNode::getName() const {
|
||||
return output;
|
||||
}
|
||||
std::u32string etk::FSNode::getUName() const {
|
||||
return to_u32string(getName());
|
||||
return etk::to_u32string(getName());
|
||||
}
|
||||
|
||||
std::string etk::FSNode::getNameFile() const {
|
||||
@ -981,7 +981,7 @@ std::string etk::FSNode::getNameFile() const {
|
||||
return "";
|
||||
}
|
||||
std::u32string etk::FSNode::getUNameFile() const {
|
||||
return to_u32string(getNameFile());
|
||||
return etk::to_u32string(getNameFile());
|
||||
}
|
||||
|
||||
std::string etk::FSNode::getRelativeFolder() const {
|
||||
@ -1023,7 +1023,7 @@ std::string etk::FSNode::getRelativeFolder() const {
|
||||
return "";
|
||||
}
|
||||
std::u32string etk::FSNode::getURelativeFolder() const {
|
||||
return to_u32string(getRelativeFolder());
|
||||
return etk::to_u32string(getRelativeFolder());
|
||||
}
|
||||
|
||||
|
||||
@ -1053,7 +1053,7 @@ bool etk::FSNode::move(const std::string& _path) {
|
||||
}
|
||||
}
|
||||
bool etk::FSNode::move(const std::u32string& _path) {
|
||||
return move(std::to_string(_path));
|
||||
return move(etk::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNode::remove() {
|
||||
@ -1088,7 +1088,7 @@ std::string etk::FSNode::timeCreatedString() const {
|
||||
return tmpTime;
|
||||
}
|
||||
std::u32string etk::FSNode::timeUCreatedString() const {
|
||||
return to_u32string(timeCreatedString());
|
||||
return etk::to_u32string(timeCreatedString());
|
||||
}
|
||||
|
||||
uint64_t etk::FSNode::timeModified() const {
|
||||
@ -1104,7 +1104,7 @@ std::string etk::FSNode::timeModifiedString() const {
|
||||
return tmpTime;
|
||||
}
|
||||
std::u32string etk::FSNode::timeUModifiedString() const {
|
||||
return to_u32string(timeModifiedString());
|
||||
return etk::to_u32string(timeModifiedString());
|
||||
}
|
||||
|
||||
uint64_t etk::FSNode::timeAccessed() const {
|
||||
@ -1120,7 +1120,7 @@ std::string etk::FSNode::timeAccessedString() const {
|
||||
return tmpTime;
|
||||
}
|
||||
std::u32string etk::FSNode::timeUAccessedString() const {
|
||||
return to_u32string(timeAccessedString());
|
||||
return etk::to_u32string(timeAccessedString());
|
||||
}
|
||||
/*
|
||||
Operator :
|
||||
@ -1467,7 +1467,7 @@ std::string etk::FSNode::fileGetExtention() {
|
||||
return "";
|
||||
}
|
||||
std::u32string etk::FSNode::fileUGetExtention() {
|
||||
return to_u32string(fileGetExtention());
|
||||
return etk::to_u32string(fileGetExtention());
|
||||
}
|
||||
|
||||
uint64_t etk::FSNode::fileSize() {
|
||||
@ -1795,7 +1795,7 @@ void etk::theme::setName(const std::string& _refName, const std::string& _folder
|
||||
g_listTheme.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
||||
}
|
||||
void etk::theme::setName(const std::u32string& _refName, const std::u32string& _folderName) {
|
||||
setName(std::to_string(_refName), std::to_string(_folderName));
|
||||
setName(etk::to_string(_refName), etk::to_string(_folderName));
|
||||
}
|
||||
|
||||
std::string etk::theme::getName(const std::string& _refName) {
|
||||
@ -1806,7 +1806,7 @@ std::string etk::theme::getName(const std::string& _refName) {
|
||||
return _refName;
|
||||
}
|
||||
std::u32string etk::theme::getName(const std::u32string& _refName) {
|
||||
return to_u32string(getName(std::to_string(_refName)));
|
||||
return etk::to_u32string(getName(etk::to_string(_refName)));
|
||||
}
|
||||
|
||||
// get the list of all the theme folder availlable in the user Home/appl
|
||||
@ -1820,7 +1820,7 @@ std::vector<std::string> etk::theme::list() {
|
||||
std::vector<std::u32string> etk::theme::listU() {
|
||||
std::vector<std::u32string> keys;
|
||||
for (auto &it : g_listTheme) {
|
||||
keys.push_back(std::to_u32string(it.first));
|
||||
keys.push_back(etk::to_u32string(it.first));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
@ -1835,7 +1835,7 @@ void etk::theme::setNameDefault(const std::string& _refName, const std::string&
|
||||
g_listThemeDefault.insert(std::pair<std::string,std::string>(_refName, _folderName));
|
||||
}
|
||||
void etk::theme::setNameDefault(const std::u32string& _refName, const std::u32string& _folderName) {
|
||||
setNameDefault(std::to_string(_refName), std::to_string(_folderName));
|
||||
setNameDefault(etk::to_string(_refName), etk::to_string(_folderName));
|
||||
}
|
||||
std::string etk::theme::getNameDefault(const std::string& _refName) {
|
||||
auto it=g_listThemeDefault.find(_refName);
|
||||
@ -1845,7 +1845,7 @@ std::string etk::theme::getNameDefault(const std::string& _refName) {
|
||||
return "default";
|
||||
}
|
||||
std::u32string etk::theme::getNameDefault(const std::u32string& _refName) {
|
||||
return to_u32string(getNameDefault(std::to_string(_refName)));
|
||||
return etk::to_u32string(getNameDefault(etk::to_string(_refName)));
|
||||
}
|
||||
|
||||
|
||||
@ -1863,7 +1863,7 @@ bool etk::FSNodeRemove(const std::string& _path) {
|
||||
return tmpNode.remove();
|
||||
}
|
||||
bool etk::FSNodeRemove(const std::u32string& _path) {
|
||||
return FSNodeRemove(std::to_string(_path));
|
||||
return FSNodeRemove(etk::to_string(_path));
|
||||
}
|
||||
|
||||
int64_t etk::FSNodeGetCount(const std::string& _path) {
|
||||
@ -1874,7 +1874,7 @@ int64_t etk::FSNodeGetCount(const std::string& _path) {
|
||||
return tmpNode.folderCount();
|
||||
}
|
||||
int64_t etk::FSNodeGetCount(const std::u32string& _path) {
|
||||
return FSNodeGetCount(std::to_string(_path));
|
||||
return FSNodeGetCount(etk::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||
@ -1882,7 +1882,7 @@ bool etk::FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum e
|
||||
return false;
|
||||
}
|
||||
bool etk::FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type) {
|
||||
return FSNodeCreate(std::to_string(_path), _right, _type);
|
||||
return FSNodeCreate(etk::to_string(_path), _right, _type);
|
||||
}
|
||||
|
||||
bool etk::FSNodeExist(const std::string& _path) {
|
||||
@ -1890,7 +1890,7 @@ bool etk::FSNodeExist(const std::string& _path) {
|
||||
return tmpNode.exist();
|
||||
}
|
||||
bool etk::FSNodeExist(const std::u32string& _path) {
|
||||
return FSNodeExist(std::to_string(_path));
|
||||
return FSNodeExist(etk::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
||||
@ -1905,7 +1905,7 @@ bool etk::FSNodeMove(const std::string& _path1, const std::string& _path2) {
|
||||
return tmpNode.move(_path2);
|
||||
}
|
||||
bool etk::FSNodeMove(const std::u32string& _path1, const std::u32string& _path2) {
|
||||
return FSNodeMove(std::to_string(_path1), std::to_string(_path2));
|
||||
return FSNodeMove(etk::to_string(_path1), etk::to_string(_path2));
|
||||
}
|
||||
|
||||
etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
||||
@ -1913,7 +1913,7 @@ etk::FSNodeRight etk::FSNodeGetRight(const std::string& _path) {
|
||||
return tmpNode.getRight();
|
||||
}
|
||||
etk::FSNodeRight etk::FSNodeGetRight(const std::u32string& _path) {
|
||||
return FSNodeGetRight(std::to_string(_path));
|
||||
return FSNodeGetRight(etk::to_string(_path));
|
||||
}
|
||||
|
||||
enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
||||
@ -1921,7 +1921,7 @@ enum etk::typeNode etk::FSNodeGetType(const std::string& _path) {
|
||||
return tmpNode.getNodeType();
|
||||
}
|
||||
enum etk::typeNode etk::FSNodeGetType(const std::u32string& _path) {
|
||||
return FSNodeGetType(std::to_string(_path));
|
||||
return FSNodeGetType(etk::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
||||
@ -1929,7 +1929,7 @@ uint64_t etk::FSNodeGetTimeCreated(const std::string& _path) {
|
||||
return tmpNode.timeCreated();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeCreated(const std::u32string& _path) {
|
||||
return FSNodeGetTimeCreated(std::to_string(_path));
|
||||
return FSNodeGetTimeCreated(etk::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
||||
@ -1937,7 +1937,7 @@ uint64_t etk::FSNodeGetTimeModified(const std::string& _path) {
|
||||
return tmpNode.timeModified();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeModified(const std::u32string& _path) {
|
||||
return FSNodeGetTimeModified(std::to_string(_path));
|
||||
return FSNodeGetTimeModified(etk::to_string(_path));
|
||||
}
|
||||
|
||||
uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
||||
@ -1945,7 +1945,7 @@ uint64_t etk::FSNodeGetTimeAccessed(const std::string& _path) {
|
||||
return tmpNode.timeAccessed();
|
||||
}
|
||||
uint64_t etk::FSNodeGetTimeAccessed(const std::u32string& _path) {
|
||||
return FSNodeGetTimeAccessed(std::to_string(_path));
|
||||
return FSNodeGetTimeAccessed(etk::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeTouch(const std::string& _path) {
|
||||
@ -1953,7 +1953,7 @@ bool etk::FSNodeTouch(const std::string& _path) {
|
||||
return tmpNode.touch();
|
||||
}
|
||||
bool etk::FSNodeTouch(const std::u32string& _path) {
|
||||
return FSNodeTouch(std::to_string(_path));
|
||||
return FSNodeTouch(etk::to_string(_path));
|
||||
}
|
||||
|
||||
bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite) {
|
||||
@ -1975,7 +1975,7 @@ bool etk::FSNodeEcho(const std::string& _path, const std::string& _dataTowrite)
|
||||
return tmpNode.fileClose();
|
||||
}
|
||||
bool etk::FSNodeEcho(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||
return FSNodeEcho(std::to_string(_path), std::to_string(_dataTowrite));
|
||||
return FSNodeEcho(etk::to_string(_path), etk::to_string(_dataTowrite));
|
||||
}
|
||||
|
||||
bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrite) {
|
||||
@ -1997,15 +1997,15 @@ bool etk::FSNodeEchoAdd(const std::string& _path, const std::string& _dataTowrit
|
||||
return tmpNode.fileClose();
|
||||
}
|
||||
bool etk::FSNodeEchoAdd(const std::u32string& _path, const std::u32string& _dataTowrite) {
|
||||
return FSNodeEchoAdd(std::to_string(_path), std::to_string(_dataTowrite));
|
||||
return FSNodeEchoAdd(etk::to_string(_path), etk::to_string(_dataTowrite));
|
||||
}
|
||||
|
||||
void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
||||
// step 1 : Move the file to prevent writing error
|
||||
//Get the first oldest save :
|
||||
for (int32_t iii=_historyCount-1; iii>0 ; iii--) {
|
||||
if (true==etk::FSNodeExist(_path + "-" + std::to_string(iii)) ) {
|
||||
etk::FSNodeMove(_path + "-" + std::to_string(iii), _path + "-" + std::to_string(iii+1));
|
||||
if (true==etk::FSNodeExist(_path + "-" + etk::to_string(iii)) ) {
|
||||
etk::FSNodeMove(_path + "-" + etk::to_string(iii), _path + "-" + etk::to_string(iii+1));
|
||||
}
|
||||
}
|
||||
if (true==etk::FSNodeExist(_path) ) {
|
||||
@ -2013,7 +2013,7 @@ void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
||||
}
|
||||
}
|
||||
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
||||
return FSNodeHistory(std::to_string(_path), _historyCount);
|
||||
return FSNodeHistory(etk::to_string(_path), _historyCount);
|
||||
}
|
||||
|
||||
std::string etk::FSNodeReadAllData(const std::string& _path) {
|
||||
|
@ -176,7 +176,7 @@ void etk::FSNodeRight::setOtherRunable(bool _newStatus)
|
||||
}
|
||||
|
||||
std::u32string etk::FSNodeRight::getURight() const {
|
||||
return to_u32string(getRight());
|
||||
return etk::to_u32string(getRight());
|
||||
}
|
||||
|
||||
std::string etk::FSNodeRight::getRight() const {
|
||||
|
347
etk/stdTools.cpp
347
etk/stdTools.cpp
@ -12,40 +12,6 @@
|
||||
#undef __class__
|
||||
#define __class__ "u32char"
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const std::string& _obj) {
|
||||
_os << _obj.c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<std::string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const std::u32string& _obj) {
|
||||
_os << etk::to_string(_obj).c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
const char32_t u32char::Null('\0');
|
||||
const char32_t u32char::Return('\n');
|
||||
const char32_t u32char::CarrierReturn('\r');
|
||||
@ -275,10 +241,73 @@ template<> std::string etk::to_string<std::u32string>(const std::u32string& _inp
|
||||
return out;
|
||||
}
|
||||
|
||||
template<> std::u32string etk::to_u32string<std::string>(const std::string& _input) {
|
||||
return etk::to_u32string(_input.c_str());
|
||||
template<> std::string etk::to_string<std::string>(const std::string& _val) {
|
||||
return _val;
|
||||
}
|
||||
template<> std::u32string etk::to_u32string<char*>(const char*& _input) {
|
||||
template<> std::string etk::to_string<bool>(const bool& _val) {
|
||||
if (_val == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
template<> std::string etk::to_string<int8_t>(const int8_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int16_t>(const int16_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int32_t>(const int32_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int64_t>(const int64_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%ld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<uint8_t>(const uint8_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<uint16_t>(const uint16_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<uint32_t>(const uint32_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<uint64_t>(const uint64_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<float>(const float& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<double>(const double& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<long double>(const long double& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%Lf", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
|
||||
template<> std::u32string etk::to_u32string<char*>(char* const & _input) {
|
||||
if (_input == NULL) {
|
||||
return U"";
|
||||
}
|
||||
@ -330,42 +359,47 @@ template<> std::u32string etk::to_u32string<char*>(const char*& _input) {
|
||||
return out;
|
||||
}
|
||||
|
||||
template<> std::u32string etk::to_u32string<std::string>(const std::string& _input) {
|
||||
return etk::to_u32string(_input.c_str());
|
||||
}
|
||||
|
||||
template<> std::u32string etk::to_u32string<int8_t>(int8_t _val) {
|
||||
|
||||
|
||||
template<> std::u32string etk::to_u32string<int8_t>(const int8_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<int16_t>(int16_t _val) {
|
||||
template<> std::u32string etk::to_u32string<int16_t>(const int16_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<int32_t>(int32_t _val) {
|
||||
template<> std::u32string etk::to_u32string<int32_t>(const int32_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<int64_t>(int64_t _val) {
|
||||
template<> std::u32string etk::to_u32string<int64_t>(const int64_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<uint8_t>(uint8_t _val) {
|
||||
template<> std::u32string etk::to_u32string<uint8_t>(const uint8_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<uint16_t>(uint16_t _val) {
|
||||
template<> std::u32string etk::to_u32string<uint16_t>(const uint16_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<uint32_t>(uint32_t _val) {
|
||||
template<> std::u32string etk::to_u32string<uint32_t>(const uint32_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<uint64_t>(uint64_t _val) {
|
||||
template<> std::u32string etk::to_u32string<uint64_t>(const uint64_t& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<float>(float _val) {
|
||||
template<> std::u32string etk::to_u32string<float>(const float& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<double>(double _val) {
|
||||
template<> std::u32string etk::to_u32string<double>(const double& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
template<> std::u32string etk::to_u32string<long double>(long double _val) {
|
||||
template<> std::u32string etk::to_u32string<long double>(const long double& _val) {
|
||||
return etk::to_u32string(etk::to_string(_val));
|
||||
};
|
||||
|
||||
bool std::string_to_bool(const std::u32string& _str) {
|
||||
bool etk::string_to_bool(const std::u32string& _str) {
|
||||
if( true == compare_no_case(_str, U"true")
|
||||
|| true == compare_no_case(_str, U"enable")
|
||||
|| true == compare_no_case(_str, U"yes")
|
||||
@ -376,37 +410,37 @@ bool std::string_to_bool(const std::u32string& _str) {
|
||||
}
|
||||
|
||||
double etk::string_to_double(const std::u32string& _str) {
|
||||
return std::stod(etk::to_string(_str), _idx);
|
||||
return std::stod(etk::to_string(_str));
|
||||
}
|
||||
long double etk::string_to_long_double(const std::u32string& _str) {
|
||||
return std::stold(etk::to_string(_str), _idx);
|
||||
return std::stold(etk::to_string(_str));
|
||||
}
|
||||
float etk::string_to_float(const std::u32string& _str) {
|
||||
return std::stof(etk::to_string(_str), _idx);
|
||||
return std::stof(etk::to_string(_str));
|
||||
}
|
||||
int8_t etk::string_to_int8_t(const std::u32string& _str, int _base) {
|
||||
return std::stoi(etk::to_string(_str), _idx, _base);
|
||||
return std::stoi(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
int16_t etk::string_to_int16_t(const std::u32string& _str, int _base) {
|
||||
return std::stoi(etk::to_string(_str), _idx, _base);
|
||||
return std::stoi(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
int32_t etk::string_to_int32_t(const std::u32string& _str, int _base) {
|
||||
return std::stoi(etk::to_string(_str), _idx, _base);
|
||||
return std::stoi(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
int64_t etk::string_to_int64_t(const std::u32string& _str, int _base) {
|
||||
return std::stoll(etk::to_string(_str), _idx, _base);
|
||||
return std::stoll(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
uint8_t etk::string_to_uint8_t(const std::u32string& _str, int _base) {
|
||||
return std::stoul(etk::to_string(_str), _idx, _base);
|
||||
return std::stoul(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
uint16_t etk::string_to_uint16_t(const std::u32string& _str, int _base) {
|
||||
return std::stoul(etk::to_string(_str), _idx, _base);
|
||||
return std::stoul(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
uint32_t etk::string_to_uint32_t(const std::u32string& _str, int _base) {
|
||||
return std::stoul(etk::to_string(_str), _idx, _base);
|
||||
return std::stoul(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
uint64_t etk::string_to_uint64_t(const std::u32string& _str, int _base) {
|
||||
return std::stoull(etk::to_string(_str), _idx, _base);
|
||||
return std::stoull(etk::to_string(_str), 0, _base);
|
||||
}
|
||||
|
||||
bool etk::string_to_bool(const std::string& _str) {
|
||||
@ -419,68 +453,6 @@ bool etk::string_to_bool(const std::string& _str) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> std::string etk::to_string<bool>(const bool& _val) {
|
||||
if (_val == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
template<> std::string etk::to_string<int8_t>(const int8_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int16_t>(const int16_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int32_t>(const int32_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%d", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int64_t>(const int64_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%ld", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int8_t>(const int8_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int16_t>(const int16_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int32_t>(const int32_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%u", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<int64_t>(const int64_t& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lu", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<float>(const float& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<double>(const double& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%f", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
template<> std::string etk::to_string<long double>(const long double& _val) {
|
||||
char tmpVal[256];
|
||||
sprintf(tmpVal, "%lf", _val);
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
template<> std::u32string etk::to_u32string<bool>(const bool& _val) {
|
||||
if (_val == true) {
|
||||
return U"true";
|
||||
@ -493,7 +465,7 @@ bool etk::compare_no_case(const std::u32string& _obj, const std::u32string& _val
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -505,7 +477,7 @@ bool etk::compare_no_case(const std::string& _obj, const std::string& _val) {
|
||||
return false;
|
||||
}
|
||||
for(size_t iii=0; iii<_val.size(); ++iii) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -612,7 +584,7 @@ bool etk::end_with(const std::string& _obj, const std::string& _val, bool _caseS
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -639,7 +611,7 @@ bool etk::end_with(const std::u32string& _obj, const std::u32string& _val, bool
|
||||
for( int64_t iii=_val.size()-1, jjj=_obj.size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[jjj])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[jjj])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -666,7 +638,7 @@ bool etk::start_with(const std::string& _obj, const std::string& _val, bool _cas
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -693,7 +665,7 @@ bool etk::start_with(const std::u32string& _obj, const std::u32string& _val, boo
|
||||
for( size_t iii = 0;
|
||||
iii < _val.size();
|
||||
iii++) {
|
||||
if (tolower(_val[iii]) != tolower(_obj[iii])) {
|
||||
if (std::tolower(_val[iii]) != std::tolower(_obj[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -812,9 +784,15 @@ std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _v
|
||||
return list;
|
||||
}
|
||||
|
||||
long double etk::string_to_long_double(const std::string& _str) {
|
||||
long double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
double etk::string_to_double(const std::string& _str) {
|
||||
double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
sscanf(_str.c_str(), "%lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -840,7 +818,7 @@ int32_t etk::string_to_int32_t(const std::string& _str, int _base) {
|
||||
return ret;
|
||||
}
|
||||
int64_t etk::string_to_int64_t(const std::string& _str, int _base) {
|
||||
int ret = 0;
|
||||
int64_t ret = 0;
|
||||
sscanf(_str.c_str(), "%ld", &ret);
|
||||
return ret;
|
||||
}
|
||||
@ -860,22 +838,11 @@ uint32_t etk::string_to_uint32_t(const std::string& _str, int _base) {
|
||||
return ret;
|
||||
}
|
||||
uint64_t etk::string_to_uint64_t(const std::string& _str, int _base) {
|
||||
long long ret = 0;
|
||||
int64_t ret = 0;
|
||||
sscanf(_str.c_str(), "%ld", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long double etk::string_to_long_double(const std::string& _str) {
|
||||
long double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
double etk::string_to_double(const std::string& _str) {
|
||||
double ret = 0;
|
||||
sscanf(_str.c_str(), "%Lf", &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void etk::sort(std::vector<std::string *> &_list) {
|
||||
std::vector<std::string *> tmpList(_list);
|
||||
_list.clear();
|
||||
@ -908,111 +875,141 @@ void etk::sort(std::vector<std::u32string *> &_list) {
|
||||
}
|
||||
}
|
||||
|
||||
bool etk::from_string<float>(float& _variableRet, const std::string& _value) {
|
||||
_variableRet = stof(_value);
|
||||
template<> bool etk::from_string<std::string>(std::string& _variableRet, const std::string& _value) {
|
||||
_variableRet = _value;
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<float>(float& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = stof(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool etk::from_string<int8_t>(int8_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<int8_t>(int8_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_int8_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int16_t>(int16_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<int16_t>(int16_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_int16_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int32_t>(int32_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<int32_t>(int32_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_int32_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int64_t>(int64_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<int64_t>(int64_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_int64_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint8_t>(uint8_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uint8_t>(uint8_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_uint8_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint16_t>(uint16_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uint16_t>(uint16_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_uint16_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint32_t>(uint32_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uint32_t>(uint32_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_uint32_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint64_t>(uint64_t& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<uint64_t>(uint64_t& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_uint64_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<float>(float& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<float>(float& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_float(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<double>(double& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<double>(double& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_double(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<long double>(long double& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<long double>(long double& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_long_double(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<bool>(bool& _variableRet, const std::string& _value) {
|
||||
template<> bool etk::from_string<bool>(bool& _variableRet, const std::string& _value) {
|
||||
_variableRet = string_to_bool(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::from_string<int8_t>(int8_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<int8_t>(int8_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_int8_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int16_t>(int16_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<int16_t>(int16_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_int16_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int32_t>(int32_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<int32_t>(int32_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_int32_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<int64_t>(int64_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<int64_t>(int64_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_int64_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint8_t>(uint8_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<uint8_t>(uint8_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_uint8_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint16_t>(uint16_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<uint16_t>(uint16_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_uint16_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint32_t>(uint32_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<uint32_t>(uint32_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_uint32_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<uint64_t>(uint64_t& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<uint64_t>(uint64_t& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_uint64_t(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<float>(float& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<float>(float& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_float(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<double>(double& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<double>(double& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_double(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<long double>(long double& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<long double>(long double& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_long_double(_value);
|
||||
return true;
|
||||
}
|
||||
bool etk::from_string<bool>(bool& _variableRet, const std::u32string& _value) {
|
||||
template<> bool etk::from_string<bool>(bool& _variableRet, const std::u32string& _value) {
|
||||
_variableRet = string_to_bool(_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::ostream& std::operator <<(std::ostream& _os, const std::string& _obj) {
|
||||
_os << _obj.c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& std::operator <<(std::ostream& _os, const std::u32string& _obj) {
|
||||
_os << etk::to_string(_obj).c_str();
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
|
||||
_os << "{";
|
||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||
if (iii>0) {
|
||||
_os << " ~ ";
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
|
@ -60,16 +60,19 @@ namespace utf8 {
|
||||
char32_t convertChar32(const char* _input);
|
||||
};
|
||||
|
||||
namespace etk {
|
||||
namespace std {
|
||||
#ifdef __TARGET_OS__MacOs
|
||||
typedef std::basic_string<char32_t> u32string;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
namespace etk {
|
||||
// these declaration is to prevent some under template declaration of unknown type
|
||||
template <class TYPE> std::string to_string(const TYPE& _variable);
|
||||
template <class TYPE> std::u32string to_string(const TYPE& _variable);
|
||||
template <class TYPE> std::u32string to_u32string(const TYPE& _variable);
|
||||
|
||||
// these declaration is to prevent some under template declaration of unknown type
|
||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value);
|
||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value);
|
||||
|
||||
template<class TYPE, int size=0> std::string to_string_format(TYPE t, std::ios_base & (*f)(std::ios_base&)) {
|
||||
std::ostringstream oss;
|
||||
@ -87,45 +90,46 @@ namespace etk {
|
||||
} else {
|
||||
oss << std::setw(size) << std::setfill('0') << f << t;
|
||||
}
|
||||
return std::to_u32string(oss.str());
|
||||
return etk::to_u32string(oss.str());
|
||||
}
|
||||
|
||||
// these declaration is to prevent some under template declaration of unknown type
|
||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value);
|
||||
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value);
|
||||
|
||||
long double string_to_long_double(const std::string& _str);
|
||||
long double string_to_long_double(const std::u32string& _str);
|
||||
|
||||
double string_to_double(const std::string& _str);
|
||||
double string_to_dbouble(const std::u32string& _str);
|
||||
double string_to_double(const std::u32string& _str);
|
||||
|
||||
float string_to_float(const std::string& _str);
|
||||
float string_to_float(const std::u32string& _str);
|
||||
|
||||
int string_to_int32_t(const std::string& _str, int _base = 10);
|
||||
int string_to_i(const std::u32string& _str, int _base = 10);
|
||||
int8_t string_to_int8_t(const std::string& _str, int _base = 10);
|
||||
int8_t string_to_int8_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
long string_to_l(const std::string& _str, int _base = 10);
|
||||
//! @previous
|
||||
long string_to_l(const std::u32string& _str, int _base = 10);
|
||||
int16_t string_to_int16_t(const std::string& _str, int _base = 10);
|
||||
int16_t string_to_int16_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
long double string_to_ld(const std::string& _str);
|
||||
//! @previous
|
||||
long double string_to_ld(const std::u32string& _str);
|
||||
int32_t string_to_int32_t(const std::string& _str, int _base = 10);
|
||||
int32_t string_to_int32_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
long long string_to_ll(const std::string& _str, int _base = 10);
|
||||
//! @previous
|
||||
long long string_to_ll(const std::u32string& _str, int _base = 10);
|
||||
int64_t string_to_int64_t(const std::string& _str, int _base = 10);
|
||||
int64_t string_to_int64_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
unsigned long stoul(const std::string& _str, int _base = 10);
|
||||
//! @previous
|
||||
unsigned long stoul(const std::u32string& _str, int _base = 10);
|
||||
uint8_t string_to_uint8_t(const std::string& _str, int _base = 10);
|
||||
uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
unsigned long long stoull(const std::string& _str, int _base = 10);
|
||||
//! @previous
|
||||
unsigned long long stoull(const std::u32string& _str, int _base = 10);
|
||||
uint16_t string_to_uint16_t(const std::string& _str, int _base = 10);
|
||||
uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
uint32_t string_to_uint32_t(const std::string& _str, int _base = 10);
|
||||
uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
uint64_t string_to_uint64_t(const std::string& _str, int _base = 10);
|
||||
uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10);
|
||||
|
||||
bool string_to_bool(const std::string& _str);
|
||||
bool string_to_bool(const std::u32string& _str);
|
||||
|
||||
bool stob(const std::string& _str);
|
||||
//! @previous
|
||||
bool stob(const std::u32string& _str);
|
||||
std::string tolower(std::string _obj);
|
||||
//! @previous
|
||||
std::u32string tolower(std::u32string _obj);
|
||||
@ -168,7 +172,7 @@ namespace std {
|
||||
}
|
||||
};
|
||||
|
||||
namespace etk {
|
||||
namespace std {
|
||||
std::ostream& operator <<(std::ostream& _os, const std::string& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<std::string>& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const std::u32string& _obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user