# Poco::Util

# class OptionSet

Library: Util
Package: Options
Header: Poco/Util/OptionSet.h

## Description

A collection of Option objects.

## Member Summary

Member Functions: addOption, begin, end, getOption, hasOption, operator =

## Types Aliases

### Iterator

using Iterator = OptionVec::const_iterator;

### OptionVec

using OptionVec = std::vector < Option >;

## Constructors

### OptionSet

OptionSet();

Creates the OptionSet.

### OptionSet

OptionSet(
const OptionSet & options
);

Creates an option set from another one.

## Destructor

### ~OptionSet

~OptionSet();

Destroys the OptionSet.

## Member Functions

### addOption

void addOption(
const Option & option
);

Adds an option to the collection.

### begin

Iterator begin() const;

Supports iterating over all options.

### end

Iterator end() const;

Supports iterating over all options.

### getOption

const Option & getOption(
const std::string & name,
bool matchShort = false
) const;

Returns a reference to the option with the given name.

The given name can either be a fully specified short name, or a partially specified full name. The name must either match the short or full name of an option. Comparison case sensitive for the short name and not case sensitive for the full name. Throws a UnknownOptionException if no matching option has been found. Throws an AmbiguousOptionException if a partial full name matches more than one option.

### hasOption

bool hasOption(
const std::string & name,
bool matchShort = false
) const;

Returns a true iff an option with the given name exists.

The given name can either be a fully specified short name, or a partially specified full name. If a partial name matches more than one full name, false is returned. The name must either match the short or full name of an option. Comparison case sensitive for the short name and not case sensitive for the full name.

### operator =

OptionSet & operator = (
const OptionSet & options
);

Assignment operator.