Skip to content

Commit ea9be93

Browse files
jamesyonandsommers
authored andcommitted
string: added repeat() method and redefined spaces() method to use it
Signed-off-by: James Yonan <[email protected]>
1 parent d9a9ad3 commit ea9be93

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

openvpn/common/string.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,22 @@ namespace openvpn {
412412
return ret;
413413
}
414414

415-
// generate a string with spaces
416-
inline std::string spaces(int n)
415+
// generate a string with n instances of char c
416+
inline std::string repeat(const char c, int n)
417417
{
418418
std::string ret;
419419
ret.reserve(n);
420420
while (n-- > 0)
421-
ret += ' ';
421+
ret += c;
422422
return ret;
423423
}
424424

425+
// generate a string with spaces
426+
inline std::string spaces(int n)
427+
{
428+
return repeat(' ', n);
429+
}
430+
425431
// indent a multiline string
426432
inline std::string indent(const std::string& str, const int first, const int remaining)
427433
{

0 commit comments

Comments
 (0)