Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/click/string.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class String { public:
String substring(int pos, int len) const;
inline String substring(int pos) const;
String trim_space() const;
String trim_space_left() const;

inline bool equals(const String &x) const;
inline bool equals(const char *s, int len) const;
Expand Down
10 changes: 10 additions & 0 deletions lib/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,16 @@ String::trim_space() const
return String();
}

/** @brief Return a substring with spaces trimmed from the start. */
String
String::trim_space_left() const
{
for (int i = 0 ; i <= _r.length - 1; i++)
if (!isspace((unsigned char) _r.data[i]))
return substring(i);
return String();
}

/** @brief Return a hex-quoted version of the string.

For example, the string "Abcd" would convert to "\<41626364>". */
Expand Down