[DEV] continue integration of etk::String
This commit is contained in:
parent
427a603121
commit
067bed60a5
@ -22,7 +22,7 @@ class ColorList {
|
|||||||
static int32_t getColorSize();
|
static int32_t getColorSize();
|
||||||
static const ColorList* getColorList();
|
static const ColorList* getColorList();
|
||||||
|
|
||||||
etk::Color<uint8_t, 4> etk::parseStringStartWithSharp(const std::string& _input) {
|
etk::Color<uint8_t, 4> etk::parseStringStartWithSharp(const etk::String& _input) {
|
||||||
TK_VERBOSE("parseStringStartWithSharp('" << _input << "'");
|
TK_VERBOSE("parseStringStartWithSharp('" << _input << "'");
|
||||||
size_t len = _input.size();
|
size_t len = _input.size();
|
||||||
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
||||||
@ -73,7 +73,7 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithSharp(const std::string& _input)
|
|||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<uint8_t, 4> etk::parseStringStartWithRGBGen(const std::string& _input) {
|
etk::Color<uint8_t, 4> etk::parseStringStartWithRGBGen(const etk::String& _input) {
|
||||||
TK_VERBOSE("parseStringStartWithRGB('" << _input << "'");
|
TK_VERBOSE("parseStringStartWithRGB('" << _input << "'");
|
||||||
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
||||||
int32_t red=0, green=0, blue=0, alpha=0;
|
int32_t red=0, green=0, blue=0, alpha=0;
|
||||||
@ -118,7 +118,7 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithRGBGen(const std::string& _input
|
|||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<double, 4> etk::parseStringStartWithRGB(const std::string& _input) {
|
etk::Color<double, 4> etk::parseStringStartWithRGB(const etk::String& _input) {
|
||||||
TK_VERBOSE("parseStringStartWithRGB('" << _input << "')");
|
TK_VERBOSE("parseStringStartWithRGB('" << _input << "')");
|
||||||
etk::Color<double, 4> outputValue(0,0,0,0);
|
etk::Color<double, 4> outputValue(0,0,0,0);
|
||||||
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
||||||
@ -155,7 +155,7 @@ etk::Color<double, 4> etk::parseStringStartWithRGB(const std::string& _input) {
|
|||||||
}
|
}
|
||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
etk::Color<uint32_t, 4> etk::parseStringStartWithRGBUnsigned32(const std::string& _input) {
|
etk::Color<uint32_t, 4> etk::parseStringStartWithRGBUnsigned32(const etk::String& _input) {
|
||||||
etk::Color<uint32_t, 4> outputValue(0,0,0,0);
|
etk::Color<uint32_t, 4> outputValue(0,0,0,0);
|
||||||
int32_t red=0, green=0, blue=0, alpha=0;
|
int32_t red=0, green=0, blue=0, alpha=0;
|
||||||
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
||||||
@ -192,7 +192,7 @@ etk::Color<uint32_t, 4> etk::parseStringStartWithRGBUnsigned32(const std::string
|
|||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<uint16_t, 4> etk::parseStringStartWithRGBUnsigned16(const std::string& _input) {
|
etk::Color<uint16_t, 4> etk::parseStringStartWithRGBUnsigned16(const etk::String& _input) {
|
||||||
etk::Color<uint16_t, 4> outputValue(0,0,0,0);
|
etk::Color<uint16_t, 4> outputValue(0,0,0,0);
|
||||||
int32_t red=0, green=0, blue=0, alpha=0;
|
int32_t red=0, green=0, blue=0, alpha=0;
|
||||||
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
||||||
@ -229,7 +229,7 @@ etk::Color<uint16_t, 4> etk::parseStringStartWithRGBUnsigned16(const std::string
|
|||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<uint8_t, 4> etk::parseStringStartWithRGBUnsigned8(const std::string& _input) {
|
etk::Color<uint8_t, 4> etk::parseStringStartWithRGBUnsigned8(const etk::String& _input) {
|
||||||
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
etk::Color<uint8_t, 4> outputValue(0,0,0,0);
|
||||||
int32_t red=0, green=0, blue=0, alpha=0;
|
int32_t red=0, green=0, blue=0, alpha=0;
|
||||||
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
double float_red=0, float_green=0, float_blue=0, float_alpha=0;
|
||||||
@ -266,7 +266,7 @@ etk::Color<uint8_t, 4> etk::parseStringStartWithRGBUnsigned8(const std::string&
|
|||||||
return outputValue;
|
return outputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<uint8_t, 4> etk::parseStringColorNamed(const std::string& _input) {
|
etk::Color<uint8_t, 4> etk::parseStringColorNamed(const etk::String& _input) {
|
||||||
// direct named color ...
|
// direct named color ...
|
||||||
for (int32_t iii=0; iii<getColorSize(); iii++) {
|
for (int32_t iii=0; iii<getColorSize(); iii++) {
|
||||||
if (etk::compare_no_case(getColorList()[iii].colorName, _input) == true) {
|
if (etk::compare_no_case(getColorList()[iii].colorName, _input) == true) {
|
||||||
|
@ -84,7 +84,7 @@ namespace etk {
|
|||||||
* @brief String extractor constructor.
|
* @brief String extractor constructor.
|
||||||
* @param[in] _input Color string to parse. it can be : "#rrggbb", "rgb", "rrggbbaa", "rgba", "yellow" ...
|
* @param[in] _input Color string to parse. it can be : "#rrggbb", "rgb", "rrggbbaa", "rgba", "yellow" ...
|
||||||
*/
|
*/
|
||||||
Color(const std::string& _input);
|
Color(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Assignment operator
|
* @brief Assignment operator
|
||||||
* @param[in] _input Color object to set in this class.
|
* @param[in] _input Color object to set in this class.
|
||||||
@ -211,7 +211,7 @@ namespace etk {
|
|||||||
* @brief Convert the color in an hexadecimal string ("0xFEDCBA98")
|
* @brief Convert the color in an hexadecimal string ("0xFEDCBA98")
|
||||||
* @return The formatted string
|
* @return The formatted string
|
||||||
*/
|
*/
|
||||||
std::string getHexString() const {
|
etk::String getHexString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "0x" << std::setw(8) << std::setfill('0') << std::hex << get();
|
os << "0x" << std::setw(8) << std::setfill('0') << std::hex << get();
|
||||||
return os.str();
|
return os.str();
|
||||||
@ -220,7 +220,7 @@ namespace etk {
|
|||||||
* @brief Convert the color in an generic string value ("#FEDCBA98")
|
* @brief Convert the color in an generic string value ("#FEDCBA98")
|
||||||
* @return The formatted string
|
* @return The formatted string
|
||||||
*/
|
*/
|
||||||
std::string getString() const {
|
etk::String getString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "#" << std::setw(8) << std::setfill('0') << std::hex << get();
|
os << "#" << std::setw(8) << std::setfill('0') << std::hex << get();
|
||||||
return os.str();
|
return os.str();
|
||||||
@ -402,43 +402,43 @@ namespace etk {
|
|||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint8_t, 4> parseStringStartWithSharp(const std::string& _input);
|
etk::Color<uint8_t, 4> parseStringStartWithSharp(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "rgb()" converted in unsigned 8 bits integer
|
* @brief Get a color value started with a "rgb()" converted in unsigned 8 bits integer
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint8_t, 4> parseStringStartWithRGBGen(const std::string& _input);
|
etk::Color<uint8_t, 4> parseStringStartWithRGBGen(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "rgb()" keep in double
|
* @brief Get a color value started with a "rgb()" keep in double
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<double, 4> parseStringStartWithRGB(const std::string& _input);
|
etk::Color<double, 4> parseStringStartWithRGB(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "rgb()" converted in unsigned 32 bits integer
|
* @brief Get a color value started with a "rgb()" converted in unsigned 32 bits integer
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint32_t, 4> parseStringStartWithRGBUnsigned32(const std::string& _input);
|
etk::Color<uint32_t, 4> parseStringStartWithRGBUnsigned32(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "rgb()" converted in unsigned 16 bits integer
|
* @brief Get a color value started with a "rgb()" converted in unsigned 16 bits integer
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint16_t, 4> parseStringStartWithRGBUnsigned16(const std::string& _input);
|
etk::Color<uint16_t, 4> parseStringStartWithRGBUnsigned16(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "rgb()" converted in unsigned 8 bits integer
|
* @brief Get a color value started with a "rgb()" converted in unsigned 8 bits integer
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint8_t, 4> parseStringStartWithRGBUnsigned8(const std::string& _input);
|
etk::Color<uint8_t, 4> parseStringStartWithRGBUnsigned8(const etk::String& _input);
|
||||||
/**
|
/**
|
||||||
* @brief Get a color value started with a "named" converted in unsigned 8 bits integer like red, green ...
|
* @brief Get a color value started with a "named" converted in unsigned 8 bits integer like red, green ...
|
||||||
* @param[in] _input String to parse
|
* @param[in] _input String to parse
|
||||||
* @return Value parsed
|
* @return Value parsed
|
||||||
*/
|
*/
|
||||||
etk::Color<uint8_t, 4> parseStringColorNamed(const std::string& _input);
|
etk::Color<uint8_t, 4> parseStringColorNamed(const etk::String& _input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Specify that the Get instance is specialized for unsigned 8 bits integer on RGBA template
|
* @brief Specify that the Get instance is specialized for unsigned 8 bits integer on RGBA template
|
||||||
@ -452,49 +452,49 @@ namespace etk {
|
|||||||
return tmp.get();
|
return tmp.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MY_TYPE, int MY_TYPE_SIZE> Color<MY_TYPE, MY_TYPE_SIZE>::Color(const std::string& _input) {
|
template<typename MY_TYPE, int MY_TYPE_SIZE> Color<MY_TYPE, MY_TYPE_SIZE>::Color(const etk::String& _input) {
|
||||||
//TK_VERBOSE("convert color string : '" << _input << "'");
|
//TK_VERBOSE("convert color string : '" << _input << "'");
|
||||||
const char* inputData = _input.c_str();
|
const char* inputData = _input.c_str();
|
||||||
size_t len = _input.size();
|
size_t len = _input.size();
|
||||||
if( len >=1
|
if( len >=1
|
||||||
&& inputData[0] == '#') {
|
&& inputData[0] == '#') {
|
||||||
Color<uint8_t, 4> value = etk::parseStringStartWithSharp(std::string(_input, 1));
|
Color<uint8_t, 4> value = etk::parseStringStartWithSharp(etk::String(_input, 1));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb(", false) == true) {
|
} else if(_input.startWith("rgb(", false) == true) {
|
||||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(std::string(_input, 4, _input.size()-5));
|
Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(etk::String(_input, 4, _input.size()-5));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba(", false) == true) {
|
} else if(_input.startWith("rgba(", false) == true) {
|
||||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(std::string(_input, 5, _input.size()-6));
|
Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(etk::String(_input, 5, _input.size()-6));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb[FLOAT](", false) == true) {
|
} else if(_input.startWith("rgb[FLOAT](", false) == true) {
|
||||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 11, _input.size()-12));
|
Color<double, 4> value = etk::parseStringStartWithRGB(etk::String(_input, 11, _input.size()-12));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba[FLOAT](", false) == true) {
|
} else if(_input.startWith("rgba[FLOAT](", false) == true) {
|
||||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 12, _input.size()-13));
|
Color<double, 4> value = etk::parseStringStartWithRGB(etk::String(_input, 12, _input.size()-13));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb[DOUBLE](", false) == true) {
|
} else if(_input.startWith("rgb[DOUBLE](", false) == true) {
|
||||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 12, _input.size()-13));
|
Color<double, 4> value = etk::parseStringStartWithRGB(etk::String(_input, 12, _input.size()-13));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba[DOUBLE](", false) == true) {
|
} else if(_input.startWith("rgba[DOUBLE](", false) == true) {
|
||||||
Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 13, _input.size()-14));
|
Color<double, 4> value = etk::parseStringStartWithRGB(etk::String(_input, 13, _input.size()-14));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb[U32](", false) == true) {
|
} else if(_input.startWith("rgb[U32](", false) == true) {
|
||||||
Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(std::string(_input, 9, _input.size()-10));
|
Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(etk::String(_input, 9, _input.size()-10));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba[U32](", false) == true) {
|
} else if(_input.startWith("rgba[U32](", false) == true) {
|
||||||
Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(std::string(_input, 10, _input.size()-11));
|
Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(etk::String(_input, 10, _input.size()-11));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb[U16](", false) == true) {
|
} else if(_input.startWith("rgb[U16](", false) == true) {
|
||||||
Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(std::string(_input, 9, _input.size()-10));
|
Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(etk::String(_input, 9, _input.size()-10));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba[U16](", false) == true) {
|
} else if(_input.startWith("rgba[U16](", false) == true) {
|
||||||
Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(std::string(_input, 10, _input.size()-11));
|
Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(etk::String(_input, 10, _input.size()-11));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgb[U8](", false) == true) {
|
} else if(_input.startWith("rgb[U8](", false) == true) {
|
||||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(std::string(_input, 8, _input.size()-9));
|
Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(etk::String(_input, 8, _input.size()-9));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else if(etk::start_with(_input, "rgba[U8](", false) == true) {
|
} else if(_input.startWith("rgba[U8](", false) == true) {
|
||||||
Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(std::string(_input, 9, _input.size()-10));
|
Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(etk::String(_input, 9, _input.size()-10));
|
||||||
*this = value;
|
*this = value;
|
||||||
} else {
|
} else {
|
||||||
Color<uint8_t, 4> value = etk::parseStringColorNamed(_input);
|
Color<uint8_t, 4> value = etk::parseStringColorNamed(_input);
|
||||||
|
@ -385,7 +385,7 @@ template<> template<> Color<uint16_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>& _val) {
|
template<> etk::String to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -398,14 +398,14 @@ template<> std::string to_string<Color<uint16_t, 1> >(const Color<uint16_t, 1>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint16_t, 1> >(Color<uint16_t, 1>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint16_t, 1> >(Color<uint16_t, 1>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint16_t, 1>(_value);
|
_variableRet = Color<uint16_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>& _val) {
|
template<> etk::String to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -418,14 +418,14 @@ template<> std::string to_string<Color<uint16_t, 2> >(const Color<uint16_t, 2>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint16_t, 2> >(Color<uint16_t, 2>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint16_t, 2> >(Color<uint16_t, 2>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint16_t, 2>(_value);
|
_variableRet = Color<uint16_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>& _val) {
|
template<> etk::String to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -438,14 +438,14 @@ template<> std::string to_string<Color<uint16_t, 3> >(const Color<uint16_t, 3>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint16_t, 3> >(Color<uint16_t, 3>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint16_t, 3> >(Color<uint16_t, 3>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint16_t, 3>(_value);
|
_variableRet = Color<uint16_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>& _val) {
|
template<> etk::String to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -458,7 +458,7 @@ template<> std::string to_string<Color<uint16_t, 4> >(const Color<uint16_t, 4>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint16_t, 4> >(Color<uint16_t, 4>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint16_t, 4> >(Color<uint16_t, 4>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint16_t, 4>(_value);
|
_variableRet = Color<uint16_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ template<> template<> Color<uint32_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>& _val) {
|
template<> etk::String to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -397,12 +397,12 @@ template<> std::string to_string<Color<uint32_t, 1> >(const Color<uint32_t, 1>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint32_t, 1> >(Color<uint32_t, 1>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint32_t, 1> >(Color<uint32_t, 1>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint32_t, 1>(_value);
|
_variableRet = Color<uint32_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>& _val) {
|
template<> etk::String to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -414,14 +414,14 @@ template<> std::string to_string<Color<uint32_t, 2> >(const Color<uint32_t, 2>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint32_t, 2> >(Color<uint32_t, 2>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint32_t, 2> >(Color<uint32_t, 2>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint32_t, 2>(_value);
|
_variableRet = Color<uint32_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>& _val) {
|
template<> etk::String to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -433,14 +433,14 @@ template<> std::string to_string<Color<uint32_t, 3> >(const Color<uint32_t, 3>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint32_t, 3> >(Color<uint32_t, 3>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint32_t, 3> >(Color<uint32_t, 3>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint32_t, 3>(_value);
|
_variableRet = Color<uint32_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>& _val) {
|
template<> etk::String to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -452,7 +452,7 @@ template<> std::string to_string<Color<uint32_t, 4> >(const Color<uint32_t, 4>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint32_t, 4> >(Color<uint32_t, 4>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint32_t, 4> >(Color<uint32_t, 4>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint32_t, 4>(_value);
|
_variableRet = Color<uint32_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ template<> template<> Color<uint8_t,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
|
|
||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _val) {
|
template<> etk::String to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -396,7 +396,7 @@ template<> std::string to_string<Color<uint8_t, 1> >(const Color<uint8_t, 1>& _v
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint8_t, 1> >(Color<uint8_t, 1>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint8_t, 1> >(Color<uint8_t, 1>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint8_t, 1>(_value);
|
_variableRet = Color<uint8_t, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -404,7 +404,7 @@ template<> bool from_string<Color<uint8_t, 1> >(Color<uint8_t, 1>& _variableRet,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _val) {
|
template<> etk::String to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -416,14 +416,14 @@ template<> std::string to_string<Color<uint8_t, 2> >(const Color<uint8_t, 2>& _v
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint8_t, 2> >(Color<uint8_t, 2>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint8_t, 2> >(Color<uint8_t, 2>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint8_t, 2>(_value);
|
_variableRet = Color<uint8_t, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _val) {
|
template<> etk::String to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -435,13 +435,13 @@ template<> std::string to_string<Color<uint8_t, 3> >(const Color<uint8_t, 3>& _v
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint8_t, 3> >(Color<uint8_t, 3>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint8_t, 3> >(Color<uint8_t, 3>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint8_t, 3>(_value);
|
_variableRet = Color<uint8_t, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _val) {
|
template<> etk::String to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -453,7 +453,7 @@ template<> std::string to_string<Color<uint8_t, 4> >(const Color<uint8_t, 4>& _v
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<uint8_t, 4> >(Color<uint8_t, 4>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<uint8_t, 4> >(Color<uint8_t, 4>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<uint8_t, 4>(_value);
|
_variableRet = Color<uint8_t, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ template<> template<> Color<double,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
// ===========================================================================================================
|
// ===========================================================================================================
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 1> >(const Color<double, 1>& _val) {
|
template<> etk::String to_string<Color<double, 1> >(const Color<double, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -397,7 +397,7 @@ template<> std::string to_string<Color<double, 1> >(const Color<double, 1>& _val
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<double, 1> >(Color<double, 1>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<double, 1> >(Color<double, 1>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<double, 1>(_value);
|
_variableRet = Color<double, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ template<> bool from_string<Color<double, 1> >(Color<double, 1>& _variableRet, c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 2> >(const Color<double, 2>& _val) {
|
template<> etk::String to_string<Color<double, 2> >(const Color<double, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -417,7 +417,7 @@ template<> std::string to_string<Color<double, 2> >(const Color<double, 2>& _val
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<double, 2> >(Color<double, 2>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<double, 2> >(Color<double, 2>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<double, 2>(_value);
|
_variableRet = Color<double, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -425,7 +425,7 @@ template<> bool from_string<Color<double, 2> >(Color<double, 2>& _variableRet, c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 3> >(const Color<double, 3>& _val) {
|
template<> etk::String to_string<Color<double, 3> >(const Color<double, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -437,14 +437,14 @@ template<> std::string to_string<Color<double, 3> >(const Color<double, 3>& _val
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<double, 3> >(Color<double, 3>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<double, 3> >(Color<double, 3>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<double, 3>(_value);
|
_variableRet = Color<double, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<double, 4> >(const Color<double, 4>& _val) {
|
template<> etk::String to_string<Color<double, 4> >(const Color<double, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -456,7 +456,7 @@ template<> std::string to_string<Color<double, 4> >(const Color<double, 4>& _val
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<double, 4> >(Color<double, 4>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<double, 4> >(Color<double, 4>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<double, 4>(_value);
|
_variableRet = Color<double, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ template<> template<> Color<float,4>::Color(const Color<double, 4>& _obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 1> >(const Color<float, 1>& _val) {
|
template<> etk::String to_string<Color<float, 1> >(const Color<float, 1>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -395,13 +395,13 @@ template<> std::string to_string<Color<float, 1> >(const Color<float, 1>& _val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<float, 1> >(Color<float, 1>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<float, 1> >(Color<float, 1>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<float, 1>(_value);
|
_variableRet = Color<float, 1>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 2> >(const Color<float, 2>& _val) {
|
template<> etk::String to_string<Color<float, 2> >(const Color<float, 2>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -413,13 +413,13 @@ template<> std::string to_string<Color<float, 2> >(const Color<float, 2>& _val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<float, 2> >(Color<float, 2>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<float, 2> >(Color<float, 2>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<float, 2>(_value);
|
_variableRet = Color<float, 2>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 3> >(const Color<float, 3>& _val) {
|
template<> etk::String to_string<Color<float, 3> >(const Color<float, 3>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -431,13 +431,13 @@ template<> std::string to_string<Color<float, 3> >(const Color<float, 3>& _val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<float, 3> >(Color<float, 3>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<float, 3> >(Color<float, 3>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<float, 3>(_value);
|
_variableRet = Color<float, 3>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> std::string to_string<Color<float, 4> >(const Color<float, 4>& _val) {
|
template<> etk::String to_string<Color<float, 4> >(const Color<float, 4>& _val) {
|
||||||
return _val.getString();
|
return _val.getString();
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
@ -449,7 +449,7 @@ template<> std::string to_string<Color<float, 4> >(const Color<float, 4>& _val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template<> bool from_string<Color<float, 4> >(Color<float, 4>& _variableRet, const std::string& _value) {
|
template<> bool from_string<Color<float, 4> >(Color<float, 4>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet = Color<float, 4>(_value);
|
_variableRet = Color<float, 4>(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
26
etk/Hash.hpp
26
etk/Hash.hpp
@ -16,14 +16,14 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
template<class MY_TYPE> class HashData {
|
template<class MY_TYPE> class HashData {
|
||||||
public:
|
public:
|
||||||
std::string m_key; //!< name of the current hash
|
etk::String m_key; //!< name of the current hash
|
||||||
MY_TYPE m_value; //!< data of the current Hash
|
MY_TYPE m_value; //!< data of the current Hash
|
||||||
/**
|
/**
|
||||||
* @brief Constructor of the data for hash table.
|
* @brief Constructor of the data for hash table.
|
||||||
* @param[in] _key name of the hash table.
|
* @param[in] _key name of the hash table.
|
||||||
* @param[in] _val Value of the hash element.
|
* @param[in] _val Value of the hash element.
|
||||||
*/
|
*/
|
||||||
HashData(const std::string& _key, const MY_TYPE& _val) :
|
HashData(const etk::String& _key, const MY_TYPE& _val) :
|
||||||
m_key(_key),
|
m_key(_key),
|
||||||
m_value(_val) {
|
m_value(_val) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
@ -95,7 +95,7 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the hash requested
|
* @param[in] _key Name of the hash requested
|
||||||
* @return Id of the element in the table or -1 of it does not existed
|
* @return Id of the element in the table or -1 of it does not existed
|
||||||
*/
|
*/
|
||||||
int64_t getId(const std::string& _key) const {
|
int64_t getId(const etk::String& _key) const {
|
||||||
for (size_t iii=0; iii<m_data.size(); iii++) {
|
for (size_t iii=0; iii<m_data.size(); iii++) {
|
||||||
if (m_data[iii] != nullptr) {
|
if (m_data[iii] != nullptr) {
|
||||||
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
|
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
|
||||||
@ -112,7 +112,7 @@ namespace etk {
|
|||||||
* @param[in] _name Name of the hash requested
|
* @param[in] _name Name of the hash requested
|
||||||
* @return true if the element exist
|
* @return true if the element exist
|
||||||
*/
|
*/
|
||||||
bool exist(const std::string& _name) const {
|
bool exist(const etk::String& _name) const {
|
||||||
int64_t elementId = getId(_name);
|
int64_t elementId = getId(_name);
|
||||||
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
|
//TK_INFO(" Exist ? '" << _name << "' id=" << elementId );
|
||||||
if (elementId<0) {
|
if (elementId<0) {
|
||||||
@ -127,7 +127,7 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the hash requested
|
* @param[in] _key Name of the hash requested
|
||||||
* @return Reference on the Element
|
* @return Reference on the Element
|
||||||
*/
|
*/
|
||||||
MY_TYPE& get(const std::string& _key) const {
|
MY_TYPE& get(const etk::String& _key) const {
|
||||||
static MY_TYPE g_error;
|
static MY_TYPE g_error;
|
||||||
int64_t elementId = getId(_key);
|
int64_t elementId = getId(_key);
|
||||||
if (elementId<0) {
|
if (elementId<0) {
|
||||||
@ -141,7 +141,7 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the hash requested
|
* @param[in] _key Name of the hash requested
|
||||||
* @return An reference on the copy of selected element
|
* @return An reference on the copy of selected element
|
||||||
*/
|
*/
|
||||||
MY_TYPE& operator[] (const std::string& _key) {
|
MY_TYPE& operator[] (const etk::String& _key) {
|
||||||
return get(_key);
|
return get(_key);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -149,7 +149,7 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the hash requested
|
* @param[in] _key Name of the hash requested
|
||||||
* @return An reference on the copy of selected element
|
* @return An reference on the copy of selected element
|
||||||
*/
|
*/
|
||||||
const MY_TYPE& operator[] (const std::string& _key) const {
|
const MY_TYPE& operator[] (const etk::String& _key) const {
|
||||||
return get(_key);
|
return get(_key);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -158,7 +158,7 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the value to set in the hash table.
|
* @param[in] _key Name of the value to set in the hash table.
|
||||||
* @param[in] _value Value to set in the hash table.
|
* @param[in] _value Value to set in the hash table.
|
||||||
*/
|
*/
|
||||||
void add(const std::string& _key, const MY_TYPE& _value) {
|
void add(const etk::String& _key, const MY_TYPE& _value) {
|
||||||
int64_t elementId = getId(_key);
|
int64_t elementId = getId(_key);
|
||||||
if (elementId <0) {
|
if (elementId <0) {
|
||||||
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
|
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
|
||||||
@ -177,14 +177,14 @@ namespace etk {
|
|||||||
* @param[in] _key Name of the value to set in the hash table.
|
* @param[in] _key Name of the value to set in the hash table.
|
||||||
* @param[in] _value Value to set in the hash table.
|
* @param[in] _value Value to set in the hash table.
|
||||||
*/
|
*/
|
||||||
void set(const std::string& _key, const MY_TYPE& _value) {
|
void set(const etk::String& _key, const MY_TYPE& _value) {
|
||||||
add(_key, _value);
|
add(_key, _value);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Remove an element in the hash table.
|
* @brief Remove an element in the hash table.
|
||||||
* @param[in] _key Name of the element to remove.
|
* @param[in] _key Name of the element to remove.
|
||||||
*/
|
*/
|
||||||
void remove(const std::string& _key) {
|
void remove(const etk::String& _key) {
|
||||||
int64_t elementId = getId(_key);
|
int64_t elementId = getId(_key);
|
||||||
if (elementId <0) {
|
if (elementId <0) {
|
||||||
//nothing to do ==> not existed
|
//nothing to do ==> not existed
|
||||||
@ -224,7 +224,7 @@ namespace etk {
|
|||||||
* @param[in] _pos Position of the element in the hash table.
|
* @param[in] _pos Position of the element in the hash table.
|
||||||
* @return name of the element (key).
|
* @return name of the element (key).
|
||||||
*/
|
*/
|
||||||
const std::string& getKey(size_t _pos) const {
|
const etk::String& getKey(size_t _pos) const {
|
||||||
// NOTE :Do not change log level, this generate error only in debug mode
|
// NOTE :Do not change log level, this generate error only in debug mode
|
||||||
#if DEBUG_LEVEL > 2
|
#if DEBUG_LEVEL > 2
|
||||||
if(_pos>m_data.size()){
|
if(_pos>m_data.size()){
|
||||||
@ -237,8 +237,8 @@ namespace etk {
|
|||||||
* @brief Get all the element name (keys).
|
* @brief Get all the element name (keys).
|
||||||
* @return a vector of all name (key).
|
* @return a vector of all name (key).
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> getKeys() const {
|
std::vector<etk::String> getKeys() const {
|
||||||
std::vector<std::string> keys;
|
std::vector<etk::String> keys;
|
||||||
for (auto &it : m_data) {
|
for (auto &it : m_data) {
|
||||||
if (it != nullptr) {
|
if (it != nullptr) {
|
||||||
keys.push_back(it->m_key);
|
keys.push_back(it->m_key);
|
||||||
|
@ -79,36 +79,36 @@ std::ostream& etk::regex::operator <<(std::ostream& _os, const etk::regex::FindP
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string etk::regex::createString(const std::vector<char32_t>& _data, int64_t _start, int64_t _stop) {
|
etk::String etk::regex::createString(const std::vector<char32_t>& _data, int64_t _start, int64_t _stop) {
|
||||||
std::string output(ETK_BASH_COLOR_NORMAL);
|
etk::String output(ETK_BASH_COLOR_NORMAL);
|
||||||
for (int64_t iii=_start; iii<(int64_t)_data.size() && iii<_stop ; iii++) {
|
for (int64_t iii=_start; iii<(int64_t)_data.size() && iii<_stop ; iii++) {
|
||||||
switch(_data[iii]) {
|
switch(_data[iii]) {
|
||||||
case regexOpcodePTheseIn: output += std::string(ETK_BASH_COLOR_RED) + (char*)"(" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodePTheseIn: output += etk::String(ETK_BASH_COLOR_RED) + (char*)"(" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodePTheseOut: output += std::string(ETK_BASH_COLOR_RED) + (char*)")" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodePTheseOut: output += etk::String(ETK_BASH_COLOR_RED) + (char*)")" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeBracketIn: output += std::string(ETK_BASH_COLOR_YELLOW) + (char*)"[" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeBracketIn: output += etk::String(ETK_BASH_COLOR_YELLOW) + (char*)"[" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeBracketOut: output += std::string(ETK_BASH_COLOR_YELLOW) + (char*)"]" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeBracketOut: output += etk::String(ETK_BASH_COLOR_YELLOW) + (char*)"]" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeTo: output += std::string(ETK_BASH_COLOR_YELLOW) + (char*)"-" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeTo: output += etk::String(ETK_BASH_COLOR_YELLOW) + (char*)"-" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeBraceIn: output += std::string(ETK_BASH_COLOR_GREEN) + (char*)"{" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeBraceIn: output += etk::String(ETK_BASH_COLOR_GREEN) + (char*)"{" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeBraceOut: output += std::string(ETK_BASH_COLOR_GREEN) + (char*)"}" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeBraceOut: output += etk::String(ETK_BASH_COLOR_GREEN) + (char*)"}" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeStar: output += std::string(ETK_BASH_COLOR_BLUE) + (char*)"*" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeStar: output += etk::String(ETK_BASH_COLOR_BLUE) + (char*)"*" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeDot: output += std::string(ETK_BASH_COLOR_BLUE) + (char*)"." + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeDot: output += etk::String(ETK_BASH_COLOR_BLUE) + (char*)"." + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeQuestion: output += std::string(ETK_BASH_COLOR_BLUE) + (char*)"?" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeQuestion: output += etk::String(ETK_BASH_COLOR_BLUE) + (char*)"?" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodePlus: output += std::string(ETK_BASH_COLOR_BLUE) + (char*)"+" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodePlus: output += etk::String(ETK_BASH_COLOR_BLUE) + (char*)"+" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodePipe: output += std::string(ETK_BASH_COLOR_BLUE) + (char*)"|" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodePipe: output += etk::String(ETK_BASH_COLOR_BLUE) + (char*)"|" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeNoChar: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"@" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeNoChar: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"@" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeStartOfLine: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"^" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeStartOfLine: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"^" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeEndOfLine: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"$" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeEndOfLine: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"$" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeDigit: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\d" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeDigit: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\d" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeDigitNot: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\D" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeDigitNot: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\D" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeLetter: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\l" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeLetter: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\l" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeLetterNot: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\L" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeLetterNot: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\L" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeSpace: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\s" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeSpace: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\s" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeSpaceNot: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\S" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeSpaceNot: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\S" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeWord: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\w" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeWord: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\w" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeWordNot: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\W" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeWordNot: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\W" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexOpcodeEOF: output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\e" + ETK_BASH_COLOR_NORMAL; break;
|
case regexOpcodeEOF: output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\e" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case '\n': output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\n" + ETK_BASH_COLOR_NORMAL; break;
|
case '\n': output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\n" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
case '\t': output += std::string(ETK_BASH_COLOR_MAGENTA) + (char*)"\\t" + ETK_BASH_COLOR_NORMAL; break;
|
case '\t': output += etk::String(ETK_BASH_COLOR_MAGENTA) + (char*)"\\t" + ETK_BASH_COLOR_NORMAL; break;
|
||||||
default:
|
default:
|
||||||
char plop[10];
|
char plop[10];
|
||||||
int8_t nb = u32char::convertUtf8(_data[iii], plop);
|
int8_t nb = u32char::convertUtf8(_data[iii], plop);
|
||||||
@ -240,7 +240,7 @@ int64_t etk::regex::getLenOfBracket(const std::vector<char32_t>& _data, int64_t
|
|||||||
|| _data[pos] == regexOpcodeTo) {
|
|| _data[pos] == regexOpcodeTo) {
|
||||||
// nothing to do ... it is permitted
|
// nothing to do ... it is permitted
|
||||||
} else if(_data[pos] > 0xFF ) {
|
} else if(_data[pos] > 0xFF ) {
|
||||||
std::string displayElement;
|
etk::String displayElement;
|
||||||
if (_data[pos] == regexOpcodeStartOfLine) {
|
if (_data[pos] == regexOpcodeStartOfLine) {
|
||||||
displayElement = "^";
|
displayElement = "^";
|
||||||
} else if (_data[pos] == regexOpcodeDigitNot) {
|
} else if (_data[pos] == regexOpcodeDigitNot) {
|
||||||
@ -400,8 +400,8 @@ allIsSet:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string etk::regex::autoStr(const std::string& _data) {
|
etk::String etk::regex::autoStr(const etk::String& _data) {
|
||||||
std::string out;
|
etk::String out;
|
||||||
for (auto &it : _data) {
|
for (auto &it : _data) {
|
||||||
if (it == '\n') {
|
if (it == '\n') {
|
||||||
out += "\\n";
|
out += "\\n";
|
||||||
@ -423,8 +423,8 @@ std::string etk::regex::autoStr(const std::string& _data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string etk::regex::autoStr(char _data) {
|
etk::String etk::regex::autoStr(char _data) {
|
||||||
std::string out;
|
etk::String out;
|
||||||
if (_data == '\n') {
|
if (_data == '\n') {
|
||||||
out += "\\n";
|
out += "\\n";
|
||||||
} else if (_data == '\t') {
|
} else if (_data == '\t') {
|
||||||
@ -443,8 +443,8 @@ std::string etk::regex::autoStr(char _data) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string etk::regex::strTick(int32_t _pos) {
|
etk::String etk::regex::strTick(int32_t _pos) {
|
||||||
std::string out;
|
etk::String out;
|
||||||
for (int32_t iii=0; iii<_pos; ++iii) {
|
for (int32_t iii=0; iii<_pos; ++iii) {
|
||||||
out += " ";
|
out += " ";
|
||||||
}
|
}
|
||||||
@ -455,20 +455,20 @@ std::string etk::regex::strTick(int32_t _pos) {
|
|||||||
|
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> std::string to_string<etk::RegEx<std::string>>(const etk::RegEx<std::string>& _val) {
|
template<> etk::String to_string<etk::RegEx<etk::String>>(const etk::RegEx<etk::String>& _val) {
|
||||||
return _val.getRegEx();
|
return _val.getRegEx();
|
||||||
}
|
}
|
||||||
template<> std::string to_string<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
|
template<> etk::String to_string<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
|
||||||
return _val.getRegEx();
|
return _val.getRegEx();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<etk::RegEx<std::string>>(const etk::RegEx<std::string>& _val) {
|
template<> std::u32string to_u32string<etk::RegEx<etk::String>>(const etk::RegEx<etk::String>& _val) {
|
||||||
return _val.getURegEx();
|
return _val.getURegEx();
|
||||||
}
|
}
|
||||||
template<> std::u32string to_u32string<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
|
template<> std::u32string to_u32string<etk::RegEx<std::u32string>>(const etk::RegEx<std::u32string>& _val) {
|
||||||
return _val.getURegEx();
|
return _val.getURegEx();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> bool from_string<etk::RegEx<std::string>>(etk::RegEx<std::string>& _variableRet, const std::u32string& _value) {
|
template<> bool from_string<etk::RegEx<etk::String>>(etk::RegEx<etk::String>& _variableRet, const std::u32string& _value) {
|
||||||
_variableRet.compile(_value);
|
_variableRet.compile(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -476,11 +476,11 @@ namespace etk {
|
|||||||
_variableRet.compile(_value);
|
_variableRet.compile(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<etk::RegEx<std::string>>(etk::RegEx<std::string>& _variableRet, const std::string& _value) {
|
template<> bool from_string<etk::RegEx<etk::String>>(etk::RegEx<etk::String>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet.compile(_value);
|
_variableRet.compile(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<> bool from_string<etk::RegEx<std::u32string>>(etk::RegEx<std::u32string>& _variableRet, const std::string& _value) {
|
template<> bool from_string<etk::RegEx<std::u32string>>(etk::RegEx<std::u32string>& _variableRet, const etk::String& _value) {
|
||||||
_variableRet.compile(_value);
|
_variableRet.compile(_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ extern const struct conversionTable constConversionTable[];
|
|||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
extern const int64_t constConversionTableSize;
|
extern const int64_t constConversionTableSize;
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
std::string createString(const std::vector<char32_t>& _data, int64_t _start=0, int64_t _stop=0x7FFFFFFF);
|
etk::String createString(const std::vector<char32_t>& _data, int64_t _start=0, int64_t _stop=0x7FFFFFFF);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
char * levelSpace(uint32_t _level);
|
char * levelSpace(uint32_t _level);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
@ -168,9 +168,9 @@ int64_t getLenOfNormal(const std::vector<char32_t>& _data, int64_t _startPos);
|
|||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
bool parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _max);
|
bool parseBrace(const std::vector<char32_t>& _data, uint32_t& _min, uint32_t& _max);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
std::string autoStr(const std::string& _data);
|
etk::String autoStr(const etk::String& _data);
|
||||||
std::string autoStr(char _data);
|
etk::String autoStr(char _data);
|
||||||
std::string strTick(int32_t _pos);
|
etk::String strTick(int32_t _pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Node Elements for every-one
|
* @brief Node Elements for every-one
|
||||||
@ -251,7 +251,7 @@ class FindProperty {
|
|||||||
}
|
}
|
||||||
template<class CLASS_TYPE>
|
template<class CLASS_TYPE>
|
||||||
static void display(const FindProperty& _element, const CLASS_TYPE& _data, int32_t _level = 0) {
|
static void display(const FindProperty& _element, const CLASS_TYPE& _data, int32_t _level = 0) {
|
||||||
std::string tmp;
|
etk::String tmp;
|
||||||
for (int32_t iii=_element.m_positionStart; iii<_element.m_positionStop; ++iii) {
|
for (int32_t iii=_element.m_positionStart; iii<_element.m_positionStop; ++iii) {
|
||||||
tmp += _data[iii];
|
tmp += _data[iii];
|
||||||
}
|
}
|
||||||
@ -996,7 +996,7 @@ template<class CLASS_TYPE> class NodePTheseElement : public Node<CLASS_TYPE> {
|
|||||||
return _data.size();
|
return _data.size();
|
||||||
};
|
};
|
||||||
virtual void parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, FindProperty& _property) {
|
virtual void parse(const CLASS_TYPE& _data, int64_t _currentPos, int64_t _lenMax, FindProperty& _property) {
|
||||||
//TK_REG_DEBUG_2("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) data to parse : '" << autoStr(std::string(_data, _currentPos, _lenMax-_currentPos)) << "'");
|
//TK_REG_DEBUG_2("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) data to parse : '" << autoStr(etk::String(_data, _currentPos, _lenMax-_currentPos)) << "'");
|
||||||
//TK_REG_DEBUG_2("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) m_data='" << autoStr(Node<CLASS_TYPE>::m_data) << "'");
|
//TK_REG_DEBUG_2("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) m_data='" << autoStr(Node<CLASS_TYPE>::m_data) << "'");
|
||||||
TK_REG_DEBUG("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) " << _property);
|
TK_REG_DEBUG("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element) " << _property);
|
||||||
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " work on: " << createString(Node<CLASS_TYPE>::m_regExData));
|
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " work on: " << createString(Node<CLASS_TYPE>::m_regExData));
|
||||||
@ -1033,7 +1033,7 @@ template<class CLASS_TYPE> class NodePTheseElement : public Node<CLASS_TYPE> {
|
|||||||
prop.setPositionStart(tmpCurrentPos);
|
prop.setPositionStart(tmpCurrentPos);
|
||||||
}
|
}
|
||||||
while (iii < m_subNode.size()) {
|
while (iii < m_subNode.size()) {
|
||||||
//TK_REG_DEBUG_2(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element=" << iii << "/" << m_subNode.size() << ") data='" << autoStr(std::string(_data, tmpCurrentPos, _lenMax-tmpCurrentPos)) << "'");
|
//TK_REG_DEBUG_2(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element=" << iii << "/" << m_subNode.size() << ") data='" << autoStr(etk::String(_data, tmpCurrentPos, _lenMax-tmpCurrentPos)) << "'");
|
||||||
m_subNode[iii]->parse(_data, tmpCurrentPos, _lenMax, prop);
|
m_subNode[iii]->parse(_data, tmpCurrentPos, _lenMax, prop);
|
||||||
if (prop.getStatus() == parseStatusNone) {
|
if (prop.getStatus() == parseStatusNone) {
|
||||||
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element=" << iii << "/" << m_subNode.size() << ") ===None=== : " << prop);
|
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (element=" << iii << "/" << m_subNode.size() << ") ===None=== : " << prop);
|
||||||
@ -1177,7 +1177,7 @@ template<class CLASS_TYPE> class NodePThese : public Node<CLASS_TYPE> {
|
|||||||
TK_REG_DEBUG("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) {" << Node<CLASS_TYPE>::m_multipleMin << "," << Node<CLASS_TYPE>::m_multipleMax << "}");
|
TK_REG_DEBUG("Parse " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) {" << Node<CLASS_TYPE>::m_multipleMin << "," << Node<CLASS_TYPE>::m_multipleMax << "}");
|
||||||
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " work on: " << createString(Node<CLASS_TYPE>::m_regExData));
|
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " work on: " << createString(Node<CLASS_TYPE>::m_regExData));
|
||||||
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " pos=" << _currentPos << " ==> " << _lenMax);
|
TK_REG_DEBUG(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " pos=" << _currentPos << " ==> " << _lenMax);
|
||||||
TK_REG_DEBUG_2(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) data='" << autoStr(std::string(_data, _currentPos, _lenMax-_currentPos)) << "'");
|
TK_REG_DEBUG_2(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) data='" << autoStr(etk::String(_data, _currentPos, _lenMax-_currentPos)) << "'");
|
||||||
TK_REG_DEBUG_3(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) input property=" << _property);
|
TK_REG_DEBUG_3(" " << levelSpace(Node<CLASS_TYPE>::m_nodeLevel) << " (...) input property=" << _property);
|
||||||
if (m_subNode.size() == 0) {
|
if (m_subNode.size() == 0) {
|
||||||
_property.setStatus(parseStatusNone);
|
_property.setStatus(parseStatusNone);
|
||||||
@ -1335,7 +1335,7 @@ template<class CLASS_TYPE> class NodePThese : public Node<CLASS_TYPE> {
|
|||||||
* @brief get the string represented the regex (colored)
|
* @brief get the string represented the regex (colored)
|
||||||
* @return Regex string
|
* @return Regex string
|
||||||
*/
|
*/
|
||||||
std::string getColoredRegEx() {
|
etk::String getColoredRegEx() {
|
||||||
return createString(Node<CLASS_TYPE>::m_regExData);
|
return createString(Node<CLASS_TYPE>::m_regExData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1405,7 +1405,7 @@ template<class CLASS_TYPE> class RegEx {
|
|||||||
/**
|
/**
|
||||||
* @previous
|
* @previous
|
||||||
*/
|
*/
|
||||||
RegEx(const std::string &_expression) :
|
RegEx(const etk::String &_expression) :
|
||||||
m_expressionRequested(U""),
|
m_expressionRequested(U""),
|
||||||
m_isOk(false),
|
m_isOk(false),
|
||||||
m_notBeginWithChar(false),
|
m_notBeginWithChar(false),
|
||||||
@ -1436,7 +1436,7 @@ template<class CLASS_TYPE> class RegEx {
|
|||||||
* @param[in] _expression the new expression to search
|
* @param[in] _expression the new expression to search
|
||||||
*/
|
*/
|
||||||
// TODO : Add an error ...
|
// TODO : Add an error ...
|
||||||
void compile(const std::string &_expression) {
|
void compile(const etk::String &_expression) {
|
||||||
if (_expression.size() != 0) {
|
if (_expression.size() != 0) {
|
||||||
TK_REG_DEBUG("normal string parse : '" << _expression << "'");
|
TK_REG_DEBUG("normal string parse : '" << _expression << "'");
|
||||||
compile(etk::to_u32string(_expression));
|
compile(etk::to_u32string(_expression));
|
||||||
@ -1580,7 +1580,7 @@ template<class CLASS_TYPE> class RegEx {
|
|||||||
* @brief Get the regular expression string
|
* @brief Get the regular expression string
|
||||||
* @return the string representing the RegEx
|
* @return the string representing the RegEx
|
||||||
*/
|
*/
|
||||||
std::string getRegEx() const {
|
etk::String getRegEx() const {
|
||||||
return etk::to_string(m_expressionRequested);
|
return etk::to_string(m_expressionRequested);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -1659,7 +1659,7 @@ template<class CLASS_TYPE> class RegEx {
|
|||||||
if ( prop.getStatus() == regex::parseStatusFull
|
if ( prop.getStatus() == regex::parseStatusFull
|
||||||
|| prop.getStatus() == regex::parseStatusPartial ) {
|
|| prop.getStatus() == regex::parseStatusPartial ) {
|
||||||
findLen = prop.getFindLen();
|
findLen = prop.getFindLen();
|
||||||
TK_REG_DEBUG_3("main search find : " << findLen << " elements data=" << std::string(_SearchIn, prop.getPositionStart(), prop.getFindLen()));
|
TK_REG_DEBUG_3("main search find : " << findLen << " elements data=" << etk::String(_SearchIn, prop.getPositionStart(), prop.getFindLen()));
|
||||||
// Check end :
|
// Check end :
|
||||||
if (m_notEndWithChar == true) {
|
if (m_notEndWithChar == true) {
|
||||||
TK_REG_DEBUG("Check end is not a char: '" << (char)_SearchIn[iii+findLen] << "'");
|
TK_REG_DEBUG("Check end is not a char: '" << (char)_SearchIn[iii+findLen] << "'");
|
||||||
@ -1805,7 +1805,7 @@ template<class CLASS_TYPE> class RegEx {
|
|||||||
* @brief Get decorated regular expression. This generate a [class[ewol::compositing::Text]] decoration text. Note that can be use in [class[ewol::widget::Label]].
|
* @brief Get decorated regular expression. This generate a [class[ewol::compositing::Text]] decoration text. Note that can be use in [class[ewol::widget::Label]].
|
||||||
* @return The decorated string
|
* @return The decorated string
|
||||||
*/
|
*/
|
||||||
std::string getRegExDecorated() {
|
etk::String getRegExDecorated() {
|
||||||
return m_expressionRootNode.getColoredRegEx();
|
return m_expressionRootNode.getColoredRegEx();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
235
etk/String.cpp
235
etk/String.cpp
@ -187,48 +187,209 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::String etk::toString(int _val) {
|
etk::String etk::toString(bool _val) {
|
||||||
char tmpVal[256];
|
if (_val == true) {
|
||||||
sprintf(tmpVal, "%d", _val);
|
return "true";
|
||||||
return tmpVal;
|
|
||||||
}
|
}
|
||||||
etk::String etk::toString(long _val) {
|
return "false";
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%ld", _val);
|
etk::String etk::toString(int _val) {
|
||||||
return tmpVal;
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%d", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(long _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%ld", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(long long _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%lld", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(unsigned _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%u", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(unsigned long _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%lu", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(unsigned long long _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%llu", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(float _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%f", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(double _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%f", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
etk::String etk::toString(long double _val) {
|
||||||
|
char tmpVal[256];
|
||||||
|
sprintf(tmpVal, "%Lf", _val);
|
||||||
|
return tmpVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t etk::String::find(char _value, size_t _pos) const {
|
||||||
|
for (size_t iii=_pos; iii<m_data.size(); ++iii) {
|
||||||
|
if (_value == m_data[iii]) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
etk::String etk::toString(long long _val) {
|
return etk::String::npos;
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%lld", _val);
|
|
||||||
return tmpVal;
|
size_t etk::String::find(const etk::String& _value, size_t _pos) const {
|
||||||
|
for (size_t iii=_pos; iii<m_data.size(); ++iii) {
|
||||||
|
bool check = true;
|
||||||
|
for (size_t jjj=0; jjj<_value.size(); ++jjj) {
|
||||||
|
if (iii+jjj >= m_data.size()) {
|
||||||
|
return etk::String::npos;
|
||||||
|
}
|
||||||
|
if (_value[jjj] != m_data[iii+jjj]) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (check == true) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
etk::String etk::toString(unsigned _val) {
|
return etk::String::npos;
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%u", _val);
|
|
||||||
return tmpVal;
|
size_t etk::String::rfind(char _value, size_t _pos) const {
|
||||||
|
if (_pos >= m_data.size()) {
|
||||||
|
_pos = m_data.size()-1;
|
||||||
}
|
}
|
||||||
etk::String etk::toString(unsigned long _val) {
|
for (int64_t iii=_pos; iii>=0; --iii) {
|
||||||
char tmpVal[256];
|
if (_value == m_data[iii]) {
|
||||||
sprintf(tmpVal, "%lu", _val);
|
return iii;
|
||||||
return tmpVal;
|
}
|
||||||
}
|
}
|
||||||
etk::String etk::toString(unsigned long long _val) {
|
return etk::String::npos;
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%llu", _val);
|
|
||||||
return tmpVal;
|
size_t etk::String::rfind(const etk::String& _value, size_t _pos) const {
|
||||||
|
if (_pos >= m_data.size()) {
|
||||||
|
_pos = m_data.size()-1;
|
||||||
}
|
}
|
||||||
etk::String etk::toString(float _val) {
|
for (int64_t iii=_pos; iii>=0; --iii) {
|
||||||
char tmpVal[256];
|
bool check = true;
|
||||||
sprintf(tmpVal, "%f", _val);
|
for (size_t jjj=0; jjj<_value.size(); ++jjj) {
|
||||||
return tmpVal;
|
if (iii+jjj >= m_data.size()) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (_value[jjj] != m_data[iii+jjj]) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (check == true) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
etk::String etk::toString(double _val) {
|
return etk::String::npos;
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%f", _val);
|
|
||||||
return tmpVal;
|
etk::String& etk::replace(size_t _pos, size_t _len, char _replace) {
|
||||||
|
erase(_pos, _len);
|
||||||
|
insert(_pos, _replace);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::String& etk::replace(size_t _pos, size_t _len, const etk::String& _replace) {
|
||||||
|
erase(_pos, _len);
|
||||||
|
insert(_pos, _replace);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::String& etk::replace(char _val, char _replace) {
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = find(_val, pos)) != etk::String::npos) {
|
||||||
|
replace(pos, _val.size(), _replace);
|
||||||
|
pos += _replace.size();
|
||||||
}
|
}
|
||||||
etk::String etk::toString(long double _val) {
|
return *this;
|
||||||
char tmpVal[256];
|
}
|
||||||
sprintf(tmpVal, "%Lf", _val);
|
|
||||||
return tmpVal;
|
etk::String& etk::String::replace(const etk::String& _val, const etk::String& _replace) {
|
||||||
}
|
size_t pos = 0;
|
||||||
|
while ((pos = find(_val, pos)) != etk::String::npos) {
|
||||||
|
replace(pos, _val.size(), _replace);
|
||||||
|
pos += _replace.size();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::String etk::String::getLine(int32_t _pos) const {
|
||||||
|
// search back : '\n'
|
||||||
|
size_t startPos = rfind('\n', _pos);
|
||||||
|
if ((int64_t)startPos == (int64_t)_pos) {
|
||||||
|
startPos = 0;
|
||||||
|
} else {
|
||||||
|
startPos++;
|
||||||
|
}
|
||||||
|
// search forward : '\n'
|
||||||
|
size_t stopPos = _pos;
|
||||||
|
if (m_data[_pos] != '\n') {
|
||||||
|
stopPos = find('\n', _pos);
|
||||||
|
if ((int64_t)stopPos == _pos) {
|
||||||
|
stopPos = size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startPos == etk::String::npos) {
|
||||||
|
startPos = 0;
|
||||||
|
} else if (startPos >= size() ) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (stopPos == etk::String::npos) {
|
||||||
|
return "";
|
||||||
|
} else if (stopPos >= size() ) {
|
||||||
|
stopPos = size();
|
||||||
|
}
|
||||||
|
return etk::String(*this, startPos, stopPos - startPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
etk::Vector<etk::String> etk::String::split(char _val) const {
|
||||||
|
etk::Vector<etk::String> list;
|
||||||
|
size_t lastStartPos = 0;
|
||||||
|
for(size_t iii=0; iii<size(); iii++) {
|
||||||
|
if (m_data[iii] == _val) {
|
||||||
|
list.push_back(etk::String(*this, lastStartPos, iii - lastStartPos));
|
||||||
|
lastStartPos = iii+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lastStartPos < size()) {
|
||||||
|
list.push_back(etk::String(*this, lastStartPos));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Vector<etk::String> etk::String::split(etk::String _val) const {
|
||||||
|
etk::Vector<etk::String> list;
|
||||||
|
size_t lastStartPos = 0;
|
||||||
|
for(size_t iii=0; iii<size()-_val.size(); iii++) {
|
||||||
|
if (etk::String(begin()+iii, begin()+iii+_val.size()) ==_val) {
|
||||||
|
list.push_back(etk::String(*this, lastStartPos, iii - lastStartPos));
|
||||||
|
lastStartPos = iii+_val.size();
|
||||||
|
iii += _val.size()-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lastStartPos < size()) {
|
||||||
|
list.push_back(etk::String(*this, lastStartPos));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -512,6 +512,14 @@ namespace etk {
|
|||||||
void insert(size_t _pos, const char _item) {
|
void insert(size_t _pos, const char _item) {
|
||||||
insert(_pos, &_item, 1);
|
insert(_pos, &_item, 1);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief Insert one element in the String at a specific position
|
||||||
|
* @param[in] _pos Position to add the elements.
|
||||||
|
* @param[in] _item Element to add.
|
||||||
|
*/
|
||||||
|
void insert(size_t _pos, const etk:::String& _value) {
|
||||||
|
insert(_pos, &_value[0], _value.size());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Remove N element
|
* @brief Remove N element
|
||||||
* @param[in] _pos Position to remove the data
|
* @param[in] _pos Position to remove the data
|
||||||
@ -657,6 +665,24 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
size_t find(char _value, size_t _pos) const;
|
||||||
|
size_t find(const etk::String& _value, size_t _pos) const;
|
||||||
|
size_t rfind(char _value, size_t _pos) const;
|
||||||
|
size_t rfind(const etk::String& _value, size_t _pos) const;
|
||||||
|
etk::String& replace(size_t _pos, size_t _len, char _replace);
|
||||||
|
etk::String& replace(size_t _pos, size_t _len, const etk::String& _replace);
|
||||||
|
etk::String& replace(char _val, char _replace);
|
||||||
|
etk::String& replace(const etk::String& _val, const etk::String& _replace);
|
||||||
|
etk::String getLine(int32_t _pos) const;
|
||||||
|
etk::String toLower() const;
|
||||||
|
etk::String& lower();
|
||||||
|
etk::String toUpper() const;
|
||||||
|
etk::String& upper();
|
||||||
|
bool compare(const etk::String& _val, bool _caseSensitive = true) const;
|
||||||
|
bool endWith(const etk::String& _val, bool _caseSensitive = true) const;
|
||||||
|
bool startWith(const etk::String& _val, bool _caseSensitive = true) const;
|
||||||
|
etk::Vector<etk::String> split(char _val) const;
|
||||||
|
etk::Vector<etk::String> split(etk::String _val) const;
|
||||||
/**
|
/**
|
||||||
* @brief Template that permit to convert string in everythings you want
|
* @brief Template that permit to convert string in everythings you want
|
||||||
* @param[in] ETK_STRING_TYPE Template type of the convertion output
|
* @param[in] ETK_STRING_TYPE Template type of the convertion output
|
||||||
@ -718,8 +744,7 @@ namespace etk {
|
|||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
std::ostream& operator <<(std::ostream& _os, const etk::String& _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::String& _obj);
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* @brief Template to declare conversion from string to anything
|
* @brief Template to declare conversion from string to anything
|
||||||
* @param[out] _variableRet Output value
|
* @param[out] _variableRet Output value
|
||||||
* @param[in] _value input property
|
* @param[in] _value input property
|
||||||
@ -728,15 +753,5 @@ namespace etk {
|
|||||||
template <class TYPE>
|
template <class TYPE>
|
||||||
bool from_string(TYPE& _variableRet, const etk::String& _value);
|
bool from_string(TYPE& _variableRet, const etk::String& _value);
|
||||||
|
|
||||||
etk::String tolower(etk::String _obj);
|
|
||||||
etk::String toupper(etk::String _obj);
|
|
||||||
bool compare_no_case(const etk::String& _obj, const etk::String& _val);
|
|
||||||
bool end_with(const etk::String& _obj, const etk::String& _val, bool _caseSensitive = true);
|
|
||||||
bool start_with(const etk::String& _obj, const etk::String& _val, bool _caseSensitive = true);
|
|
||||||
etk::String replace(const etk::String& _obj, char _val, char _replace);
|
|
||||||
etk::String replace(const etk::String& _obj, const etk::String& _val, const etk::String& _replace);
|
|
||||||
etk::String extract_line(const etk::String& _obj, int32_t _pos);
|
|
||||||
etk::Vector<etk::String> split(const etk::String& _input, char _val);
|
|
||||||
etk::Vector<etk::String> split(const etk::String& _input, etk::String _val);
|
|
||||||
void sort(etk::Vector<etk::String *>& _list);
|
void sort(etk::Vector<etk::String *>& _list);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ void etk::init(int _argc, const char** _argv) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||||
std::string data = _argv[iii];
|
etk::String data = _argv[iii];
|
||||||
if ( data == "-h"
|
if ( data == "-h"
|
||||||
|| data == "--help") {
|
|| data == "--help") {
|
||||||
TK_PRINT("etk - help : ");
|
TK_PRINT("etk - help : ");
|
||||||
@ -70,6 +70,6 @@ void etk::init(int _argc, const char** _argv) {
|
|||||||
TK_INFO("ETK system init (END)");
|
TK_INFO("ETK system init (END)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string etk::getApplicationName() {
|
etk::String etk::getApplicationName() {
|
||||||
return etk::FSNodeGetApplicationName();
|
return etk::FSNodeGetApplicationName();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ namespace etk {
|
|||||||
* @brief Get application name.
|
* @brief Get application name.
|
||||||
* @return The application name
|
* @return The application name
|
||||||
*/
|
*/
|
||||||
std::string getApplicationName();
|
etk::String getApplicationName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,52 +733,6 @@ bool etk::start_with(const std::string& _obj, const std::string& _val, bool _cas
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string etk::replace(const std::string& _obj, char _val, char _replace) {
|
|
||||||
std::string copy(_obj);
|
|
||||||
std::replace(copy.begin(), copy.end(), _val, _replace);
|
|
||||||
return copy;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! @not_in_doc
|
|
||||||
std::string etk::replace(const std::string& _obj, const std::string& _val, const std::string& _replace) {
|
|
||||||
std::string copy(_obj);
|
|
||||||
size_t pos = 0;
|
|
||||||
while ((pos = copy.find(_val, pos)) != std::string::npos) {
|
|
||||||
copy.replace(pos, _val.length(), _replace);
|
|
||||||
pos += _replace.length();
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string etk::extract_line(const std::string& _obj, int32_t _pos) {
|
|
||||||
// search back : '\n'
|
|
||||||
size_t startPos = _obj.rfind('\n', _pos);
|
|
||||||
if ((int64_t)startPos == (int64_t)_pos) {
|
|
||||||
startPos = 0;
|
|
||||||
} else {
|
|
||||||
startPos++;
|
|
||||||
}
|
|
||||||
// search forward : '\n'
|
|
||||||
size_t stopPos = _pos;
|
|
||||||
if (_obj[_pos] != '\n') {
|
|
||||||
stopPos = _obj.find('\n', _pos);
|
|
||||||
if ((int64_t)stopPos == _pos) {
|
|
||||||
stopPos = _obj.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (startPos == std::string::npos) {
|
|
||||||
startPos = 0;
|
|
||||||
} else if (startPos >= _obj.size() ) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (stopPos == std::string::npos) {
|
|
||||||
return "";
|
|
||||||
} else if (stopPos >= _obj.size() ) {
|
|
||||||
stopPos = _obj.size();
|
|
||||||
}
|
|
||||||
return std::string(_obj, startPos, stopPos - startPos);
|
|
||||||
}
|
|
||||||
#if __CPP_VERSION__ >= 2011
|
#if __CPP_VERSION__ >= 2011
|
||||||
std::u32string etk::extract_line(const std::u32string& _obj, int32_t _pos) {
|
std::u32string etk::extract_line(const std::u32string& _obj, int32_t _pos) {
|
||||||
// search back : '\n'
|
// search back : '\n'
|
||||||
@ -810,21 +764,6 @@ std::string etk::extract_line(const std::string& _obj, int32_t _pos) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> etk::split(const std::string& _input, char _val) {
|
|
||||||
std::vector<std::string> list;
|
|
||||||
size_t lastStartPos = 0;
|
|
||||||
for(size_t iii=0; iii<_input.size(); iii++) {
|
|
||||||
if (_input[iii]==_val) {
|
|
||||||
list.push_back(std::string(_input, lastStartPos, iii - lastStartPos));
|
|
||||||
lastStartPos = iii+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastStartPos<_input.size()) {
|
|
||||||
list.push_back(std::string(_input, lastStartPos));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __CPP_VERSION__ >= 2011
|
#if __CPP_VERSION__ >= 2011
|
||||||
std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _val) {
|
std::vector<std::u32string> etk::split(const std::u32string& _input, char32_t _val) {
|
||||||
std::vector<std::u32string> list;
|
std::vector<std::u32string> list;
|
||||||
@ -842,21 +781,6 @@ std::vector<std::string> etk::split(const std::string& _input, char _val) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> etk::split(const std::string& _input, std::string _val) {
|
|
||||||
std::vector<std::string> list;
|
|
||||||
size_t lastStartPos = 0;
|
|
||||||
for(size_t iii=0; iii<_input.size()-_val.size(); iii++) {
|
|
||||||
if (std::string(_input.begin()+iii, _input.begin()+iii+_val.size()) ==_val) {
|
|
||||||
list.push_back(std::string(_input, lastStartPos, iii - lastStartPos));
|
|
||||||
lastStartPos = iii+_val.size();
|
|
||||||
iii += _val.size()-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastStartPos<_input.size()) {
|
|
||||||
list.push_back(std::string(_input, lastStartPos));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if __CPP_VERSION__ >= 2011
|
#if __CPP_VERSION__ >= 2011
|
||||||
|
Loading…
Reference in New Issue
Block a user