| 1325 | }; |
| 1326 | |
| 1327 | class OptionValue |
| 1328 | { |
| 1329 | public: |
| 1330 | void |
| 1331 | parse |
| 1332 | ( |
| 1333 | const std::shared_ptr<const OptionDetails>& details, |
| 1334 | const std::string& text |
| 1335 | ) |
| 1336 | { |
| 1337 | ensure_value(details); |
| 1338 | ++m_count; |
| 1339 | m_value->parse(text); |
| 1340 | m_long_name = &details->long_name(); |
| 1341 | } |
| 1342 | |
| 1343 | void |
| 1344 | parse_default(const std::shared_ptr<const OptionDetails>& details) |
| 1345 | { |
| 1346 | ensure_value(details); |
| 1347 | m_default = true; |
| 1348 | m_long_name = &details->long_name(); |
| 1349 | m_value->parse(); |
| 1350 | } |
| 1351 | |
| 1352 | void |
| 1353 | parse_no_value(const std::shared_ptr<const OptionDetails>& details) |
| 1354 | { |
| 1355 | m_long_name = &details->long_name(); |
| 1356 | } |
| 1357 | |
| 1358 | #if defined(CXXOPTS_NULL_DEREF_IGNORE) |
| 1359 | #pragma GCC diagnostic push |
| 1360 | #pragma GCC diagnostic ignored "-Wnull-dereference" |
| 1361 | #endif |
| 1362 | |
| 1363 | CXXOPTS_NODISCARD |
| 1364 | size_t |
| 1365 | count() const noexcept |
| 1366 | { |
| 1367 | return m_count; |
| 1368 | } |
| 1369 | |
| 1370 | #if defined(CXXOPTS_NULL_DEREF_IGNORE) |
| 1371 | #pragma GCC diagnostic pop |
| 1372 | #endif |
| 1373 | |
| 1374 | // TODO: maybe default options should count towards the number of arguments |
| 1375 | CXXOPTS_NODISCARD |
| 1376 | bool |
| 1377 | has_default() const noexcept |
| 1378 | { |
| 1379 | return m_default; |
| 1380 | } |
| 1381 | |
| 1382 | template <typename T> |
| 1383 | const T& |
| 1384 | as() const |