[DEV] add random generator of string

This commit is contained in:
Edouard DUPIN 2018-09-05 22:28:13 +02:00
parent 0bad189b50
commit cb948b5014
2 changed files with 17 additions and 0 deletions

View File

@ -30,3 +30,14 @@ void etk::random::reset() {
void etk::random::resetSeed(int32_t _val) {
srand(_val);
}
etk::String etk::random::generateString(uint_t _size) {
static etk::String value = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn1234567890_";
etk::String out;
for (uint_t iii=0; iii< _size; ++iii) {
out += value[etk::random::irand(0,value.size()-1)];
}
return out;
}

View File

@ -48,6 +48,12 @@ namespace etk {
++_left;
}
}
/**
* @brief Generate a random string with the specify size.
* @param[in] _size number of char.
* @return the generated string.
*/
etk::String generateString(uint_t _size);
}
/**
* @brief Some useful tools