Commit 0fe22a5171187339d2dfeb930784943c511610cc

Authored by Dennis Luxen
1 parent 1d9ae57a

untangle includes

- order lexicographically
- include all used headers directly instead of implicit includes
- remove unused header
- move regex include into compile unit
src/cxxopts.cpp
... ... @@ -24,6 +24,8 @@ THE SOFTWARE.
24 24  
25 25 #include "cxxopts.hpp"
26 26  
  27 +#include <regex>
  28 +
27 29 #define OPTION_LONGEST 30
28 30 #define OPTION_DESC_GAP 2
29 31  
... ... @@ -136,8 +138,8 @@ Options::add_options(std::string group)
136 138  
137 139 OptionAdder&
138 140 OptionAdder::operator()
139   -(
140   - const std::string& opts,
  141 +(
  142 + const std::string& opts,
141 143 const std::string& desc,
142 144 std::shared_ptr<const Value> value
143 145 )
... ... @@ -162,7 +164,7 @@ void
162 164 Options::parse_option
163 165 (
164 166 std::shared_ptr<OptionDetails> value,
165   - const std::string& name,
  167 + const std::string& name,
166 168 const std::string& arg
167 169 )
168 170 {
... ... @@ -291,7 +293,7 @@ Options::parse(int&amp; argc, char**&amp; argv)
291 293 else if (result[1].length() != 0)
292 294 {
293 295 std::string name = result[1];
294   -
  296 +
295 297 auto iter = m_options.find(name);
296 298  
297 299 if (iter == m_options.end())
... ... @@ -343,8 +345,8 @@ void
343 345 Options::add_option
344 346 (
345 347 const std::string& group,
346   - const std::string& s,
347   - const std::string& l,
  348 + const std::string& s,
  349 + const std::string& l,
348 350 const std::string& desc,
349 351 std::shared_ptr<const Value> value
350 352 )
... ... @@ -397,7 +399,7 @@ Options::help_one_group(const std::string&amp; g) const
397 399 size_t longest = 0;
398 400  
399 401 std::string result;
400   -
  402 +
401 403 if (!g.empty())
402 404 {
403 405 result += " " + g + " options:\n\n";
... ... @@ -443,7 +445,7 @@ Options::help_one_group(const std::string&amp; g) const
443 445 std::string
444 446 Options::help(const std::vector<std::string>& groups) const
445 447 {
446   - std::string result = "Usage:\n " + m_program + " [OPTION...] "
  448 + std::string result = "Usage:\n " + m_program + " [OPTION...] "
447 449 + m_help_string + "\n\n";
448 450  
449 451 for (const auto& g : groups)
... ...
src/cxxopts.hpp
... ... @@ -22,13 +22,13 @@ THE SOFTWARE.
22 22  
23 23 */
24 24  
25   -#include <regex>
26   -#include <set>
27   -#include <map>
28 25 #include <exception>
29   -#include <sstream>
30   -
31 26 #include <iostream>
  27 +#include <map>
  28 +#include <memory>
  29 +#include <sstream>
  30 +#include <string>
  31 +#include <vector>
32 32  
33 33 namespace cxxopts
34 34 {
... ... @@ -130,7 +130,7 @@ namespace cxxopts
130 130 public:
131 131 option_not_has_argument_exception
132 132 (
133   - const std::string& option,
  133 + const std::string& option,
134 134 const std::string& arg
135 135 )
136 136 : OptionParseException(
... ... @@ -288,7 +288,7 @@ namespace cxxopts
288 288 {
289 289 }
290 290  
291   - const std::string&
  291 + const std::string&
292 292 description() const
293 293 {
294 294 return m_desc;
... ... @@ -361,8 +361,8 @@ namespace cxxopts
361 361 add_option
362 362 (
363 363 const std::string& group,
364   - const std::string& s,
365   - const std::string& l,
  364 + const std::string& s,
  365 + const std::string& l,
366 366 const std::string& desc,
367 367 std::shared_ptr<const Value> value
368 368 );
... ... @@ -400,7 +400,7 @@ namespace cxxopts
400 400 help(const std::vector<std::string>& groups = {""}) const;
401 401  
402 402 private:
403   -
  403 +
404 404 void
405 405 add_one_option
406 406 (
... ... @@ -418,10 +418,10 @@ namespace cxxopts
418 418 parse_option
419 419 (
420 420 std::shared_ptr<OptionDetails> value,
421   - const std::string& name,
  421 + const std::string& name,
422 422 const std::string& arg = ""
423 423 );
424   -
  424 +
425 425 void
426 426 checked_parse_arg
427 427 (
... ... @@ -456,8 +456,8 @@ namespace cxxopts
456 456  
457 457 OptionAdder&
458 458 operator()
459   - (
460   - const std::string& opts,
  459 + (
  460 + const std::string& opts,
461 461 const std::string& desc,
462 462 std::shared_ptr<const Value> value
463 463 = ::cxxopts::value<bool>()
... ...