E-MailRelay
goption.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file goption.cpp
19///
20
21#include "gdef.h"
22#include "goption.h"
23
24G::Option::Option( char c_in , const std::string & name_in , const std::string & description_in ,
25 const std::string & description_extra_in , Multiplicity value_multiplicity_in ,
26 const std::string & vd_in , unsigned int level_in ) :
27 c(c_in) ,
28 name(name_in) ,
29 description(description_in) ,
30 description_extra(description_extra_in) ,
31 value_multiplicity(value_multiplicity_in) ,
32 hidden(description_in.empty()||level_in==0U) ,
33 value_description(vd_in) ,
34 level(level_in) ,
35 main_tag(0U) ,
36 tag_bits(0U)
37{
38}
39
40G::Option::Option( char c_in , const char * name_in , const char * description_in ,
41 const char * description_extra_in , Multiplicity value_multiplicity_in ,
42 const char * vd_in , unsigned int level_in , unsigned int main_tag_in ,
43 unsigned int tag_bits_in ) :
44 c(c_in) ,
45 name(name_in) ,
46 description(description_in) ,
47 description_extra(description_extra_in) ,
48 value_multiplicity(value_multiplicity_in) ,
49 hidden(*description_in=='\0'||level_in==0U) ,
50 value_description(vd_in) ,
51 level(level_in) ,
52 main_tag(main_tag_in) ,
53 tag_bits(main_tag_in|tag_bits_in)
54{
55}
56
57G::Option::Multiplicity G::Option::decode( const std::string & s )
58{
59 if( s == "0" )
60 return Multiplicity::zero ;
61 else if( s == "01" )
62 return Multiplicity::zero_or_one ;
63 else if( s == "1" )
64 return Multiplicity::one ;
65 else if( s == "2" )
66 return Multiplicity::many ;
67 else
68 return Multiplicity::error ;
69}
70
Option(char c, const std::string &name, const std::string &description, const std::string &description_extra, Multiplicity value_multiplicity, const std::string &vd, unsigned int level)
Constructor taking strings.
Definition: goption.cpp:24
static Multiplicity decode(const std::string &)
Decodes a multiplicity string into its enumeration.
Definition: goption.cpp:57