# Class item

- Defined in File item.hpp

## Class Documentation

class item

  item is a transient class that is used to pass data into rows but it also takes care of formatting data.

  The class cif::item is often used implicitly when creating a row in a category using the emplace function.

      cif::category cat("my-cat");
      cat.emplace({
        { "item-1", 1 },                             // <- stores an item with value 1
        { "item-2", 1.0, 2 },                        // <- stores an item with value 1.00
        { "item-3", std::optional<int>() },          // <- stores an item with value ?
        { "item-4", std::make_optional<int>(42) },   // <- stores an item with value 42
        { "item-5" }                                 // <- stores an item with value .
      });

      std::cout << cat << '\n';

  Will result in:

      _my-cat.item-1 1
      _my-cat.item-2 1.00
      _my-cat.item-3 ?
      _my-cat.item-4 42
      _my-cat.item-5 .

  Public Functions

  item() = default

    Default constructor, empty item.

  inline item(std::string_view name)

    constructor for an item with name name and as content the character ‘.’, i.e. an inapplicable value.

  inline item(std::string_view name, char value)

    constructor for an item with name name and as content a single character string with content value

  template<typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
  inline item(std::string_view name, const T &value, int precision)

    constructor for an item with name name and as content the formatted floating point value value with precision precision

  template<typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
  inline item(const std::string_view name, const T &value)

    constructor for an item with name name and as content a formatted floating point value value with so-called general formatting

  template<typename T, std::enable_if_t<std::is_integral_v<T> and not std::is_same_v<T, bool>, int> = 0>
  inline item(const std::string_view name, const T &value)

    constructor for an item with name name and as content the formatted integral value value

  template<typename T, std::enable_if_t<std::is_same_v<T, bool>, int> = 0>
  inline item(const std::string_view name, const T &value)

    constructor for an item with name name and as content the formatted boolean value value

  inline item(const std::string_view name, std::string_view value)

    constructor for an item with name name and as content value value

  template<typename T, std::enable_if_t<std::is_same_v<T, std::string>, int> = 0>
  inline item(const std::string_view name, T &&value)

    constructor for an item with name name and as content value value

  template<typename T>
  inline item(const std::string_view name, const std::optional<T> &value)

    constructor for an item with name name and as content the optional value value

  template<typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
  inline item(std::string_view name, const std::optional<T> &value, int precision)

    constructor for an item with name name and as content the formatted floating point value value with precision precision

  inline std::string_view name() const

    Return the name of the item.

  inline std::string_view value() const &

    Return the value of the item.

  inline std::string value() const &&

    Return the value of the item.

  inline void value(std::string_view v)

    replace the content of the stored value with v

  inline bool empty() const

    empty means either null or unknown

  inline bool is_null() const

    returns true if the item contains ‘.’

  inline bool is_unknown() const

    returns true if the item contains ‘?’

  inline std::size_t length() const

    the length of the value string

  template<std::size_t N>
  inline decltype(auto) get() const

    support for structured binding