Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
command_line.cpp
Go to the documentation of this file.
1
// Copyrights(c) 2017-2021, The Electroneum Project
2
// Copyrights(c) 2014-2019, The Monero Project
3
//
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without modification, are
7
// permitted provided that the following conditions are met:
8
//
9
// 1. Redistributions of source code must retain the above copyright notice, this list of
10
// conditions and the following disclaimer.
11
//
12
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
// of conditions and the following disclaimer in the documentation and/or other
14
// materials provided with the distribution.
15
//
16
// 3. Neither the name of the copyright holder nor the names of its contributors may be
17
// used to endorse or promote products derived from this software without specific
18
// prior written permission.
19
//
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
//
30
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32
#include "
command_line.h
"
33
#include <boost/algorithm/string/compare.hpp>
34
#include <boost/algorithm/string/predicate.hpp>
35
#include <unordered_set>
36
#include "
common/i18n.h
"
37
38
namespace
command_line
39
{
40
namespace
41
{
42
const
char
*
tr
(
const
char
* str)
43
{
44
return
i18n_translate
(str,
"command_line"
);
45
}
46
}
47
48
bool
is_yes
(
const
std::string& str)
49
{
50
if
(str ==
"y"
|| str ==
"Y"
)
51
return
true
;
52
53
boost::algorithm::is_iequal ignore_case{};
54
if
(boost::algorithm::equals(
"yes"
, str, ignore_case))
55
return
true
;
56
if
(boost::algorithm::equals(command_line::tr(
"yes"
), str, ignore_case))
57
return
true
;
58
59
return
false
;
60
}
61
62
bool
is_no
(
const
std::string& str)
63
{
64
if
(str ==
"n"
|| str ==
"N"
)
65
return
true
;
66
67
boost::algorithm::is_iequal ignore_case{};
68
if
(boost::algorithm::equals(
"no"
, str, ignore_case))
69
return
true
;
70
if
(boost::algorithm::equals(command_line::tr(
"no"
), str, ignore_case))
71
return
true
;
72
73
return
false
;
74
}
75
76
const
arg_descriptor<bool>
arg_help
= {
"help"
,
"Produce help message"
};
77
const
arg_descriptor<bool>
arg_version
= {
"version"
,
"Output version information"
};
78
}
command_line.h
tr
#define tr(x)
Definition
common_defines.h:4
i18n_translate
const char * i18n_translate(const char *s, const std::string &context)
Definition
i18n.cpp:323
i18n.h
command_line
Definition
command_line.cpp:39
command_line::arg_help
const arg_descriptor< bool > arg_help
Definition
command_line.cpp:76
command_line::is_no
bool is_no(const std::string &str)
Definition
command_line.cpp:62
command_line::arg_version
const arg_descriptor< bool > arg_version
Definition
command_line.cpp:77
command_line::is_yes
bool is_yes(const std::string &str)
Definition
command_line.cpp:48
command_line::arg_descriptor
Definition
command_line.h:54
src
common
command_line.cpp
Generated on
for Electroneum by
1.17.0