diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-07-15 14:53:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-07-15 14:53:43 (GMT) |
commit | 63ecf481da4d88196410ca67ebd0c9aa69f2e036 (patch) | |
tree | 67d0887bbd39819d995280b3e8ff575066bc4929 /Source/cmStringAlgorithms.h | |
parent | 36e00f9c843d2e03661119182fd98f0668320e09 (diff) | |
parent | eaad8072eefb9cbb7bf60d9753492e6fb604fd09 (diff) | |
download | CMake-63ecf481da4d88196410ca67ebd0c9aa69f2e036.zip CMake-63ecf481da4d88196410ca67ebd0c9aa69f2e036.tar.gz CMake-63ecf481da4d88196410ca67ebd0c9aa69f2e036.tar.bz2 |
Merge topic 'cmnonempty'
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5017
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r-- | Source/cmStringAlgorithms.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 3d5bf7e..4b0090b 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -20,6 +20,20 @@ /** String range type. */ using cmStringRange = cmRange<std::vector<std::string>::const_iterator>; +/** Check for non-empty string. */ +inline bool cmNonempty(const char* str) +{ + return str && *str; +} +inline bool cmNonempty(cm::string_view str) +{ + return !str.empty(); +} +inline bool cmNonempty(std::string const* str) +{ + return str && !str->empty(); +} + /** Callable string comparison struct. */ struct cmStrCmp { |