|
1 |
| -# Compile Time generator of configs |
2 |
| ---- |
3 |
| -GCT - это генератор CT конфига, тоесть из простого конфига, сгенерируется config.h / config.hpp файл, в котором будет все сгенерированые |
4 |
| ---- |
| 1 | +# CTH++ |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +### What is CTH++ |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +```text |
| 10 | +Usage: cth++ [options] |
| 11 | +Options: |
| 12 | + -h, --help - show this message |
| 13 | + -f, --file=<file> - input json file |
| 14 | + -o, --output=<file> - output file |
| 15 | + -w, --working=<dir> - working directory |
| 16 | + --std <std> - c++ standard |
| 17 | + --cmake-target-current-build <target> - current build target |
| 18 | + --global-namespace <name> - global namespace |
| 19 | + --debug - debug mode |
| 20 | + --release - release mode |
| 21 | + --development - development mode |
| 22 | + --production - production mode |
| 23 | +``` |
| 24 | + |
| 25 | +# Example |
| 26 | + |
| 27 | +```shell |
| 28 | +$ cth++ -f=config.json -o=config.h |
| 29 | +``` |
| 30 | + |
| 31 | +- config.json |
| 32 | + |
| 33 | +```json |
5 | 34 |
|
6 |
| -#### Usage: |
7 |
| -```hjson |
8 | 35 | {
|
9 |
| - project: { |
10 |
| - name: my_project |
11 |
| - version: 1.0.0 |
12 |
| - type: debug|developing |
13 |
| - } |
14 |
| - config: { |
15 |
| - server: { |
16 |
| - log: { |
17 |
| - level: { |
18 |
| - debug: TRACE |
19 |
| - release: WARN |
20 |
| - } |
21 |
| - } |
22 |
| - } |
23 |
| - } |
| 36 | + "project": { |
| 37 | + "name": "Example", |
| 38 | + "desc": "Example Example Example ", |
| 39 | + "version": "1.1.1", |
| 40 | + "debug": true, |
| 41 | + "dev": true, |
| 42 | + "output-path": "path/to/output", |
| 43 | + "project-dir": "path/to/project/dir" |
| 44 | + }, |
| 45 | + "config": { |
| 46 | + "client": { |
| 47 | + "port": 52485, |
| 48 | + "host": "localhost" |
| 49 | + }, |
| 50 | + "server": { |
| 51 | + "port": 2000, |
| 52 | + "host": "localhost", |
| 53 | + "options": { |
| 54 | + "max-connections": 10, |
| 55 | + "offline": false, |
| 56 | + "debug": { |
| 57 | + "max-connections": 5 |
| 58 | + } |
| 59 | + } |
| 60 | + }, |
| 61 | + "master": { |
| 62 | + "port": 2000, |
| 63 | + "host": "localhost" |
| 64 | + } |
| 65 | + } |
24 | 66 | }
|
25 | 67 | ```
|
26 | 68 |
|
27 |
| -```cpp |
28 |
| -... |
29 |
| -namespace my_project{ |
30 |
| - namespace project{ |
31 |
| - constexpr char* name = u8"my_project"; |
32 |
| - constexpr char* version = u8"1.0.0"; |
33 |
| - constexpr bool debug = true; |
34 |
| - constexpr bool developing = true; |
35 |
| - constepxr bool release = false; |
36 |
| - constexpr bool production = false; |
37 |
| - } |
38 |
| - namespacee config { |
| 69 | +- config.hpp |
| 70 | + |
| 71 | +```c++ |
| 72 | +// path/to/output |
| 73 | +/* |
| 74 | + _____ _ |
| 75 | + | ____| __ __ __ _ _ __ ___ _ __ | | ___ |
| 76 | + | _| \ \/ / / _` | | '_ ` _ \ | '_ \ | | / _ \ |
| 77 | + | |___ > < | (_| | | | | | | | | |_) | | | | __/ |
| 78 | + |_____| /_/\_\ \__,_| |_| |_| |_| | .__/ |_| \___| |
| 79 | + |_| |
| 80 | +*/ |
| 81 | + |
| 82 | +#pragma once |
| 83 | + |
| 84 | +#define VERSION_PACK(MAJOR, MINOR, PATCH) \ |
| 85 | + ( ( ( MAJOR ) << 16 ) | ( ( MINOR ) << 8 ) | ( PATCH ) ) |
| 86 | + |
| 87 | + |
| 88 | +namespace config { |
| 89 | + namespace project { |
| 90 | + constexpr char *name = "Example"; |
| 91 | + constexpr char *description = "Example work with config"; |
| 92 | + constexpr char *git_hash = "fb3483f"; |
| 93 | + constexpr unsigned int version = 65536; |
| 94 | + constexpr bool debug = true; |
| 95 | + constexpr bool release = false; |
| 96 | + constexpr bool development = true; |
| 97 | + constexpr bool production = false; |
| 98 | + constexpr char *target = ""; |
| 99 | + constexpr char *mode = "development"; |
| 100 | + constexpr char *type = "debug"; |
| 101 | + } |
| 102 | + namespace client { |
| 103 | + constexpr char *host = "localhost"; |
| 104 | + constexpr unsigned long long port = 52485ULL; |
| 105 | + } |
| 106 | + namespace master { |
| 107 | + constexpr char *host = "localhost"; |
| 108 | + constexpr unsigned long long port = 2000ULL; |
| 109 | + } |
39 | 110 | namespace server {
|
40 |
| - namespacec log { |
41 |
| - constexpr char* level = u8"TRACE"; |
42 |
| - } |
| 111 | + constexpr char *host = "localhost"; |
| 112 | + namespace options { |
| 113 | + namespace debug { |
| 114 | + constexpr unsigned long long max_connections = 5ULL; |
| 115 | + } |
| 116 | + constexpr unsigned long long max_connections = 10ULL; |
| 117 | + constexpr bool offline = false; |
| 118 | + } |
| 119 | + constexpr unsigned long long port = 2000ULL; |
43 | 120 | }
|
44 |
| - } |
45 | 121 | }
|
46 |
| -... |
47 |
| -``` |
48 |
| - |
49 |
| - |
50 |
| -### reference |
51 |
| -- buildroot config(make nconfig) |
52 |
| -- linux dialog |
| 122 | +``` |
0 commit comments