AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
autopas::options::Option< actualOption > Class Template Reference

Base class for autopas options. More...

#include <Option.h>

Inheritance diagram for autopas::options::Option< actualOption >:
Inheritance graph
[legend]

Public Member Functions

 operator bool ()=delete
 Prevents cast to bool by deleting the conversion operator.
 
std::string to_string (bool fixedLength=false) const
 Converts an Option object to its respective string representation.
 

Static Public Member Functions

static std::set< actualOption > getAllOptions ()
 Provides a way to iterate over the possible options.
 
static std::set< actualOption > getMostOptions ()
 Provides a way to iterate over the possible options minus those that are very unlikely to be on interest.
 
static size_t maxStringLength ()
 Returns the number of characters in the string representation of the longest option.
 
template<class OutputContainer = std::set<actualOption>>
static OutputContainer parseOptions (const std::string &optionsString)
 Converts a string of options to a set of enums.
 
template<bool lowercase = false>
static actualOption parseOptionExact (const std::string &optionString)
 Converts a string to an enum.
 

Friends

std::ostream & operator<< (std::ostream &os, const Option &option)
 Stream output operator.
 
std::istream & operator>> (std::istream &in, actualOption &option)
 Stream extraction operator.
 

Detailed Description

template<typename actualOption>
class autopas::options::Option< actualOption >

Base class for autopas options.

Template Parameters
actualOptionCuriously recurring template pattern.

Member Function Documentation

◆ getAllOptions()

template<typename actualOption >
static std::set< actualOption > autopas::options::Option< actualOption >::getAllOptions ( )
inlinestatic

Provides a way to iterate over the possible options.

Returns
Set of all possible values of this option type.

◆ getMostOptions()

template<typename actualOption >
static std::set< actualOption > autopas::options::Option< actualOption >::getMostOptions ( )
inlinestatic

Provides a way to iterate over the possible options minus those that are very unlikely to be on interest.

Note
This function is meant to provide sane defaults.
Returns

◆ maxStringLength()

template<typename actualOption >
static size_t autopas::options::Option< actualOption >::maxStringLength ( )
inlinestatic

Returns the number of characters in the string representation of the longest option.

Useful for pretty output.

Returns
the number of characters in the string representation of the longest option.

◆ operator bool()

template<typename actualOption >
autopas::options::Option< actualOption >::operator bool ( )
explicitdelete

Prevents cast to bool by deleting the conversion operator.

Returns

◆ parseOptionExact()

template<typename actualOption >
template<bool lowercase = false>
static actualOption autopas::options::Option< actualOption >::parseOptionExact ( const std::string &  optionString)
inlinestatic

Converts a string to an enum.

This function works faster than parseOptions, however, the given string needs to match exactly an option.

Template Parameters
lowercaseif set to true all option names are transformed to lower case.
Parameters
optionString
Returns
Option enum.

◆ parseOptions()

template<typename actualOption >
template<class OutputContainer = std::set<actualOption>>
static OutputContainer autopas::options::Option< actualOption >::parseOptions ( const std::string &  optionsString)
inlinestatic

Converts a string of options to a set of enums.

For best results, the options are expected to be lower case.

Allowed delimiters can be found in autopas::utils::StringUtils::delimiters. Possible options can be found in getAllOptions().

This function uses the Needleman-Wunsch algorithm to find the closest matching options. If an option is ambiguous an exception is thrown.

Note
If the only token in the string is "all", all options will be returned.
Template Parameters
OutputContainerType of the container in which the parsed values are stored. By default this will be a std::set to avoid duplicated but if ordering is important a std::vector could be used.
Parameters
optionsStringString containing traversal options.
Returns
Container of option enums. If no valid option was found the empty set is returned.

◆ to_string()

template<typename actualOption >
std::string autopas::options::Option< actualOption >::to_string ( bool  fixedLength = false) const
inline

Converts an Option object to its respective string representation.

Parameters
fixedLengthWhether result should be filled up with spaces to the length of the longest option.
Returns
The string representation or "Unknown Option (<IntValue>)".

Friends And Related Symbol Documentation

◆ operator<<

template<typename actualOption >
std::ostream & operator<< ( std::ostream &  os,
const Option< actualOption > &  option 
)
friend

Stream output operator.

Parameters
os
option
Returns

◆ operator>>

template<typename actualOption >
std::istream & operator>> ( std::istream &  in,
actualOption< actualOption > &  option 
)
friend

Stream extraction operator.

Parameters
inStream from which will be parsed.
optionout-parameter that will be filled with the parsed option.
Returns
Processed stream.

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