Struct item_handle

Struct Documentation

struct item_handle

This is item_handle, it is used to access the data stored in item_value’s in rows.

Public Functions

item_handle() = delete
inline item_handle &operator=(item_value value)

Assign value value to the item referenced.

Template Parameters:

T – Type of the value

Parameters:

value – The value

Returns:

reference to this item_handle

item_value &value()

Return the value of the item.

const item_value &value() const

Return the const value of the item.

inline bool is_inapplicable() const noexcept

Return if value in item is of type INAPPLICABLE.

inline bool is_missing() const noexcept

Return if value in item is of type MISSING.

inline bool is_null() const noexcept

Return if value in item is NULL (MISSING or INAPPLICABLE).

inline bool is_string() const noexcept

Return if value in item is of type TEXT.

inline bool is_number_int() const noexcept

Return if value in item is an integer.

inline bool is_number_float() const noexcept

Return if value in item is a double.

inline bool is_number() const noexcept

Return if value in item is a number.

inline auto type() const

Return type of the value.

template<typename T>
inline auto get() const

Return the value casted to the type.

Template Parameters:

T

template<typename T>
inline auto as() const

Return the value casted to the type.

Template Parameters:

T, same – as get

inline auto str() const

Return the value as a std::string.

inline auto sv() const

Return a std::string_view to the character data in the value, throws if the type is not TEXT.

template<typename T>
inline auto value_or(const T &dv) const

Return the contents of this item as type

Template Parameters:

T – or, if not set, use dv as the default value.

inline int compare(const item_value &value, bool icase = true) const noexcept

Compare the contents of this item with value value optionally ignoring character case, if icase is true. Returns 0 if both are equal, -1 if this sorts before value and 1 if this sorts after value.

Parameters:
  • value – The value to compare with

  • icase – Flag indicating if we should compare character case sensitive

Returns:

-1, 0 or 1

inline int compare(const item_handle &value, bool icase = true) const noexcept

Compare the contents of this item with value of item value optionally ignoring character case, if icase is true. Returns 0 if both are equal, -1 if this sorts before value and 1 if this sorts after value.

Parameters:
  • value – The value to compare with

  • icase – Flag indicating if we should compare character case sensitive

Returns:

-1, 0 or 1

inline bool operator==(const item_value &value) const noexcept

Compare the value contained with the value value and return true if both are equal.

template<typename T>
inline bool operator!=(const T &value) const noexcept

Compare the value contained with the value value and return true if both are not equal.

bool empty() const

Returns true if the content string is empty or only contains ‘.’ meaning null or ‘?’ meaning unknown in a mmCIF context.

std::string_view text_() const

Return a std::string_view for the contents

inline item_handle(category &cat, row &row, uint16_t item_ix)

Construct a new item handle object.

Parameters:
  • cat – Reference to category containing row

  • row – Reference to the row

  • item_ix – Item index

inline item_handle(const category &cat, const row &r, uint16_t item_ix)

Constructor.

item_handle(const item_handle&) = delete
item_handle &operator=(const item_handle&) = delete

Friends

friend void swap(item_handle a, item_handle b) noexcept

Swap contents of a and b

inline friend std::ostream &operator<<(std::ostream &os, const item_handle &h)

Print out the item, for debugging.