MCPcopy Create free account
hub / github.com/avast/retdec / isNiceAsciiWideString

Function isNiceAsciiWideString

src/utils/string.cpp:1034–1043  ·  view source on GitHub ↗

* @brief Does the provided wide string consist only from ASCII characters and is nice? * Nice string have ration of printable characters and escape sequences in the * string is at least @p minRatio. Empty string is never nice. * @param str Wide string to check. * @param minRatio Minimum ratio of printable characters. * @return @c True if the string seems nice, @c false otherwise

Source from the content-addressed store, hash-verified

1032 * @return @c True if the string seems nice, @c false otherwise.
1033 */
1034bool isNiceAsciiWideString(const std::vector<unsigned long long> &str, double minRatio) {
1035 assert(0.0 <= minRatio && minRatio <= 1.0);
1036
1037 auto s = str;
1038 if (!s.empty() && s.back() == 0)
1039 s.pop_back();
1040
1041 auto niceCnt = std::count_if(s.begin(), s.end(), isNiceAsciiWideCharacter);
1042 return !s.empty() && (niceCnt) >= (s.size() * minRatio);
1043}
1044
1045/**
1046* @brief Returns an indentation string containing the specified number of

Callers 1

TEST_FFunction · 0.85

Calls 5

emptyMethod · 0.45
backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68