diff options
Diffstat (limited to 'StringTools/include')
| -rw-r--r-- | StringTools/include/StringTools/CharTools.h | 44 | ||||
| -rw-r--r-- | StringTools/include/StringTools/StringTools.h | 57 |
2 files changed, 55 insertions, 46 deletions
diff --git a/StringTools/include/StringTools/CharTools.h b/StringTools/include/StringTools/CharTools.h index 66c32c0..42b7e61 100644 --- a/StringTools/include/StringTools/CharTools.h +++ b/StringTools/include/StringTools/CharTools.h @@ -3,33 +3,37 @@ #include <string> -/* Handy utensils to manipulate characters */ -class CharTools { -public: - //! Checks whether or not `c` is a vowel. You can define custom vowel characters. - static bool IsVowel(const char c, const std::string &vowels = "euioay"); +namespace Leonetienne::StringTools { - //! Returns whether or not `c` is a letter. - static bool IsLetter(const char c); + /* Handy utensils to manipulate characters */ + class CharTools { + public: + //! Checks whether or not `c` is a vowel. You can define custom vowel characters. + static bool IsVowel(const char c, const std::string &vowels = "euioay"); - //! Returns whether or not `c` is a digit. - static bool IsDigit(const char c); + //! Returns whether or not `c` is a letter. + static bool IsLetter(const char c); - //! Checks whether or not `c` is an uppercase character. - static bool IsUpper(const char c); + //! Returns whether or not `c` is a digit. + static bool IsDigit(const char c); - //! Checks whether or not `c` is a lowercase character. - static bool IsLower(const char c); + //! Checks whether or not `c` is an uppercase character. + static bool IsUpper(const char c); - //! Will return `c` as an uppercase character. - static char MakeUpper(char c); + //! Checks whether or not `c` is a lowercase character. + static bool IsLower(const char c); - //! Will return `c` as a lowercase character. - static char MakeLower(char c); + //! Will return `c` as an uppercase character. + static char MakeUpper(char c); - //! Will return `c` with the same capitalization as `sign`. - static char CopySign(char sign, char c); -}; + //! Will return `c` as a lowercase character. + static char MakeLower(char c); + + //! Will return `c` with the same capitalization as `sign`. + static char CopySign(char sign, char c); + }; + +} #endif //STRINGTOOLS_CHARTOOLS_H diff --git a/StringTools/include/StringTools/StringTools.h b/StringTools/include/StringTools/StringTools.h index 818df4c..e984755 100644 --- a/StringTools/include/StringTools/StringTools.h +++ b/StringTools/include/StringTools/StringTools.h @@ -4,40 +4,45 @@ #include <string> #include <vector> -/* Handy utensils to manipulate strings */ -class StringTools -{ -public: - //! Will replace every occurence of `find` in `str` by `subst`. - static std::string Replace(const std::string& str, const char find, const std::string& subst); - //! Will replace every occurence of `find` in `str` by `subst`. - static std::string Replace(const std::string& str, const std::string& find, const std::string& subst); +namespace Leonetienne::StringTools { - //! Will replace every occurence of `find` in `str` by `subst`. - static std::string Replace(const std::string& str, const char find, const char subst); + /* Handy utensils to manipulate strings */ + class StringTools + { + public: + //! Will replace every occurence of `find` in `str` by `subst`. + static std::string Replace(const std::string& str, const char find, const std::string& subst); - //! Will replace every occurence of `find` in `str` by `subst`. - static std::string Replace(const std::string& str, const std::string& find, const char subst); + //! Will replace every occurence of `find` in `str` by `subst`. + static std::string Replace(const std::string& str, const std::string& find, const std::string& subst); - //! Will make a string all-lowercase. - static std::string Lower(const std::string& str); + //! Will replace every occurence of `find` in `str` by `subst`. + static std::string Replace(const std::string& str, const char find, const char subst); - //! Will make a string all-uppercase. - static std::string Upper(const std::string& str); + //! Will replace every occurence of `find` in `str` by `subst`. + static std::string Replace(const std::string& str, const std::string& find, const char subst); - //! Will split a string by a string seperator - static std::vector<std::string> Split(const std::string& str, const std::string& seperator); + //! Will make a string all-lowercase. + static std::string Lower(const std::string& str); - //! Will pad a string to the left to length l - static std::string PadLeft(const std::string& str, const char pad, const std::size_t len); + //! Will make a string all-uppercase. + static std::string Upper(const std::string& str); - //! Will pad a string to the right to length l - static std::string PadRight(const std::string& str, const char pad, const std::size_t len); + //! Will split a string by a string seperator + static std::vector<std::string> Split(const std::string& str, const std::string& seperator); -private: - // No instanciation! >:( - StringTools(); -}; + //! Will pad a string to the left to length l + static std::string PadLeft(const std::string& str, const char pad, const std::size_t len); + + //! Will pad a string to the right to length l + static std::string PadRight(const std::string& str, const char pad, const std::size_t len); + + private: + // No instanciation! >:( + StringTools(); + }; + +} #endif //STRINGTOOLS_STRINGTOOLS_H |
