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
67
68
69
70
71
72
73
74
75
|
#ifndef utility_H__
#define utility_H__
#include <cstdlib>
#include <string>
namespace meow{
//#
//# === meow:: *Functios* in utility.h
//#
//# [options="header",width="100%",cols="1>s,5<,1<,10<",grid="rows"]
//# |==============================================================
//# |Name | Parameters | Return_Type | Description
//# |stringPrintf |(char const * `fmt`, ...) | std::string
//# |Format print to C++ string and return it
inline std::string stringPrintf(char const * fmt, ...);
//# |stringReplace |(std::string `str`,\std::string const&
//# `from`,\std::string const& `to`) | std::string
//# |Return a string like `str`, but all `from` be replaced by `to`
inline std::string stringReplace(std::string str,
std::string const& from,
std::string const& to);
//# |cstringEndWith |(char const* `str`,\int `n`, ...) | bool
//# |Return whether `str` is end with one of the c-string you specify in
//# the parameters or not
inline bool cstringEndWith(char const* str, int n, ...);
//# |debugPrintf |(char const* `fmt`, ...) | void
//# |Print debug message (file name, line number, ...etc) when `DEBUG` is
//# defined
#define debugPrintf(...) \
meow::debugPrintf_(\
__FILE__,\
__PRETTY_FUNCTION__,\
__LINE__,\
meow::stringPrintf(__VA_ARGS__).c_str())
inline void debugPrintf_(char const* file,
char const* func,
size_t line,
char const* msg);
//# |messagePrintf |(int `level_change`,\char const* `fmt`, ...) | void
//# |階層式的訊息輸出
inline void messagePrintf(int level_change, char const* fmt, ...);
//# |filenameCompare |(std::string const& `f1`, std::string const& `f2`)|void
//# | 依照 `a0.txt < a1.txt < a2.txt < a10.txt` 的字串比較方法比較字串
inline bool filenameCompare(std::string const& f1, std::string const& f2);
//# |==============================================================
//#
//# [NOTE]
//# ====================================
//# * `stringReplace()` 不是用什麼好方法寫的因此執行效率很低請別虐待它.
//# ====================================
//#
//# '''
//#
}
#include "utility.hpp"
#endif // utility_H__
|