diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-09-23 21:16:25 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-09-23 21:16:25 +0200 |
| commit | 5ae43acf945c6574cebccb6c5d1b3b5427deed70 (patch) | |
| tree | bbc1472c997dfeba7ab721aae937424ebc0b7674 /src/string.cc | |
| parent | 5a02d3808184d4d2714c7ab4a608a7b698624b35 (diff) | |
Add prefix_match function and use it instead of adhoc code
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc index dcfc1037..870cdf9e 100644 --- a/src/string.cc +++ b/src/string.cc @@ -83,4 +83,15 @@ void option_from_string(const String& str, Regex& re) } } +bool prefix_match(const String& str, const String& prefix) +{ + auto it = str.begin(); + for (auto& c : prefix) + { + if (it ==str.end() or *it++ != c) + return false; + } + return true; +} + } |
