1//
2// OptionSet.h
3//
4// Library: Util
5// Package: Options
6// Module: OptionSet
7//
8// Definition of the OptionSet class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Util_OptionSet_INCLUDED
18#define Util_OptionSet_INCLUDED
19
20
21#include "Poco/Util/Util.h"
22#include "Poco/Util/Option.h"
23#include <vector>
24
25
26namespace Poco {
27namespace Util {
28
29
30class Util_API OptionSet
31 /// A collection of Option objects.
32{
33public:
34 typedef std::vector<Option> OptionVec;
35 typedef OptionVec::const_iterator Iterator;
36
37 OptionSet();
38 /// Creates the OptionSet.
39
40 OptionSet(const OptionSet& options);
41 /// Creates an option set from another one.
42
43 ~OptionSet();
44 /// Destroys the OptionSet.
45
46 OptionSet& operator = (const OptionSet& options);
47 /// Assignment operator.
48
49 void addOption(const Option& option);
50 /// Adds an option to the collection.
51
52 bool hasOption(const std::string& name, bool matchShort = false) const;
53 /// Returns a true iff an option with the given name exists.
54 ///
55 /// The given name can either be a fully specified short name,
56 /// or a partially specified full name. If a partial name
57 /// matches more than one full name, false is returned.
58 /// The name must either match the short or full name of an
59 /// option. Comparison case sensitive for the short name and
60 /// not case sensitive for the full name.
61
62 const Option& getOption(const std::string& name, bool matchShort = false) const;
63 /// Returns a reference to the option with the given name.
64 ///
65 /// The given name can either be a fully specified short name,
66 /// or a partially specified full name.
67 /// The name must either match the short or full name of an
68 /// option. Comparison case sensitive for the short name and
69 /// not case sensitive for the full name.
70 /// Throws a NotFoundException if no matching option has been found.
71 /// Throws an UnknownOptionException if a partial full name matches
72 /// more than one option.
73
74 Iterator begin() const;
75 /// Supports iterating over all options.
76
77 Iterator end() const;
78 /// Supports iterating over all options.
79
80private:
81 OptionVec _options;
82};
83
84
85} } // namespace Poco::Util
86
87
88#endif // Util_OptionSet_INCLUDED
89