summaryrefslogtreecommitdiffstats
path: root/Src/StringTools
diff options
context:
space:
mode:
authorLeonetienne <leonetienne@hotmail.de>2022-02-12 16:04:48 +0100
committerLeonetienne <leonetienne@hotmail.de>2022-02-12 16:04:48 +0100
commit7726d64530f82fc9b8ac08f484491335bd7ca2a4 (patch)
tree903e6f16b10f64a420c86ae93eaa8315a313ae2b /Src/StringTools
parenta8b8d557692823931bb41dcd55627080f55b6099 (diff)
Optimized directory structure
Diffstat (limited to 'Src/StringTools')
-rw-r--r--Src/StringTools/CMakeLists.txt6
-rw-r--r--Src/StringTools/StringTools.cpp100
-rw-r--r--Src/StringTools/StringTools.h29
3 files changed, 0 insertions, 135 deletions
diff --git a/Src/StringTools/CMakeLists.txt b/Src/StringTools/CMakeLists.txt
deleted file mode 100644
index 4aacd6e..0000000
--- a/Src/StringTools/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(StringTools)
-
-set(CMAKE_CXX_STANDARD 17)
-
-add_library(StringTools StringTools.cpp)
diff --git a/Src/StringTools/StringTools.cpp b/Src/StringTools/StringTools.cpp
deleted file mode 100644
index bb5faf3..0000000
--- a/Src/StringTools/StringTools.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "StringTools.h"
-#include <sstream>
-
-std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst)
-{
- std::stringstream ss;
-
- for (std::size_t i = 0; i < str.length(); i++)
- {
- if (str[i] != find)
- ss << str[i];
- else
- ss << subst;
- }
-
- return ss.str();
-}
-
-std::string StringTools::Replace(const std::string& str, const std::string& find, const std::string& subst)
-{
- if (find.length() == 0)
- return str;
-
- std::stringstream ss;
-
- std::size_t posFound = 0;
- std::size_t lastFound = 0;
-
- while (posFound != std::string::npos)
- {
- lastFound = posFound;
- posFound = str.find(find, posFound);
-
- if (posFound != std::string::npos)
- {
- ss << str.substr(lastFound, posFound - lastFound) << subst;
- posFound += find.length();
- }
- else
- {
- ss << str.substr(lastFound, (str.length()) - lastFound);
- }
- }
-
- return ss.str();
-}
-
-std::string StringTools::Replace(const std::string& str, const char find, const char subst)
-{
- std::stringstream ss;
- ss << subst;
-
- return Replace(str, find, ss.str());
-}
-
-std::string StringTools::Replace(const std::string& str, const std::string& find, const char subst)
-{
- std::stringstream ss;
- ss << subst;
-
- return Replace(str, find, ss.str());
-}
-
-std::string StringTools::Lower(const std::string& str)
-{
- std::stringstream ss;
-
- for (std::size_t i = 0; i < str.size(); i++)
- {
- const char c = str[i];
-
- // Quick-accept: regular letters
- if ((c >= 'A') && (c <= 'Z'))
- ss << (char)(c | 32);
-
- // Else: keep the character as is
- else ss << c;
- }
-
- return ss.str();
-}
-
-std::string StringTools::Upper(const std::string& str)
-{
- std::stringstream ss;
-
- for (std::size_t i = 0; i < str.size(); i++)
- {
- const char c = str[i];
-
- // Quick-accept: regular letters
- if ((c >= 'a') && (c <= 'z'))
- ss << (char)(c & ~32);
-
- // Else: keep the character as is
- else ss << c;
- }
-
- return ss.str();
-}
diff --git a/Src/StringTools/StringTools.h b/Src/StringTools/StringTools.h
deleted file mode 100644
index 589c047..0000000
--- a/Src/StringTools/StringTools.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-#include <string>
-
-/* 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);
-
- //! 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 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 make a string all-lowercase. Only works with latin and german umlautes, plus some extras.
- static std::string Lower(const std::string& str);
-
- //! Will make a string all-uppercase. Only works with latin and german umlautes, plus some extras.
- static std::string Upper(const std::string& str);
-
-private:
- // No instanciation! >:(
- StringTools();
-};