[Process] Process Execution Refactor (#2632)

* Swap execute output method

* Create "Process" class and move random string to Strings

* test

* Tweaks
This commit is contained in:
Chris Miles
2022-12-11 13:08:55 -06:00
committed by GitHub
parent 70719852d6
commit f5126222c2
8 changed files with 73 additions and 83 deletions
+15
View File
@@ -738,3 +738,18 @@ bool Strings::ToBool(std::string bool_string)
return false;
}
// returns a random string of specified length
std::string Strings::Random(size_t length)
{
auto randchar = []() -> char {
const char charset[] = "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
const size_t max_index = (sizeof(charset) - 1);
return charset[static_cast<size_t>(std::rand()) % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;
}