OptionFlags

#include <poplar/OptionFlags.hpp>
namespace poplar

Poplar classes and functions.

Functions

ProfileValue getAsProfileValue(const OptionFlags &flags)
void readJSON(StringRef string, OptionFlags &flags)

Read options from a string in JSON format.

Parameters
  • string – The string to parse.

  • flags – The OptionFlags to update.

Throws

parse_error – if the input cannot be parsed.

void readJSON(std::istream &stream, OptionFlags &flags)

Read options from a stream in JSON format.

Parameters
  • stream – The input stream to read from.

  • flags – The OptionFlags to update.

Throws

parse_error – if the input cannot be parsed.

void readJSONFromEnv(StringRef envVarName, OptionFlags &flags)

Read options from a environment variable in JSON format.

Parameters
  • envVarName – The environment variable to retrieve and parse.

  • flags – The OptionFlags to update.

Throws

parse_error – if the input cannot be parsed.

std::ostream &operator<<(std::ostream &ostream, const OptionFlags &flags)

Write the contents of the given flags to an ostream in JSON format.

Parameters
  • ostream – The stream to write to.

  • flags – The OptionFlags to write.

class OptionFlags
#include <OptionFlags.hpp>

A set of option/value string flags to be used in various APIs.

Public Types

using OptionFlag = std::pair<const std::string, std::string>
using initializer_list = std::initializer_list<OptionFlag>

Public Functions

OptionFlags()

Construct a set of option flags.

The default constructor creates an empty set of flags.

~OptionFlags()
OptionFlags(const OptionFlags &other)
OptionFlags(OptionFlags &&other) noexcept
OptionFlags &operator=(const OptionFlags &other)
OptionFlags &operator=(OptionFlags &&other) noexcept
bool operator==(const OptionFlags &other) const

Option flags are an exact match.

Each collection contains the same keys, and both collections have the same values for each key

inline OptionFlags(initializer_list &&list)

Construct a set of option flags from an initializer list of string pairs.

Flags are set in the order they appear in the constructor.

Setting a flag more than once will result in the previous value for that option being overwritten.

Parameters

initializer – A list of option/value string pairs to set in the flags.

void set(initializer_list &&list)

Set option flags from an initializer list of string pairs.

Flags are set in the order they appear in the list.

Setting a flag more than once will result in the previous value for that option being overwritten. If the option was already set in these flags then the previous value will be overwritten.

Parameters

initializer – A list of option/value string pairs to set in the flags.

void set(StringRef option, StringRef value)

Set a single option to a value.

If the option was already set in these flags then the previous value will be over- written.

Parameters
  • option – The option to set in the flags.

  • value – The value to set the option to in the flags.

StringRef at(StringRef option) const

Retrieves the value of the given option.

If the option does not exist, then an exception is thrown.

Parameters

option – The option to retrieve in the flags.

void clear()

Remove all set flags.

iterator begin() const

Get iterators for the currently set option flags.

All iterators are invalidated when a new flag is set or the option flags are re-assigned.

iterator end() const

Private Members

std::unique_ptr<core::OptionFlags> impl
class iterator : public std::iterator<std::forward_iterator_tag, OptionFlag>

Public Functions

iterator(const iterator &other)
iterator &operator=(const iterator &other)
iterator(iterator &&other) noexcept
iterator &operator=(iterator &&other) noexcept
~iterator()
const OptionFlag &operator*() const
const OptionFlag *operator->() const
bool operator==(const iterator &other) const
inline bool operator!=(const iterator &other) const
iterator &operator++()
inline iterator operator++(int)

Private Functions

iterator(std::unique_ptr<core::OptionFlagsIterator> p) noexcept

Private Members

std::unique_ptr<core::OptionFlagsIterator> impl

Friends

friend class OptionFlags
namespace core