MCPcopy Create free account
hub / github.com/comaps/comaps / RandomString

Function RandomString

libs/platform/platform.cpp:22–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace
21{
22std::string RandomString(size_t length)
23{
24 /// @todo Used for temp file name, so lower-upper case is strange here, no?
25 static std::string_view constexpr kCharset =
26 "0123456789"
27 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
28 "abcdefghijklmnopqrstuvwxyz";
29
30 base::UniformRandom<size_t> rand(0, kCharset.size() - 1);
31 std::string str(length, 0);
32 std::generate_n(str.begin(), length, [&rand]() { return kCharset[rand()]; });
33 return str;
34}
35
36inline bool IsSpecialDirName(std::string const & dirName)
37{

Callers 1

TmpPathForFileMethod · 0.85

Calls 2

sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected