@@ -17,13 +17,13 @@ Or include files:
17
17
* ` src/wsjcpp_core.h `
18
18
* ` src/wsjcpp_core.cpp `
19
19
20
- ## Logger (WSJCppLog )
20
+ ## Logger (WsjcppLog )
21
21
22
22
* Output will be collored for console, but color will be missing for files.
23
23
* Functions are safe thread.
24
24
* Logger supports a log rotation (every 51000 seconds / every day)
25
- * WSJCppLog ::throw_err - will be generate ` throw std::runtime_error(sMessage); `
26
- * std::vector< std::string > WSJCppLog ::getLastLogMessages() - last 50 records from log
25
+ * WsjcppLog ::throw_err - will be generate ` throw std::runtime_error(sMessage); `
26
+ * std::vector< std::string > WsjcppLog ::getLastLogMessages() - last 50 records from log
27
27
28
28
In main() you need to init logger first.
29
29
@@ -32,11 +32,11 @@ In main() you need to init logger first.
32
32
33
33
int main(int argc, char* argv[]) {
34
34
std::string TAG = "MAIN";
35
- if (!WSJCppCore ::dirExists(".logs")) {
36
- WSJCppCore ::makeDir(".logs");
35
+ if (!WsjcppCore ::dirExists(".logs")) {
36
+ WsjcppCore ::makeDir(".logs");
37
37
}
38
- WSJCppLog ::setLogDirectory(".logs");
39
- WSJCppLog ::setPrefixLogFile("app");
38
+ WsjcppLog ::setLogDirectory(".logs");
39
+ WsjcppLog ::setPrefixLogFile("app");
40
40
41
41
// ...
42
42
return 0;
@@ -50,10 +50,10 @@ And then you can call static functions anywhere in your code:
50
50
51
51
...
52
52
const std::string TAG = "MAIN";
53
- WSJCppLog ::info(TAG, "Hello info");
54
- WSJCppLog ::err(TAG, "Hello err");
55
- WSJCppLog ::warn(TAG, "Hello warn");
56
- WSJCppLog ::ok(TAG, "Hello ok");
53
+ WsjcppLog ::info(TAG, "Hello info");
54
+ WsjcppLog ::err(TAG, "Hello err");
55
+ WsjcppLog ::warn(TAG, "Hello warn");
56
+ WsjcppLog ::ok(TAG, "Hello ok");
57
57
```
58
58
59
59
Example output
@@ -64,22 +64,22 @@ Example output
64
64
2020-02-25 16:56:07.376, 0x0x10ac51dc0 [OK] MAIN: Hello ok
65
65
```
66
66
67
- ## List of static function (WSJCppCore ):
67
+ ## List of static function (WsjcppCore ):
68
68
69
69
### doNormalizePath
70
70
71
71
Normalize paths. For example: ".//../bin/some/../" -> "./../bin/"
72
72
73
73
```
74
- std::string sPath = WSJCppCore ::doNormalizePath(".//../bin/some/../");
74
+ std::string sPath = WsjcppCore ::doNormalizePath(".//../bin/some/../");
75
75
```
76
76
77
77
### extractFilename
78
78
79
79
Extract base filename from fullpath.
80
80
81
81
```
82
- std::string sFilename = WSJCppCore ::doNormalizePath(".//../bin/some/../file.txt");
82
+ std::string sFilename = WsjcppCore ::doNormalizePath(".//../bin/some/../file.txt");
83
83
```
84
84
85
85
### getCurrentDirectory
@@ -165,7 +165,7 @@ static std::vector<std::string> listOfFiles(const std::string &sDirname);
165
165
Create a new directory
166
166
```
167
167
std::string sDirname = ".logs";
168
- if (WSJCppCore ::makeDir(sDirname)) {
168
+ if (WsjcppCore ::makeDir(sDirname)) {
169
169
std::cout << " Created '" << sDirname << "'" << std::endl;
170
170
}
171
171
```
@@ -182,7 +182,7 @@ static bool writeFile(const std::string &sFilename, const char *pBuffer, const i
182
182
Read text files into std::string
183
183
```
184
184
std::string sContent;
185
- if (WSJCppCore ::readTextFile("./file.txt", sContent)) {
185
+ if (WsjcppCore ::readTextFile("./file.txt", sContent)) {
186
186
std::cout << sContent;
187
187
}
188
188
```
@@ -194,15 +194,15 @@ Read file binary content to buffer
194
194
```
195
195
char *pBuffer = nullptr;
196
196
int nBufferSize = 0;
197
- if (WSJCppCore ::readFileToBuffer("./data/readFileToBuffer.txt", &pBuffer, nBufferSize)) {
197
+ if (WsjcppCore ::readFileToBuffer("./data/readFileToBuffer.txt", &pBuffer, nBufferSize)) {
198
198
// your can work with buffer here
199
199
}
200
200
```
201
201
202
202
### removeFile
203
203
204
204
```
205
- if (WSJCppCore ::removeFile("./file.txt")) {
205
+ if (WsjcppCore ::removeFile("./file.txt")) {
206
206
std::cout << "File removed" << std::endl;
207
207
}
208
208
```
@@ -212,7 +212,7 @@ if (WSJCppCore::removeFile("./file.txt")) {
212
212
Creating empty file. Will return true if file not exists and do created
213
213
214
214
```
215
- if (WSJCppCore ::createEmptyFile("./file.txt")) {
215
+ if (WsjcppCore ::createEmptyFile("./file.txt")) {
216
216
std::cout << "Empty file created" << std::endl;
217
217
}
218
218
```
@@ -244,14 +244,14 @@ Convert text to upper charaters like "abC" -> "ABC". Worked only with latin alph
244
244
### replaceAll
245
245
246
246
```
247
- WSJCppCore ::replaceAll(std::string& str, const std::string& from, const std::string& to);
247
+ WsjcppCore ::replaceAll(std::string& str, const std::string& from, const std::string& to);
248
248
```
249
249
250
250
### replaceAll
251
251
252
252
```
253
253
std::string sWhat = "|1a|2b|3c|4d|";
254
- std::vector<std::string> vSplitted = WSJCppCore ::split(sWhat, "|");
254
+ std::vector<std::string> vSplitted = WsjcppCore ::split(sWhat, "|");
255
255
for (int i = 0; i < vSplitted.size(); i++) {
256
256
std::cout << vSplitted[i] << std::endl;
257
257
}
@@ -269,11 +269,11 @@ Example output:
269
269
270
270
### createUuid
271
271
272
- Generate uuid, but you need to call ` WSJCppCore ::initRandom();` before it (for example in main() function)
272
+ Generate uuid, but you need to call ` WsjcppCore ::initRandom();` before it (for example in main() function)
273
273
274
274
```
275
- WSJCppCore ::initRandom(); // once in main on start
276
- std::string sUuid = WSJCppCore ::createUuid();
275
+ WsjcppCore ::initRandom(); // once in main on start
276
+ std::string sUuid = WsjcppCore ::createUuid();
277
277
std::cout << sUuid << std::endl;
278
278
```
279
279
@@ -287,9 +287,9 @@ b49d92ae-f11c-f8bc-3a94-e7519e341927
287
287
` unsigned int ` to hex string (lowercase)
288
288
289
289
```
290
- std::cout << WSJCppCore ::uint2hexString(1) << std::endl;
291
- std::cout << WSJCppCore ::uint2hexString(3000) << std::endl;
292
- std::cout << WSJCppCore ::uint2hexString(4123123123) << std::endl;
290
+ std::cout << WsjcppCore ::uint2hexString(1) << std::endl;
291
+ std::cout << WsjcppCore ::uint2hexString(3000) << std::endl;
292
+ std::cout << WsjcppCore ::uint2hexString(4123123123) << std::endl;
293
293
```
294
294
295
295
Example output
@@ -302,7 +302,7 @@ f5c1ddb3
302
302
303
303
```
304
304
std::string s = "dddd";
305
- unsigned long nPointer = WSJCppCore ::convertVoidToULong((void *)&s);
305
+ unsigned long nPointer = WsjcppCore ::convertVoidToULong((void *)&s);
306
306
std::cout << sPointerHex << std::endl;
307
307
static unsigned long convertVoidToULong(void *p);
308
308
```
@@ -316,7 +316,7 @@ Example output:
316
316
317
317
```
318
318
std::string s = "dddd";
319
- std::string sPointerHex = WSJCppCore ::getPointerAsHex((void *)&s);
319
+ std::string sPointerHex = WsjcppCore ::getPointerAsHex((void *)&s);
320
320
std::cout << sPointerHex << std::endl;
321
321
```
322
322
@@ -328,15 +328,15 @@ Example output:
328
328
### extractURLProtocol
329
329
330
330
```
331
- std::string sProtocol = WSJCppCore ::extractURLProtocol("https://github.com/wsjcpp");
331
+ std::string sProtocol = WsjcppCore ::extractURLProtocol("https://github.com/wsjcpp");
332
332
```
333
333
334
334
### getEnv
335
335
336
336
Get the value of a system environment variable
337
337
```
338
338
std::string sValue;
339
- if (WSJCppCore ::getEnv("PATH", sValue)) {
339
+ if (WsjcppCore ::getEnv("PATH", sValue)) {
340
340
std::cout << sValue << std::endl;
341
341
}
342
342
```
0 commit comments