[DEV] add random generator of string
This commit is contained in:
parent
0bad189b50
commit
cb948b5014
11
etk/tool.cpp
11
etk/tool.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user