Moved objects into namespace Leonetienne

This commit is contained in:
Leonetienne 2022-05-17 00:03:39 +02:00
parent 954629f6bc
commit 7d9193e3ee
No known key found for this signature in database
GPG Key ID: C33879CD92E9708C
20 changed files with 294 additions and 228 deletions

View File

@ -1,6 +1,8 @@
#include <iostream> #include <iostream>
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
using namespace Leonetienne::StringTools;
int main() int main()
{ {
std::vector<std::string> foo = std::vector<std::string> foo =

View File

@ -3,8 +3,10 @@
#include <string> #include <string>
/* Handy utensils to manipulate characters */
namespace Leonetienne::StringTools {
/* Handy utensils to manipulate characters */
class CharTools { class CharTools {
public: public:
//! Checks whether or not `c` is a vowel. You can define custom vowel characters. //! Checks whether or not `c` is a vowel. You can define custom vowel characters.
@ -32,4 +34,6 @@ public:
static char CopySign(char sign, char c); static char CopySign(char sign, char c);
}; };
}
#endif //STRINGTOOLS_CHARTOOLS_H #endif //STRINGTOOLS_CHARTOOLS_H

View File

@ -4,6 +4,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace Leonetienne::StringTools {
/* Handy utensils to manipulate strings */ /* Handy utensils to manipulate strings */
class StringTools class StringTools
{ {
@ -40,4 +43,6 @@ private:
StringTools(); StringTools();
}; };
}
#endif //STRINGTOOLS_STRINGTOOLS_H #endif //STRINGTOOLS_STRINGTOOLS_H

View File

@ -1,6 +1,8 @@
#include "StringTools/CharTools.h" #include "StringTools/CharTools.h"
#include <algorithm> #include <algorithm>
namespace Leonetienne::StringTools {
bool CharTools::IsVowel(const char c, const std::string &vowels) { bool CharTools::IsVowel(const char c, const std::string &vowels) {
const char lc = MakeLower(c); const char lc = MakeLower(c);
@ -66,3 +68,6 @@ char CharTools::CopySign(char sign, char c) {
else else
return MakeLower(c); return MakeLower(c);
} }
}

View File

@ -1,6 +1,8 @@
#include "StringTools/StringTools.h" #include "StringTools/StringTools.h"
#include <sstream> #include <sstream>
namespace Leonetienne::StringTools {
std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst) { std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst) {
std::stringstream ss; std::stringstream ss;
@ -153,3 +155,6 @@ std::string StringTools::PadRight(const std::string& str, const char pad, const
return ss.str(); return ss.str();
} }
}

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]") TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
{ {
// Setup // Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character digit-ness by checking it against a map // Tests character digit-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]") TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character letter-ness by checking it against a map // Tests character letter-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]") TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character sign by checking it against a map // Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]") TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]")
{ {

View File

@ -2,6 +2,9 @@
#include <iostream> #include <iostream>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character sign by checking it against a map // Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]") TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character vowel-ness by checking it against a map // Tests character vowel-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]") TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]") TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
{ {
// Setup // Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h> #include <StringTools/CharTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]") TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
{ {
// Setup // Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that lowering an empty string returns an empty string // Tests that lowering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]") TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that padding to a length shorter adds no padding // Tests that padding to a length shorter adds no padding
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadLeft]") TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadLeft]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that padding to a length shorter adds no padding // Tests that padding to a length shorter adds no padding
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadRight]") TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadRight]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that replacing something in an empty string returns an empty string // Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]") TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that replacing something in an empty string returns an empty string // Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]") TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that splitting an empty string always returns {""} // Tests that splitting an empty string always returns {""}
TEST_CASE(__FILE__"/EmptyString", "[Strings][Split]") TEST_CASE(__FILE__"/EmptyString", "[Strings][Split]")
{ {

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h> #include <StringTools/StringTools.h>
#include "Catch2.h" #include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that uppering an empty string returns an empty string // Tests that uppering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]") TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
{ {