diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-10-01 13:22:29 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-10-01 13:22:29 -0700 |
| commit | 2de9f83ff22774d0f70e3ee8158b26c494f5ea30 (patch) | |
| tree | b51023478e4ee413edc999ff458d270b7349e0da | |
| parent | 53d5076f64daa08c18802fda1b7bf8e100109103 (diff) | |
| download | vcpkg-2de9f83ff22774d0f70e3ee8158b26c494f5ea30.tar.gz vcpkg-2de9f83ff22774d0f70e3ee8158b26c494f5ea30.zip | |
Introduce Strings::case_insensitive_ascii_starts_with();
| -rw-r--r-- | toolsrc/include/vcpkg_Strings.h | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Strings.cpp | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 61f6fab61..c44ce2b99 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -65,6 +65,8 @@ namespace vcpkg::Strings std::string ascii_to_lowercase(const std::string& input); + bool case_insensitive_ascii_starts_with(const std::string& s, const std::string& pattern); + template<class Container, class Transformer, class CharType> std::basic_string<CharType> join(const CharType* delimiter, const Container& v, Transformer transformer) { diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 5ad951399..1bd96fc12 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -110,6 +110,11 @@ namespace vcpkg::Strings return output; } + bool case_insensitive_ascii_starts_with(const std::string& s, const std::string& pattern) + { + return _strnicmp(s.c_str(), pattern.c_str(), pattern.size()) == 0; + } + void trim(std::string* s) { s->erase(std::find_if_not(s->rbegin(), s->rend(), details::isspace).base(), s->end()); @@ -136,8 +141,9 @@ namespace vcpkg::Strings std::vector<std::string> split(const std::string& s, const std::string& delimiter) { std::vector<std::string> output; - - if(delimiter.empty()){ + + if (delimiter.empty()) + { output.push_back(s); return output; } |
