XJ music engine  1.9.6
In-game runtime engine for XJ music.
StringUtils.h
Go to the documentation of this file.
1 // Copyright (c) XJ Music Inc. (https://xjmusic.com) All Rights Reserved.
2 
3 #ifndef XJMUSIC_STRING_UTILS_H
4 #define XJMUSIC_STRING_UTILS_H
5 
6 #include <optional>
7 #include <regex>
8 #include <set>
9 #include <string>
10 #include <vector>
11 
12 namespace XJ {
13  class StringUtils {
14  private:
15  static std::regex leadingScores;
16  static std::regex nonAlphabetical;
17  static std::regex nonAlphanumeric;
18  static std::regex nonEvent;
19  static std::regex nonMeme;
20  static std::regex nonScored;
21  static std::regex nonSlug;
22  static std::regex spaces;
23  static std::regex tailingScores;
24  static std::regex underscores;
25 
26  public:
33  static std::vector<std::string> split(const std::string &input, const char delimiter);
34 
41  static std::string join(const std::vector<std::string> &input, const std::string &delimiter);
42 
48  static std::string trim(const std::string &str);
49 
55  static std::string toMeme(const std::string &raw);
56 
63  static std::string toMeme(const std::string *raw, const std::string &defaultValue);
64 
71  static std::string toEvent(const std::string &raw);
72 
78  static bool isNullOrEmpty(const std::string *raw);
79 
85  static std::string toAlphabetical(const std::string &raw);
86 
92  static std::string toAlphanumeric(const std::string &raw);
93 
99  static std::string toUpperCase(const std::string &input);
100 
106  static std::string toLowerCase(const std::string &input);
107 
113  static std::string formatFloat(float value);
114 
120  static std::string stripExtraSpaces(const std::string &value);
121 
129  static std::optional<std::string> match(const std::regex &pattern, const std::string &text);
130 
137  static int countMatches(const std::regex &regex, const std::string &basicString);
138 
145  static int countMatches(const char regex, const std::string &basicString);
146 
152  static std::string toShipKey(const std::string &name);
153 
159  static std::string toLowerScored(const std::string &raw);
160 
166  static std::string toUpperScored(const std::string &raw);
167 
173  static std::string toScored(const std::string &raw);
174 
181  static std::string toProper(std::string raw);
182 
189  static std::string toProperSlug(const std::string &raw);
190 
197  static std::string toSlug(std::string raw);
198 
205  static std::string toLowerSlug(const std::string &raw);
206 
213  static std::string toUpperSlug(const std::string &raw);
214 
220  static std::vector<std::string> sort(const std::set<std::string> &items);
221 
229  static std::string zeroPadded(unsigned long long value, int digits) {
230  std::string result = std::to_string(value);
231  while (result.length() < digits) {
232  result.insert(result.begin(), '0');
233  }
234  return result;
235  }
236 
237  };
238 
239 
240 }// namespace XJ
241 
242 #endif//XJMUSIC_STRING_UTILS_H
Definition: StringUtils.h:13
static std::vector< std::string > sort(const std::set< std::string > &items)
Definition: StringUtils.cpp:226
static std::string toLowerScored(const std::string &raw)
Definition: StringUtils.cpp:168
static std::string zeroPadded(unsigned long long value, int digits)
Definition: StringUtils.h:229
static bool isNullOrEmpty(const std::string *raw)
Definition: StringUtils.cpp:82
static std::string toProperSlug(const std::string &raw)
Definition: StringUtils.cpp:206
static std::string toUpperSlug(const std::string &raw)
Definition: StringUtils.cpp:222
static std::string toScored(const std::string &raw)
Definition: StringUtils.cpp:182
static std::string join(const std::vector< std::string > &input, const std::string &delimiter)
Definition: StringUtils.cpp:36
static std::vector< std::string > split(const std::string &input, const char delimiter)
Definition: StringUtils.cpp:26
static std::string toAlphabetical(const std::string &raw)
Definition: StringUtils.cpp:87
static std::string toMeme(const std::string &raw)
Definition: StringUtils.cpp:56
static int countMatches(const std::regex &regex, const std::string &basicString)
Definition: StringUtils.cpp:151
static std::string toProper(std::string raw)
Definition: StringUtils.cpp:194
static std::string formatFloat(float value)
Definition: StringUtils.cpp:113
static std::string toLowerCase(const std::string &input)
Definition: StringUtils.cpp:106
static std::string toEvent(const std::string &raw)
Definition: StringUtils.cpp:75
static std::string toAlphanumeric(const std::string &raw)
Definition: StringUtils.cpp:93
static std::string stripExtraSpaces(const std::string &value)
Definition: StringUtils.cpp:128
static std::optional< std::string > match(const std::regex &pattern, const std::string &text)
Definition: StringUtils.cpp:136
static std::string trim(const std::string &str)
Definition: StringUtils.cpp:47
static std::string toUpperCase(const std::string &input)
Definition: StringUtils.cpp:99
static std::string toSlug(std::string raw)
Definition: StringUtils.cpp:211
static std::string toShipKey(const std::string &name)
Definition: StringUtils.cpp:163
static std::string toLowerSlug(const std::string &raw)
Definition: StringUtils.cpp:217
static std::string toUpperScored(const std::string &raw)
Definition: StringUtils.cpp:175
Definition: ActiveAudio.h:11