* -Wsuggest-override is not supported by gcc before 5.0
* GCC prior to 5.0 should ignore not only -Wnon-virtual-dtor but also -Weffc++, otherwise non-virtual destructor problems will still be reported.
* The `#pragma GCC diagnostic push' should be used before setting up the temporary environment.
* When using GCC4.8, use manual lexical analysis instead of regular expressions.
* Add gcc4.8 stuff to travis file.
* -Wsuggest-override is not supported by gcc before 5.0
* GCC prior to 5.0 should ignore not only -Wnon-virtual-dtor but also -Weffc++, otherwise non-virtual destructor problems will still be reported.
* The `#pragma GCC diagnostic push' should be used before setting up the temporary environment.
* Improve formatting of help descriptions (#213)
* new function: cxxopts::Option::set_width(size_t width)
Set the size of a helpline.
* new function: cxxopts::Option::set_tab_expansion()
Expand the tabs in descriptions.
The tabsize 8 chars, base is start of description.
The descriptions are not disturbed by adding additional options.
* Allow newlines \n and tabs \t in descriptions.
Other changes (last commit/new commit):
* 1453/1471: size_t for OPTION_LONGEST and OPTION_DESC_GAP.
This prevents the static cast in 2086/2140.
* 2088/2142: in case of small width the value of
"width - longest - OPTION_DEC_GAP" becomes negative.
Because size_t is unsigned the result is a big number, and
the width of the column of the descriptions is not shortened.
* new 2143: When the given width is too small, it is set to
longest + OPTION_DESC_GAP + 10
* new 1570: A long description is broken into multiple lines, and
the iterator lastSpace remembers the begin of the last word.
But when the iterator current reaches the end of line, the whole
string from iterator is printed, which in soome cases is too
long. Thats why one blank is added to the description to trigger
the handling of lastSpace.
Accordingly in 1574/1627 the line is shortened by one char.
* repaired signed/unsigned issue
* changes for unicode
* Cmake Revamp
I needed to do a variety of things to ensure cxxopts worked well in my own project.
I created a new cmake module to abstract a lot of the logic in the main CMakelists.txt, I think it really assists in the readability of the project. Consequently a lot of logic is now written in functions.
I made a lot of the project options off by default unless the project is being built standalone. As a frequent consumer of cmake libraries this is a huge issue. Since examples, tests, installation, etc. aren't things I expect/desired by default when using libraries.
Co-authored-by: Juan Ramos <juanr0911@gmail.com>
Major refactor of the parsing code organisation to improve encapsulation
and not modify the input arguments. The returned result no longer has
pointers into the original option specification.
* Fixes#245:
* Added a new exception type: `option_has_no_value_exception`; throwing it when an option has no value we can cast with `as()`, instead of an `std::domain_error`.
* The `OptionValue` type now holds a pointer to the long option name (in its corresponding key within ParseResults's `m_results` field.
Some positional parameters would be listed in the help text and others
would not, when what is desired is that no positional parameters are
listed with the other command options. This change suppresses the help
listing for all positional parameters.
String literals with the prefix `u8` now have the type `const char8_t[N]` in
C++20. As a consequence the library does not compile in c++2a mode with GCC
(you can't concatenate `std::basic_string<char>` and `const char8_t[]` as
`char` and `char8_t` are different types).
Fixes#132. Since the map of options is shared between Options and
ParseResult, they should use a shared pointer instead of a reference so
that ParseResult can be returned without referencing destroyed memory.
Fixes#109. Although we always used numbers in the ASCII range, it was
in a `size_t`, leading to a warning about possible loss of data on some
compilers.
Fixes#102. Don't show the default value when it is a boolean and the
value is false. Note that this is a bit of a hack and the
implementation should probably be reevaluated in the future.
Fixes#96. Default values of options not specified on the command line
had a `count` of 1. It would be better if they had a count of 0 because
they were not actually specified, so that count is only for options
given by the user.
* `|` should be inside of `(…)`
It's possible to use `(t|true|T|True)` as `truthy_pattern` but still failing `true` as a truthy under my environment :-(
```
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
Fixes#83.
Adds an overload for positional arguments taking a
`std::initializer_list`. When using an `initializer_list` with one
argument, the function call is ambiguous matching both `std::string`
and `std::vector<std::string>`.
Fixes#84. Implicit values are not handled very well. For example:
--foo false true
--foo --bar
In the first, `false` is an argument to `--foo`, and then `true` is a
positional argument. In the second, because of the hyphen in `--bar`, `--foo`
is parsed with its implicit value. This seems inconsistent and unintuitive.
Better is that implicit values *never* consume the next parameter to be
completely consistent. This means that values with an implicit parameter
*must* be specified using the `--option=value` form.
* Prevent malformed numbers from being parsed as correct numbers.
Fixes#78. If you passed a string for example "test" it would get parsed to 1400.
The problem was that the parser did not throw an exception when an incorrect char was encountered.
Also a number without 0x in front with hexadecimal digits in it got parsed.
The number was treated as a hexadecimal number but it was still calculated with base 10.
So now before the current char is used, it is checked if it is valid in the current base.
Furthermore the number 0x0 was not a valid number, it now is a special case in the `integer_pattern`.
* Fixed `integer_pattern` so it works correctly under clang. Added testcase for invalid integers and for 0x0 being a valid number.
This is broken at the moment; it needs a complete rewrite.
The problem is that multiple options point to the same `OptionDetails`.
I really need to separate parsing results from describing options.
This removes the `final` on the class, and the `virtual` keyword on the
functions that made `final` necessary. They shouldn't have been
virtual in the first place since nothing derives from it.
This hopefully doesn't reintroduce the non-virtual-destructor warning.
´Value´ and ´standard_value´ don't have a virtual destructor. When I understand the code right, this is intended, because they are used through ´shared_ptr´ and so its not required. Nevertheless, clang does warn about it, since at the point of the destructor call it can not check if the object has a final type. Adding the C++11 keyword ´final´ to ´standard_value´ avoids this warning.
Fixes#62. This fixes compiler warnings that are raised by MSVC.
In one case the code that was warned about was never executed, but
this compiles it out in that case to silence the warning.
Fixes#39. Closes#40. This is an overhaul of the way that integer
arguments are parsed. Instead of using std::istream, which allows,
for example, negative integers for unsigned types, we use our own
parser.
This allows us to do proper range checking depending on the type,
and to correctly check for negative values passed to unsigned types.
This also allows the handling of base 16 numbers.