aboutsummaryrefslogtreecommitdiff
path: root/frontend/strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/strings.cpp')
-rw-r--r--frontend/strings.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/frontend/strings.cpp b/frontend/strings.cpp
index bb4a419..70fed85 100644
--- a/frontend/strings.cpp
+++ b/frontend/strings.cpp
@@ -1,13 +1,15 @@
+#include <algorithm>
+
#include "strings.h"
#include "print.h"
using namespace std;
-void print_string(const char * str) {
- lprtf("%s\n", wrap_string(str).c_str());
+void str_print(const char * str) {
+ lprtf("%s\n", str_wrap(str).c_str());
}
-string wrap_string(const char * str) {
+string str_wrap(const char * str) {
string out;
for (; *str != '\0'; str++) {
@@ -27,7 +29,8 @@ string wrap_string(const char * str) {
return out;
}
-vector<string> split_string(const string & src, const string & delim) {
+vector<string> str_split(const string & src, const string & delim) {
+ if (src.size() == 0) return {};
vector<string> out;
size_t start = 0;
size_t end = src.find(delim);
@@ -42,3 +45,16 @@ vector<string> split_string(const string & src, const string & delim) {
return out;
}
+string str_lower(const string & input) {
+ string out = input;
+ transform(out.begin(), out.end(), out.begin(), [](unsigned char c){ return tolower(c); });
+ return out;
+}
+
+string str_title(const string & input) {
+ if (input.size() == 0) return "";
+ string out = str_lower(input);
+ out[0] = toupper(out[0]);
+ return out;
+}
+