|
1 | 1 | #ifndef ARGPARSE_H |
2 | 2 | #define ARGPARSE_H |
3 | | -#define ARGPARSE_VERSION 2.2.5 |
| 3 | +#define ARGPARSE_VERSION 2.2.6 |
4 | 4 | #include <iostream> |
5 | 5 | #include <sstream> |
6 | 6 | #include <fstream> |
@@ -57,6 +57,19 @@ namespace argparse{ |
57 | 57 | operator float() const; |
58 | 58 | operator double() const; |
59 | 59 | operator bool() const; |
| 60 | + |
| 61 | + // Logical Operators |
| 62 | + bool operator!() const{ |
| 63 | + return !(bool)*this; |
| 64 | + } |
| 65 | + template <typename T> |
| 66 | + bool operator&&(const T& other) const{ |
| 67 | + return (bool)*this && other; |
| 68 | + } |
| 69 | + template <typename T> |
| 70 | + bool operator||(const T& other) const{ |
| 71 | + return (bool)*this || other; |
| 72 | + } |
60 | 73 |
|
61 | 74 | // Comparison Operators |
62 | 75 | template <typename T> |
@@ -127,6 +140,7 @@ namespace argparse{ |
127 | 140 | // Accessors |
128 | 141 | bool is_none() const; |
129 | 142 | bool is_true() const; |
| 143 | + bool is_false() const; |
130 | 144 | }; |
131 | 145 |
|
132 | 146 |
|
@@ -162,6 +176,19 @@ namespace argparse{ |
162 | 176 | operator bool() const; |
163 | 177 | operator std::string() const; |
164 | 178 |
|
| 179 | + // Logical Operators |
| 180 | + bool operator!() const{ |
| 181 | + return !(bool)at(0); |
| 182 | + } |
| 183 | + template <typename T> |
| 184 | + bool operator&&(const T& other) const{ |
| 185 | + return (bool)at(0) && other; |
| 186 | + } |
| 187 | + template <typename T> |
| 188 | + bool operator||(const T& other) const{ |
| 189 | + return (bool)at(0) || other; |
| 190 | + } |
| 191 | + |
165 | 192 | // Comparison Operators |
166 | 193 | template <typename T> |
167 | 194 | bool operator==(const T& other) const{ |
@@ -243,12 +270,9 @@ namespace argparse{ |
243 | 270 | const char* c_str() const; |
244 | 271 | bool is_none() const; |
245 | 272 | bool is_true() const; |
| 273 | + bool is_false() const; |
246 | 274 | std::vector<std::string> vec() const; |
247 | 275 | }; |
248 | | - std::ostream& operator<<(std::ostream& os, const ArgumentValueList& arglist){ |
249 | | - os << arglist.str(); |
250 | | - return os; |
251 | | - } |
252 | 276 | typedef std::map<std::string, ArgumentValueList> ArgumentMap; |
253 | 277 | std::string format_args(ArgumentMap args); |
254 | 278 | void print_args(ArgumentMap args, std::ostream& out=std::cout); |
|
0 commit comments