1 /* COPYING ******************************************************************
2 For copyright and licensing terms, see the file named COPYING.
3 // **************************************************************************
4 */
5 
6 #include <iostream>
7 #include <iomanip>
8 #include <cstring>
9 #include <cstdlib>
10 #include <cctype>
11 
12 #include "popt.h"
13 
14 using namespace popt;
15 
16 const char bool_string_definition::a[] = "boolean";
~bool_string_definition()17 bool_string_definition::~bool_string_definition() {}
action(processor &,const char * text)18 void bool_string_definition::action(processor & /*proc*/, const char * text)
19 {
20         if (0 == std::strcmp(text, "on"))
21                 value = true;
22         else
23         if (0 == std::strcmp(text, "off"))
24                 value = false;
25         else
26         if (0 == std::strcmp(text, "true"))
27                 value = true;
28         else
29         if (0 == std::strcmp(text, "false"))
30                 value = false;
31         else
32         if (0 == std::strcmp(text, "yes"))
33                 value = true;
34         else
35         if (0 == std::strcmp(text, "no"))
36                 value = false;
37         else
38         if (0 == std::strcmp(text, "1"))
39                 value = true;
40         else
41         if (0 == std::strcmp(text, "0"))
42                 value = false;
43         else
44 		throw error(text, "not a boolean");
45         set = true;
46 }
47