equal
deleted
inserted
replaced
|
1 #pragma once |
|
2 |
|
3 #include <locale.h> |
|
4 #include <string> |
|
5 #include <vector> |
|
6 #include <sstream> |
|
7 #include <locale> |
|
8 #include <codecvt> |
|
9 |
|
10 using namespace std; |
|
11 |
|
12 namespace relpipe { |
|
13 namespace cli { |
|
14 |
|
15 class CLI { |
|
16 public: |
|
17 |
|
18 CLI(int argc, char* argv[]) { |
|
19 setlocale(LC_ALL, ""); |
|
20 |
|
21 this->argc = &argc; |
|
22 this->argv = &argv; |
|
23 |
|
24 program = convertor.from_bytes(argv[0]); |
|
25 |
|
26 for (int i = 1; i < argc; i++) { |
|
27 args.insert(args.end(), convertor.from_bytes(argv[i])); |
|
28 } |
|
29 |
|
30 } |
|
31 |
|
32 CLI(const CLI& orig) { |
|
33 } |
|
34 |
|
35 virtual ~CLI() { |
|
36 } |
|
37 |
|
38 const wstring programName() { |
|
39 return (const wstring) program; |
|
40 } |
|
41 |
|
42 const vector<wstring> arguments() { |
|
43 return (const vector<wstring>)args; |
|
44 } |
|
45 |
|
46 static const int EXIT_CODE_SUCCESS = 0; |
|
47 static const int EXIT_CODE_UNEXPECTED_ERROR = 1; |
|
48 static const int EXIT_CODE_BAD_SYNTAX = 3; |
|
49 static const int EXIT_CODE_UNKNOWN_COMMAND = 4; |
|
50 static const int EXIT_CODE_DATA_ERROR = 5; |
|
51 |
|
52 private: |
|
53 int* argc; |
|
54 char*** argv; |
|
55 wstring program; |
|
56 vector<wstring> args; |
|
57 wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
|
58 }; |
|
59 |
|
60 } |
|
61 } |