author | František Kučera <franta-hg@frantovo.cz> |
Wed, 23 Oct 2019 22:43:29 +0200 | |
branch | v_0 |
changeset 26 | fff8e9a86e85 |
parent 12 | cf77c218b0b1 |
permissions | -rw-r--r-- |
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* cadMousePro |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
26
fff8e9a86e85
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
12 | 19 |
#include "CadMouseConfig.h" |
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include "CLI.h" |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#include "CLIException.h" |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
12 | 23 |
class Common { |
24 |
public: |
|
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
12 | 26 |
static Frequency parseFrequency(std::wstring value) { |
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
if (value == L"125") return Frequency::Hz_0125; |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
else if (value == L"250") return Frequency::Hz_0250; |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
else if (value == L"500") return Frequency::Hz_0500; |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
else if (value == L"1000") return Frequency::Hz_1000; |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
else throw CLIException(L"Unable to parse frequency value „" + value + L"“ – expecting „125“ or „250“ or „500“ or „1000“", CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
} |
12 | 33 |
|
34 |
// TODO: refactor exceptions |
|
7
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
148f8dd077e8
CLI options and parser of configuration parameters instead of hardcoded values
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
}; |