summaryrefslogtreecommitdiff
path: root/src/cam/options.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-06 05:29:57 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-22 17:13:23 +0300
commitbb682d258517c7ed9c773f184df113e83f26c4f2 (patch)
tree360ef07c155d7e40f2efd46ec89d1c8880d796f0 /src/cam/options.h
parentb53f68e66ccfe67ca8b4ff4f7235a66fcfae01de (diff)
cam: options: Support parent-child relationship between options
Add support for creating a tree-based hieararchy of options instead of a flat list. This is useful to support options that need to be interpreted in the context of a particular occurrence of an array option. The usage text automatically documents the options in their corresponding context: Options: -c, --camera camera ... Specify which camera to operate on, by id or by index -h, --help Display this help message -I, --info Display information about stream(s) -l, --list List all cameras --list-controls List cameras controls -p, --list-properties List cameras properties -m, --monitor Monitor for hotplug and unplug camera events Options valid in the context of --camera: -C, --capture[=count] Capture until interrupted by user or until <count> frames captured -F, --file[=filename] Write captured frames to disk If the file name ends with a '/', it sets the directory in which to write files, using the default file name. Otherwise it sets the full file path and name. The first '#' character in the file name is expanded to the camera index, stream name and frame sequence number. The default file name is 'frame-#.bin'. -s, --stream key=value[,key=value,...] ... Set configuration of a camera stream height=integer Height in pixels pixelformat=string Pixel format name role=string Role for the stream (viewfinder, video, still, raw) width=integer Width in pixels --strict-formats Do not allow requested stream format(s) to be adjusted --metadata Print the metadata for completed requests Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/cam/options.h')
-rw-r--r--src/cam/options.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cam/options.h b/src/cam/options.h
index 5c51a94c..e894822c 100644
--- a/src/cam/options.h
+++ b/src/cam/options.h
@@ -10,6 +10,7 @@
#include <ctype.h>
#include <list>
#include <map>
+#include <tuple>
#include <vector>
class KeyValueParser;
@@ -91,9 +92,11 @@ public:
bool addOption(int opt, OptionType type, const char *help,
const char *name = nullptr,
OptionArgument argument = ArgumentNone,
- const char *argumentName = nullptr, bool array = false);
+ const char *argumentName = nullptr, bool array = false,
+ int parent = 0);
bool addOption(int opt, KeyValueParser *parser, const char *help,
- const char *name = nullptr, bool array = false);
+ const char *name = nullptr, bool array = false,
+ int parent = 0);
Options parse(int argc, char *argv[]);
void usage();
@@ -104,6 +107,10 @@ private:
void usageOptions(const std::list<Option> &options, unsigned int indent);
+ std::tuple<OptionsParser::Options *, const Option *>
+ childOption(const Option *parent, Options *options);
+ bool parseValue(const Option &option, const char *arg, Options *options);
+
std::list<Option> options_;
std::map<unsigned int, Option *> optionsMap_;
};
@@ -139,12 +146,15 @@ public:
KeyValueParser::Options toKeyValues() const;
std::vector<OptionValue> toArray() const;
+ const OptionsParser::Options &children() const;
+
private:
ValueType type_;
int integer_;
std::string string_;
KeyValueParser::Options keyValues_;
std::vector<OptionValue> array_;
+ OptionsParser::Options children_;
};
#endif /* __CAM_OPTIONS_H__ */