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

Function removeLeadingCharacter

src/utils/string.cpp:965–979  ·  view source on GitHub ↗

* @brief Removes @c n @c leading characters from the given string @c s and * returns the result. * * @param s String from which leading characters are tp be removed. * @param leading Leading character to remove. * @param n Max number of characters to remove. If not set, remove as much * as possible. */

Source from the content-addressed store, hash-verified

963* as possible.
964*/
965std::string removeLeadingCharacter(const std::string &s, char leading, std::size_t n) {
966 if (n == 0) {
967 return s;
968 }
969
970 std::string ret(s);
971 std::size_t counter = 0;
972 while (ret[0] == leading) {
973 ret.erase(0, 1);
974 if (n == ++counter) {
975 return ret;
976 }
977 }
978 return ret;
979}
980
981/**
982 * @return @c True if character @a c is a control character, @c false otherwise.

Callers 4

getPairFunctionFreeMethod · 0.85
presentErrorsMethod · 0.85
TEST_FFunction · 0.85

Calls 1

eraseMethod · 0.45

Tested by 1

TEST_FFunction · 0.68