squid petting simulator 2020
This commit is contained in:
parent
49a3eae324
commit
cc14aa47e8
2 changed files with 26 additions and 11 deletions
|
@ -1,17 +1,34 @@
|
||||||
#include "string.hpp"
|
#include "string.hpp"
|
||||||
|
|
||||||
std::string sosc::str::trim(std::string str) {
|
std::string sosc::str::trim(std::string str) {
|
||||||
return rtrimr(ltrimr(str));
|
return *rtrim(ltrim(&str));
|
||||||
}
|
}
|
||||||
std::string* sosc::str::trim(std::string* str) {
|
std::string* sosc::str::trim(std::string* str) {
|
||||||
return rtrim(ltrim(str));
|
return rtrim(ltrim(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& sosc::str::trimr(std::string& str) {
|
std::string sosc::str::ltrim(std::string str) {
|
||||||
return rtrimr(ltrimr(str));
|
return *ltrim(&str);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string* sosc::str::ltrim(std::string* str) {
|
||||||
|
int marker = 0;
|
||||||
|
for(; marker < str->length(); ++marker)
|
||||||
|
if((*str)[marker] < 0x21) break;
|
||||||
|
|
||||||
|
str->erase(0, marker - 1);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sosc::str::rtrim(std::string str) {
|
std::string sosc::str::rtrim(std::string str) {
|
||||||
int marker = 0;
|
return *rtrim(&str);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string* sosc::str::rtrim(std::string *str) {
|
||||||
|
int marker = 0;
|
||||||
|
for(; marker < str->length(); --marker)
|
||||||
|
if((*str)[str->length() - marker - 1] < 0x21) break;
|
||||||
|
|
||||||
|
str->erase(str->length() - marker - 1, marker);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
#ifndef SOSC_UTIL_STRING_H
|
#ifndef SOSC_UTIL_STRING_H
|
||||||
#define SOSC_UTIL_STRING_H
|
#define SOSC_UTIL_STRING_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace sosc {
|
namespace sosc {
|
||||||
namespace str {
|
namespace str {
|
||||||
std::string trim (std::string str);
|
std::string trim (std::string str);
|
||||||
std::string* trim (std::string* str);
|
std::string* trim (std::string* str);
|
||||||
std::string& trimr(std::string& str);
|
|
||||||
|
|
||||||
std::string rtrim (std::string str);
|
|
||||||
std::string* rtrim (std::string* str);
|
|
||||||
std::string& rtrimr(std::string& str);
|
|
||||||
|
|
||||||
std::string ltrim (std::string str);
|
std::string ltrim (std::string str);
|
||||||
std::string* ltrim (std::string* str);
|
std::string* ltrim (std::string* str);
|
||||||
std::string& ltrimr(std::string& str);
|
|
||||||
|
std::string rtrim (std::string str);
|
||||||
|
std::string* rtrim (std::string* str);
|
||||||
|
|
||||||
std::vector<std::string> split
|
std::vector<std::string> split
|
||||||
(const std::string& str, char delimiter, int count = -1);
|
(const std::string& str, char delimiter, int count = -1);
|
||||||
|
|
Loading…
Reference in a new issue