OptionParsing

#include <poputil/OptionParsing.hpp>

OptionSpec and OptionHandler used to build up a specification of what options and their values should be, and to translate the value strings to real values.

namespace poplibs

PopLibs classes and functions.

Functions

template<typename T>
inline OptionHandler createOptionalDoubleHandler(std::optional<T> &output, double lowerBound = std::numeric_limits<double>::min(), bool lowerBoundIsInclusive = true, double upperBound = std::numeric_limits<double>::max(), bool upperBoundIsInclusive = true)
template<typename T, typename ValueMapT = std::map<std::string, T>>
inline OptionHandler createOptionalEnumHandler(std::optional<T> &output, ValueMapT &&valueMap)
class OptionHandler
#include <OptionParsing.hpp>

Represents the various options types.

Public Functions

template<typename T>
inline OptionHandler(T &&valueHandler)
inline void parseValue(poplar::StringRef value) const

Public Static Functions

template<typename T, typename ValueMapT = std::map<std::string, T>>
static inline OptionHandler createWithEnum(T &output, ValueMapT &&valueMap)
template<typename T>
static inline OptionHandler createWithInteger(T &output)
template<typename T>
static inline OptionHandler createWithBool(T &output)
template<typename T>
static inline void ensureValueIsWithinBounds(T value, const T &lowerBound, bool lowerBoundIsInclusive, const T &upperBound, bool upperBoundIsInclusive)
template<typename T>
static inline OptionHandler createWithDouble(T &output, double lowerBound = std::numeric_limits<double>::min(), bool lowerBoundIsInclusive = true, double upperBound = std::numeric_limits<double>::max(), bool upperBoundIsInclusive = true)
static inline OptionHandler createWithString(std::string &output)
template<typename T>
static inline OptionHandler createWithList(std::vector<T> &output)

Private Members

std::function<void(poplar::StringRef)> valueHandler
class OptionSpec
#include <OptionParsing.hpp>

Represents a set of options and their values.

Public Functions

inline OptionSpec(initializer_list_t &&handlers)
inline void parse(poplar::StringRef option, poplar::StringRef value, bool ignoreUnknown = false) const

Private Types

using value_type = std::pair<const std::string, OptionHandler>
using map_type = std::map<const std::string, OptionHandler>
using initializer_list_t = std::initializer_list<value_type>

Private Members

map_type handlers
namespace parse

Functions

template<typename T>
T asInteger(const poplar::StringRef &str)
template<typename T>
T asFloatingPoint(const poplar::StringRef &str)
template<typename T>
static inline std::string describeEnumValues(const std::map<std::string, T> &valueMap)
template<typename T>
T asEnum(const poplar::StringRef &value, const std::map<std::string, T> &map)
inline bool asBool(const poplar::StringRef &value)