C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
argumentparserprivate.h
Go to the documentation of this file.
1 #ifndef APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
2 #define APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
3 
4 #include "./argumentparser.h"
5 #include "./commandlineutils.h"
6 
7 namespace ApplicationUtilities {
8 
10 public:
11  ArgumentReader(ArgumentParser &parser, const char *const *argv, const char *const *end, bool completionMode = false);
12  ApplicationUtilities::ArgumentReader &reset(const char *const *argv, const char *const *end);
13  bool read();
14  bool read(ArgumentVector &args);
15 
21  size_t index;
23  const char *const *argv;
25  const char *const *end;
29  const char *const *lastArgDenotation;
31  const char *argDenotation;
33  unsigned char argDenotationType;
36 };
37 
38 class Wrapper;
39 
40 std::ostream &operator<<(std::ostream &os, const Wrapper &wrapper);
41 
42 class Wrapper {
43  friend std::ostream &operator<<(std::ostream &os, const Wrapper &wrapper);
44 
45 public:
46  Wrapper(const char *str, Indentation currentIndentation = Indentation());
47 
48 private:
49  const char *const m_str;
50  Indentation m_indentation;
51 };
52 
53 Wrapper::Wrapper(const char *str, Indentation currentIndentation)
54  : m_str(str)
55  , m_indentation(currentIndentation)
56 {
57 }
58 
59 } // namespace ApplicationUtilities
60 
61 #endif // APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
Argument * lastArg
The last Argument instance which could be detected. Set to nullptr in the initial call....
#define CPP_UTILITIES_EXPORT
unsigned char argDenotationType
The type of the currently processed abbreviation denotation. Unspecified if argDenotation is not set.
std::vector< Argument * > ArgumentVector
Contains currently only ArgumentParser and related classes.
The Wrapper class is internally used print text which might needs to be wrapped preserving the indent...
const char *const * argv
Points to the first argument denotation and will be incremented when a denotation has been processed.
The Indentation class allows printing indentation conveniently, eg.
const char * argDenotation
The currently processed abbreviation denotation (should be substring of one of the args in argv)....
ArgumentParser & parser
The associated ArgumentParser instance.
friend std::ostream & operator<<(std::ostream &os, const Wrapper &wrapper)
size_t index
An index which is incremented when an argument is encountered (the current index is stored in the occ...
The Argument class is a wrapper for command line argument information.
ArgumentVector & args
The Argument instances to store the results. Sub arguments of args are considered as well.
Wrapper(const char *str, Indentation currentIndentation=Indentation())
const char *const * end
Points to the end of the argv array.
const char *const * lastArgDenotation
Points to the element in argv where lastArg was encountered. Unspecified if lastArg is not set.
The ArgumentReader class internally encapsulates the process of reading command line arguments.
bool completionMode
Whether completion mode is enabled. In this case reading args will be continued even if an denotation...
CPP_UTILITIES_EXPORT std::ostream & operator<<(std::ostream &out, Indentation indentation)
The ArgumentParser class provides a means for handling command line arguments.