Skip to content

Commit cee3d10

Browse files
committed
Support GCC 4.8, using Boost.Regex
The only caveat is that the user should make sure to link boost libraries as needed.
1 parent c15f292 commit cee3d10

3 files changed

Lines changed: 79 additions & 64 deletions

File tree

README.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ and instead can write only the help message--*the way you want it*.
4242

4343
int main(int argc, const char** argv)
4444
{
45-
std::map<std::string, docopt::value> args
46-
= docopt::docopt(USAGE,
45+
std::map<std::string, docopt::value> args
46+
= docopt::docopt(USAGE,
4747
{ argv + 1, argv + argc },
4848
true, // show help if requested
4949
"Naval Fate 2.0"); // version string
@@ -78,7 +78,9 @@ to work with docopt:
7878
- GCC 4.9
7979
- Visual C++ 2015 RC
8080

81-
Note that GCC-4.8 will not work due to its missing the ``regex`` module.
81+
GCC-4.8 can work, but the std::regex module needs to be replaced with ``Boost.Regex``.
82+
In that case, you will need to define ``DOCTOPT_USE_BOOST_REGEX`` when compiling
83+
docopt, and link your code with the appropriated Boost libraries.
8284

8385
This port is licensed under the MIT license, just like the original module.
8486
However, we are also dual-licensing this code under the Boost License, version 1.0,
@@ -92,8 +94,8 @@ The differences from the Python port are:
9294
* a ``docopt::value`` type to hold the various value types that can be parsed.
9395
We considered using boost::variant, but it seems better to have no external
9496
dependencies (beyond a good STL).
95-
* because C++ is statically-typed and Python is not, we had to make some
96-
changes to the interfaces of the internal parse tree types.
97+
* because C++ is statically-typed and Python is not, we had to make some
98+
changes to the interfaces of the internal parse tree types.
9799
* because ``std::regex`` does not have an equivalent to Python's regex.split,
98100
some of the regex's had to be restructured and additional loops used.
99101

@@ -126,7 +128,7 @@ API
126128
- ``argv`` is a vector of strings representing the args passed. Although
127129
main usually takes a ``(int argc, const char** argv)`` pair, you can
128130
pass the value ``{argv+1, argv+argc}`` to generate the vector automatically.
129-
(Note we skip the argv[0] argument!) Alternatively you can supply a list of
131+
(Note we skip the argv[0] argument!) Alternatively you can supply a list of
130132
strings like ``{ "--verbose", "-o", "hai.txt" }``.
131133

132134
- ``help``, by default ``true``, specifies whether the parser should
@@ -155,8 +157,8 @@ API
155157
compatibility with POSIX, or if you want to dispatch your arguments
156158
to other programs.
157159

158-
The **return** value is a ``map<string, docopt::value>`` with options,
159-
arguments and commands as keys, spelled exactly like in your help message.
160+
The **return** value is a ``map<string, docopt::value>`` with options,
161+
arguments and commands as keys, spelled exactly like in your help message.
160162
Long versions of options are given priority. For example, if you invoke the
161163
top example as::
162164

@@ -372,7 +374,7 @@ We have an extensive list of `examples
372374
every aspect of functionality of **docopt**. Try them out, read the
373375
source if in doubt.
374376

375-
There are also very intersting applications and ideas at that page.
377+
There are also very intersting applications and ideas at that page.
376378
Check out the sister project for more information!
377379

378380
Subparsers, multi-level help and *huge* applications (like git)
@@ -397,7 +399,7 @@ a C++ test case runner (run_testcase.cpp)::
397399

398400
$ clang++ --std=c++11 --stdlib=libc++ docopt.cpp run_testcase.cpp -o run_testcase
399401
$ python run_tests.py
400-
PASS (175)
402+
PASS (175)
401403

402404
You can also compile the example shown at the start (included as example.cpp)::
403405

@@ -424,10 +426,10 @@ You can also compile the example shown at the start (included as example.cpp)::
424426
Development
425427
---------------------------------------------------
426428

427-
Comments and suggestions are *very* welcome! If you find issues, please
429+
Comments and suggestions are *very* welcome! If you find issues, please
428430
file them and help improve our code!
429431

430-
Please note, however, that we have tried to stay true to the original
432+
Please note, however, that we have tried to stay true to the original
431433
Python code. If you have any major patches, structural changes, or new features,
432434
we might want to first negotiate these changes into the Python code first.
433435
However, bring it up! Let's hear it!
@@ -439,4 +441,3 @@ Changelog
439441
first release with stable API will be 1.0.0 (soon).
440442

441443
- 0.6.1 The initial C++ port of docopt.py
442-

docopt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <unordered_map>
1818
#include <map>
1919
#include <string>
20-
#include <regex>
2120
#include <iostream>
2221
#include <cassert>
2322
#include <cstddef>

0 commit comments

Comments
 (0)