IOFormat 1.12.0
Loading...
Searching...
No Matches
ioformat::GeneralOptions Class Reference

A collection of general options. More...

#include <ioformat/GeneralOptions.h>

Inherits ioformat::OptionMap.

Public Member Functions

 GeneralOptions (const GeneralOptions &other)=default
 
GeneralOptionsoperator= (const GeneralOptions &other)=default
 
 GeneralOptions (GeneralOptions &&other) noexcept=default
 
GeneralOptionsoperator= (GeneralOptions &&other) noexcept=default
 
bool has (const std::string &key) const
 Check if a key is present.
 
iolink::DataType dtype (const std::string &key) const
 Get the option data type.
 
size_t count (const std::string &key) const
 Get the number of values associated with a key.
 
void remove (const std::string &key)
 Remove a key from the option map.
 
bool getBool (const std::string &key) const
 Get a boolean value.
 
const std::string & getString (const std::string &key) const
 Get a string value.
 
const int64_t * getIntPtr (const std::string &key) const
 Get a pointer to the integer array first value.
 
int64_t getInt (const std::string &key, size_t index) const
 Get the integer value at a given index.
 
int64_t getInt (const std::string &key) const
 Get an integer value.
 
const double * getFloatPtr (const std::string &key) const
 Get a pointer to the float array first value.
 
double getFloat (const std::string &key, size_t index) const
 Get the float value at the given index.
 
double getFloat (const std::string &key) const
 Get a float value.
 
void setBool (const std::string &key, bool value)
 Associate a boolean value with a specific key.
 
void setString (const std::string &key, const std::string &value)
 Associate a string value with a specific key.
 
void setInt (const std::string &key, const int64_t *values, size_t count)
 Associate an integer array with a specific key.
 
void setInt (const std::string &key, int64_t value)
 Associate an integer value with a specific key.
 
void setFloat (const std::string &key, const double *values, size_t count)
 Associate a float array with a specific key.
 
void setFloat (const std::string &key, double value)
 Associate a float value with a specific key.
 
OptionMap select (const std::string &plugin, const std::string &format) const
 Select a subset of options.
 
- Public Member Functions inherited from ioformat::OptionMap
 OptionMap (const OptionMap &other)
 
OptionMapoperator= (const OptionMap &other)
 
 OptionMap (OptionMap &&other) noexcept
 
OptionMapoperator= (OptionMap &&other) noexcept
 
size_t size () const
 Get the number of element in the option map.
 
bool empty () const
 Check if the option map is empty.
 
bool has (const std::string &key) const
 Check if a key is present.
 
iolink::DataType dtype (const std::string &key) const
 Get the option data type.
 
size_t count (const std::string &key) const
 Get the number of values associated with a key.
 
void remove (const std::string &key)
 Remove a key from the option map.
 
std::string toString () const
 Get a string representation of the option map.
 
bool getBool (const std::string &key) const
 Get a boolean value.
 
const std::string & getString (const std::string &key) const
 Get a string value.
 
const int64_t * getIntPtr (const std::string &key) const
 Get a pointer to the integer array first value.
 
int64_t getInt (const std::string &key, size_t index) const
 Get the integer value at a given index.
 
int64_t getInt (const std::string &key) const
 Get an integer value.
 
const double * getFloatPtr (const std::string &key) const
 Get a pointer to the float array first value.
 
double getFloat (const std::string &key, size_t index) const
 Get the float value at the given index.
 
double getFloat (const std::string &key) const
 Get a float value.
 
void setBool (const std::string &key, bool value)
 Associate a boolean value with a specific key.
 
void setString (const std::string &key, const std::string &value)
 Associate a string value with a specific key.
 
void setInt (const std::string &key, const int64_t *values, size_t count)
 Associate an integer array with a specific key.
 
void setInt (const std::string &key, int64_t value)
 Associate an integer value with a specific key.
 
void setFloat (const std::string &key, const double *values, size_t count)
 Associate a float array with a specific key.
 
void setFloat (const std::string &key, double value)
 Associate a float value with a specific key.
 
iterator begin () const
 Get an iterator on the beginning of the option map.
 
iterator end () const
 Get an iterator on the end of the option map.
 

Detailed Description

A collection of general options.

This class behaves in a way similar to OptionMap, but it does some processing on the keys to allow for a more flexible use of the options.

The keys are formatted as a three part string: "plugin:format:option". You can use special values for the first two parts:

  • "all" to match any plugin
  • "ANY" to match any format/protocol For example, the key "all:TIFF:compression" will match any option that is specific to the TIFF format, regardless of the plugin. And the key "all:ANY:compression" will match any option that is related to the compression, regardless of the format or the plugin.

The first segment can be ommited, in which case it will be considered as "all". the first and second segments can be ommited, in which case they will be considered as "all" and "ANY" respectively. For example the option key, "compression" is equivalent to "all:ANY:compression" and ANY:compression". Plus, the "TIFF:compression" key is equivalent to "all:TIFF:compression".

