cadMousePro-daemon/src/Common.h
branchv_0
changeset 12 cf77c218b0b1
parent 10 05dbed834852
child 26 fff8e9a86e85
equal deleted inserted replaced
11:bb42abd9f510 12:cf77c218b0b1
       
     1 /**
       
     2  * cadMousePro
       
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation, either version 3 of the License, or
       
     8  * (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    17  */
       
    18 #pragma once
       
    19 
       
    20 #include "CadMouseConfig.h"
       
    21 #include "CLI.h"
       
    22 #include "CLIException.h"
       
    23 
       
    24 class Common {
       
    25 public:
       
    26 
       
    27 	static Frequency parseFrequency(std::wstring value) {
       
    28 		if (value == L"125") return Frequency::Hz_0125;
       
    29 		else if (value == L"250") return Frequency::Hz_0250;
       
    30 		else if (value == L"500") return Frequency::Hz_0500;
       
    31 		else if (value == L"1000") return Frequency::Hz_1000;
       
    32 		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);
       
    33 	}
       
    34 	
       
    35 	// TODO: refactor exceptions
       
    36 
       
    37 };