Changed brace-style
This commit is contained in:
parent
91d7f8da33
commit
cf397f3af8
@ -1,8 +1,7 @@
|
|||||||
#include "StringTools.h"
|
#include "StringTools.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < str.length(); i++)
|
for (std::size_t i = 0; i < str.length(); i++)
|
||||||
@ -16,8 +15,7 @@ std::string StringTools::Replace(const std::string& str, const char find, const
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringTools::Replace(const std::string& str, const std::string& find, const std::string& subst)
|
std::string StringTools::Replace(const std::string& str, const std::string& find, const std::string& subst) {
|
||||||
{
|
|
||||||
if (find.length() == 0)
|
if (find.length() == 0)
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
@ -45,24 +43,21 @@ std::string StringTools::Replace(const std::string& str, const std::string& find
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringTools::Replace(const std::string& str, const char find, const char subst)
|
std::string StringTools::Replace(const std::string& str, const char find, const char subst) {
|
||||||
{
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << subst;
|
ss << subst;
|
||||||
|
|
||||||
return Replace(str, find, ss.str());
|
return Replace(str, find, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringTools::Replace(const std::string& str, const std::string& find, const char subst)
|
std::string StringTools::Replace(const std::string& str, const std::string& find, const char subst) {
|
||||||
{
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << subst;
|
ss << subst;
|
||||||
|
|
||||||
return Replace(str, find, ss.str());
|
return Replace(str, find, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringTools::Lower(const std::string& str)
|
std::string StringTools::Lower(const std::string& str) {
|
||||||
{
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < str.size(); i++)
|
for (std::size_t i = 0; i < str.size(); i++)
|
||||||
@ -80,8 +75,7 @@ std::string StringTools::Lower(const std::string& str)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringTools::Upper(const std::string& str)
|
std::string StringTools::Upper(const std::string& str) {
|
||||||
{
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < str.size(); i++)
|
for (std::size_t i = 0; i < str.size(); i++)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#pragma once
|
#ifndef STRINGTOOLS_STRINGTOOLS_H
|
||||||
|
#define STRINGTOOLS_STRINGTOOLS_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/* Handy utensils to manipulate strings */
|
/* Handy utensils to manipulate strings */
|
||||||
@ -17,13 +19,15 @@ public:
|
|||||||
//! Will replace every occurence of `find` in `str` by `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);
|
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.
|
//! Will make a string all-lowercase.
|
||||||
static std::string Lower(const std::string& str);
|
static std::string Lower(const std::string& str);
|
||||||
|
|
||||||
//! Will make a string all-uppercase. Only works with latin and german umlautes, plus some extras.
|
//! Will make a string all-uppercase.
|
||||||
static std::string Upper(const std::string& str);
|
static std::string Upper(const std::string& str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// No instanciation! >:(
|
// No instanciation! >:(
|
||||||
StringTools();
|
StringTools();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //STRINGTOOLS_STRINGTOOLS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user