-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.h
30 lines (24 loc) · 1.25 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef WTIIINTERPRETER_UTILS_H
#define WTIIINTERPRETER_UTILS_H
#include <string>
#include <vector>
#include "RuntimeException.h"
#include "ParsedScripts/Values/Constant.h"
// Helpful macros
#define throw_err(msg) throw RuntimeException(new Constant(msg, "string"))
#define Null new Constant("NULL", "NULL")
class Utils {
public:
static bool EndsWith(std::string str, std::string ending);
static std::string SubString(const std::string& str, int start, int end);
static std::vector<std::string> SubVector(const std::vector<std::string>& vec, int start, int end);
static void DumpErrorInfo(const RuntimeException& e);
static std::string GetAbsolutePath(const std::string& path);
static std::string TrimString(const std::string& val);
static bool ContainsChar(const std::string& str, const char& v);
static std::vector<std::string> SplitString(const std::string& str, const char& delimiter);
static std::vector<std::string> SplitString(const std::string& str, const char& delimiter, int count);
static std::vector<std::string> SplitString(const std::string& str, const std::string& delimiter, int amount);
static std::vector<std::string> SafeSplit(const std::string& str, const char& delimiter);
};
#endif //WTIIINTERPRETER_UTILS_H