forked from jewalky/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.h
66 lines (52 loc) · 1.99 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef UTILS_H_INCLUDED
#define UTILS_H_INCLUDED
#include <string>
#include <vector>
#include <fstream>
extern std::ofstream _LOG_FILE;
extern std::string _LOG_NAME;
void _stdcall log_format(char *s, ...);
void _stdcall log_format2(char *s, ...);
std::vector<std::string> ParseCommandLine(std::string raw);
// string-related
std::string Format(const std::string format, ...);
std::vector<std::string> Explode(const std::string& what, const std::string& separator);
bool IsWhitespace(char what);
std::string TrimLeft(const std::string& what, bool (callback)(char) = IsWhitespace);
std::string TrimRight(const std::string& what, bool (callback)(char) = IsWhitespace);
std::string Trim(const std::string& what, bool (callback)(char) = IsWhitespace);
std::string ToLower(const std::string& what);
std::string ToUpper(const std::string& what);
unsigned long StrToInt(const std::string& what);
double StrToFloat(const std::string& what);
bool StrToBoolean(const std::string& what);
bool CheckInteger(const std::string& what);
// file related
bool FileExists(const std::string& file);
std::string Basename(const std::string& file);
std::string Dirname(const std::string& filename);
std::string FixSlashes(const std::string& filename);
std::string TruncateSlashes(const std::string& filename);
// helper
unsigned long _stdcall _call_func(unsigned long addr, unsigned long countp = 0, ...);
unsigned long _call_member_func(unsigned long addr, unsigned long cptr, unsigned long countp = 0, ...);
unsigned long _call_virtual_func(unsigned long cptr, unsigned long offset, unsigned long countp = 0, ...);
unsigned long _get_this();
#define _fst(count) __asm add esp, count
// directory search
struct CDirectoryEntry
{
std::string name;
};
class CDirectory
{
public:
CDirectory();
~CDirectory();
bool Open(const std::string& what);
bool Read(CDirectoryEntry& where);
void Close();
protected:
//DIR* directory;
};
#endif // UTILS_H_INCLUDED