DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
stringUtils.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Cody R. Drisko. All rights reserved.
2// Licensed under the MIT License. See the LICENSE file in the project root for more information.
3//
4// Name: stringUtils.hpp
5// Author: cdrisko
6// Date: 01/31/2020-15:41:47
7// Description: A collection of random string utilities and functions
8
9#ifndef DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_STRINGS_UTILS_STRINGUTILS_HPP
10#define DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_STRINGS_UTILS_STRINGUTILS_HPP
11
12#include <string>
13
14namespace CppUtils::Strings
15{
25 template<typename CharTraits>
26 constexpr bool foundSubstr(const std::basic_string<char, CharTraits>& stringToFind,
27 const std::basic_string<char, CharTraits>& stringToSearch) noexcept
28 {
29 if (stringToSearch.find(stringToFind) != std::basic_string<char, CharTraits>::npos)
30 return true;
31 else
32 return false;
33 }
34
38 template<typename CharTraits>
39 constexpr bool foundSubstr(char stringToFind, const std::basic_string<char, CharTraits>& stringToSearch) noexcept
40 {
41 if (stringToSearch.find(stringToFind) != std::basic_string<char, CharTraits>::npos)
42 return true;
43 else
44 return false;
45 }
46
50 template<typename CharTraits>
51 constexpr bool foundSubstr(const char* stringToFind, const std::basic_string<char, CharTraits>& stringToSearch) noexcept
52 {
53 if (stringToSearch.find(stringToFind) != std::basic_string<char, CharTraits>::npos)
54 return true;
55 else
56 return false;
57 }
58} // namespace CppUtils::Strings
59
60#endif
Definition ciString.hpp:17
constexpr bool foundSubstr(const std::basic_string< char, CharTraits > &stringToFind, const std::basic_string< char, CharTraits > &stringToSearch) noexcept
Definition stringUtils.hpp:26