Member Function Documentation

◆ count()

size_t ioformat::GeneralOptions::count ( const std::string &  key) const

Get the number of values associated with a key.

Boolean and string values will always return one, while numeric values will return the number of elements in the array.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.

◆ dtype()

iolink::DataType ioformat::GeneralOptions::dtype ( const std::string &  key) const

Get the option data type.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.

◆ getBool()

bool ioformat::GeneralOptions::getBool ( const std::string &  key) const

Get a boolean value.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not a boolean.

◆ getFloat() [1/2]

double ioformat::GeneralOptions::getFloat ( const std::string &  key) const

Get a float value.

This shortcut method return the first element of the array.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not a float.

◆ getFloat() [2/2]

double ioformat::GeneralOptions::getFloat ( const std::string &  key,
size_t  index 
) const

Get the float value at the given index.

Parameters
keyThe key to fetch.
indexThe index of the value in the array.
Exceptions
InvalidArgumentif the key is not present.
InvalidArgumentif the index is out of bounds.
Errorif the value is not a float.

◆ getFloatPtr()

const double * ioformat::GeneralOptions::getFloatPtr ( const std::string &  key) const

Get a pointer to the float array first value.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not a float.

◆ getInt() [1/2]

int64_t ioformat::GeneralOptions::getInt ( const std::string &  key) const

Get an integer value.

This shortcut method return the first element of the array.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not an integer.

◆ getInt() [2/2]

int64_t ioformat::GeneralOptions::getInt ( const std::string &  key,
size_t  index 
) const

Get the integer value at a given index.

Parameters
keyThe key to fetch.
indexThe index of the value in the array.
Exceptions
InvalidArgumentif the key is not present.
InvalidArgumentif the index is out of bounds.
Errorif the value is not an integer.

◆ getIntPtr()

const int64_t * ioformat::GeneralOptions::getIntPtr ( const std::string &  key) const

Get a pointer to the integer array first value.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not an integer.

◆ getString()

const std::string & ioformat::GeneralOptions::getString ( const std::string &  key) const

Get a string value.

Parameters
keyThe key to fetch.
Exceptions
InvalidArgumentif the key is not present.
Errorif the value is not a string.

◆ has()

bool ioformat::GeneralOptions::has ( const std::string &  key) const

Check if a key is present.

Parameters
keyThe key to check

◆ remove()

void ioformat::GeneralOptions::remove ( const std::string &  key)

Remove a key from the option map.

Parameters
keyThe key to remove.
Exceptions
InvalidArgumentif the key is not present.

◆ select()

OptionMap ioformat::GeneralOptions::select ( const std::string &  plugin,
const std::string &  format 
) const

Select a subset of options.

This method will return a new OptionMap containing only the options that match the given plugin and format/protocol. You can use the special values "all" and "ANY" to match any plugin or format/protocol.

If two selected options have the same third segment, the one that is more specific will be kept. Option keys get a point of priority for each segment that match the requested one (excluding the special values). For example, if you select "all:TIFF", the option "all:ANY:compression" will be less specific than "all:TIFF:compression", and the TIFF one will be selected.

Parameters
pluginThe plugin to filter on.
formatThe format or protocol to filter on.
Returns
Filtered options as an OptionMap.

◆ setBool()

void ioformat::GeneralOptions::setBool ( const std::string &  key,
bool  value 
)

Associate a boolean value with a specific key.

Parameters
keyThe key to set.
valueThe value to set.

◆ setFloat() [1/2]

void ioformat::GeneralOptions::setFloat ( const std::string &  key,
const double *  values,
size_t  count 
)

Associate a float array with a specific key.

Parameters
keyThe key to set.
valuesThe values to set.
countThe number of values to set.

◆ setFloat() [2/2]

void ioformat::GeneralOptions::setFloat ( const std::string &  key,
double  value 
)

Associate a float value with a specific key.

This shortcut method set a single value.

Parameters
keyThe key to set.
valueThe value to set.

◆ setInt() [1/2]

void ioformat::GeneralOptions::setInt ( const std::string &  key,
const int64_t *  values,
size_t  count 
)

Associate an integer array with a specific key.

Parameters
keyThe key to set.
valuesThe values to set.
countThe number of values to set.

◆ setInt() [2/2]

void ioformat::GeneralOptions::setInt ( const std::string &  key,
int64_t  value 
)

Associate an integer value with a specific key.

This shortcut method set a single value.

Parameters
keyThe key to set.
valueThe value to set.

◆ setString()

void ioformat::GeneralOptions::setString ( const std::string &  key,
const std::string &  value 
)

Associate a string value with a specific key.

Parameters
keyThe key to set.
valueThe value to set.

The documentation for this class was generated from the following file: