diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-26 23:50:23 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-26 23:50:23 +0200 |
commit | a8256910d40a0eee85bf539a3f120c9d92485f3f (patch) | |
tree | 83fd119fe43257ca131620656b94a698b23c4329 /include-priv/trygvis/string_utils.h | |
parent | 128e53d220d97225803d61d86f8e43439563181d (diff) | |
download | kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.gz kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.bz2 kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.xz kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.zip |
o Working version with support for Arduino parts.
Diffstat (limited to 'include-priv/trygvis/string_utils.h')
-rw-r--r-- | include-priv/trygvis/string_utils.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include-priv/trygvis/string_utils.h b/include-priv/trygvis/string_utils.h new file mode 100644 index 0000000..9902a3f --- /dev/null +++ b/include-priv/trygvis/string_utils.h @@ -0,0 +1,23 @@ +#pragma once + +#include <string> + +namespace trygvis { +namespace string_utils { + +/** + * Check if a starts with b. + */ +static bool startsWith(const std::string &a, const std::string &b) { + return b.length() <= a.length() && a.compare(0, b.length(), b) == 0; +} + +/** + * Check if a ends with b. + */ +static bool endsWith(const std::string &a, const std::string &b) { + return b.length() <= a.length() && a.compare(a.length() - b.length(), b.length(), b) == 0; +} + +} // namespace string_utils +} // namespace trygvis |