cxxopts
cxxopts copied to clipboard
Split cxxopts.hpp into multiple files
One can observe a decomposition of cxxopts.hpp
into several parts:
- non-option-specific string-related code
- Exception-related code
- the values namespace and the Value class
- KeyValue, Option, OptionParser and related code
- ParseResult and some Option/OptionParser implementations which need ParseResult
- Options, OptionAddr, help
And the above is also the order of dependencies.
Or, actually, maybe we could take this another step and have one file per (non-trivial) class, so separate files for Option, Option Adder, Options, OptionParser etc.
So, how about we split the huge single file into a file for each of these? With cxxopts.hpp
remaining as an "includer" of all the others?
This will:
- Improve source code readability
- Make it easier to merge changes
- Make the revision history easier to understand (when looking at the affected files)
What do you think, @jarro2783 ?
I always wanted this to be single header to just drop into a project, and it still doesn't seem huge yet. If there was a nice way to generate a single header then I think it could be broken up.
@jarro2783 : Why is it important to be able to drop a single file rather than a subfolder?
Anyway, to create a single header, you run:
quom cxxopts.hpp cxxopts_single.hpp
and you get quom with:
pip3 --user install quom
See also: https://stackoverflow.com/a/62218074/1593077
Yeah I guess having multiple files is not so bad. I'll look at this after some of the other changes because it will mess up PRs.
So, yeah, the different PRs tend to clash. When you decide which of them you like, I'll rebase them onto each other so that you can merge.