C++ Utilities: application/argumentparserprivate.h Source File

C++ Utilities 5.33.0 Useful C++ classes and routines such as argument parser, IO and conversion utilities

Loading...
Searching...
No Matches
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
7namespace CppUtilities {
8
9 class CPP_UTILITIES_EXPORT ArgumentReader {
10public:
11 ArgumentReader(ArgumentParser &parser, const char *const *argv, const char *const *end, bool completionMode = false);
12 ArgumentReader &reset(const char *const *argv, const char *const *end);
13 bool read();
14 bool read(ArgumentVector &args);
15
17 ArgumentParser &parser;
19 ArgumentVector &args;
21 std::size_t index;
23 const char *const *argv;
25 const char *const *end;
27 Argument *lastArg;
29 const char *const *lastArgDenotation;
31 const char *argDenotation;
33 unsigned char argDenotationType;
35 bool completionMode;
36};
37
38class Wrapper;
39
40std::ostream &operator<<(std::ostream &os, const Wrapper &wrapper);
41
42 class Wrapper {
43 friend std::ostream &operator<<(std::ostream &os, const Wrapper &wrapper);
44
45public:
46 Wrapper(const char *str, Indentation currentIndentation = Indentation());
47
48private:
49 const char *const m_str;
50 Indentation m_indentation;
51};
52
53 inline Wrapper::Wrapper(const char *str, Indentation currentIndentation)
54 : m_str(str)
55 , m_indentation(currentIndentation)
56{
57}
58
59} // namespace CppUtilities
60
61#endif // APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
argumentparser.h
CppUtilities::ArgumentParser
The ArgumentParser class provides a means for handling command line arguments.
Definition argumentparser.h:457
CppUtilities::ArgumentReader::lastArgDenotation
const char *const * lastArgDenotation
Points to the element in argv where lastArg was encountered. Unspecified if lastArg is not set.
Definition argumentparserprivate.h:29
CppUtilities::ArgumentReader::argDenotation
const char * argDenotation
The currently processed abbreviation denotation (should be substring of one of the args in argv)....
Definition argumentparserprivate.h:31
CppUtilities::ArgumentReader::ArgumentReader
ArgumentReader(ArgumentParser &parser, const char *const *argv, const char *const *end, bool completionMode=false)
Initializes the internal reader for the specified parser and arguments.
Definition argumentparser.cpp:126
CppUtilities::ArgumentReader::args
ArgumentVector & args
The Argument instances to store the results. Sub arguments of args are considered as well.
Definition argumentparserprivate.h:19
CppUtilities::ArgumentReader::argv
const char *const * argv
Points to the first argument denotation and will be incremented when a denotation has been processed.
Definition argumentparserprivate.h:23
CppUtilities::ArgumentReader::lastArg
Argument * lastArg
The last Argument instance which could be detected. Set to nullptr in the initial call....
Definition argumentparserprivate.h:27
CppUtilities::ArgumentReader::completionMode
bool completionMode
Whether completion mode is enabled. In this case reading args will be continued even if an denotation...
Definition argumentparserprivate.h:35
CppUtilities::ArgumentReader::argDenotationType
unsigned char argDenotationType
The type of the currently processed abbreviation denotation. Unspecified if argDenotation is not set.
Definition argumentparserprivate.h:33
CppUtilities::ArgumentReader::index
std::size_t index
An index which is incremented when an argument is encountered (the current index is stored in the occ...
Definition argumentparserprivate.h:21
CppUtilities::ArgumentReader::reset
ArgumentReader & reset(const char *const *argv, const char *const *end)
Resets the ArgumentReader to continue reading new argv.
Definition argumentparser.cpp:141
CppUtilities::ArgumentReader::parser
ArgumentParser & parser
The associated ArgumentParser instance.
Definition argumentparserprivate.h:17
CppUtilities::ArgumentReader::read
bool read()
Reads the commands line arguments specified when constructing the object.
Definition argumentparser.cpp:155
CppUtilities::ArgumentReader::end
const char *const * end
Points to the end of the argv array.
Definition argumentparserprivate.h:25
CppUtilities::Argument
The Argument class is a wrapper for command line argument information.
Definition argumentparser.h:263
CppUtilities::Indentation
The Indentation class allows printing indentation conveniently, eg.
Definition commandlineutils.h:71
CppUtilities::Wrapper
The Wrapper class is internally used print text which might needs to be wrapped preserving the indent...
Definition argumentparserprivate.h:42
CppUtilities::Wrapper::operator<<
friend std::ostream & operator<<(std::ostream &os, const Wrapper &wrapper)
Definition argumentparser.cpp:407
CppUtilities::Wrapper::Wrapper
Wrapper(const char *str, Indentation currentIndentation=Indentation())
Definition argumentparserprivate.h:53
commandlineutils.h
CPP_UTILITIES_EXPORT
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
Definition global.h:14
CppUtilities
Contains all utilities provided by the c++utilities library.
Definition argumentparser.h:18
CppUtilities::ArgumentVector
std::vector< Argument * > ArgumentVector
Definition argumentparser.h:69
CppUtilities::operator<<
CPP_UTILITIES_EXPORT std::ostream & operator<<(std::ostream &out, Indentation indentation)
Definition commandlineutils.h:88