Struct item_handle

Struct Documentation

struct item_handle

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

Public Functions

template<typename T>
inline item_handle &operator=(const T &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

template<typename T>
inline item_handle &operator=(T &&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

template<std::size_t N>
inline item_handle &operator=(const char (&value)[N])

Assign value value to the item referenced.

Template Parameters

T – Type of the value

Parameters

value – The value

Returns

reference to this item_handle

template<typename ...Ts>
inline void os(const Ts&... v)

A method with a variable number of arguments that will be concatenated and assigned as a string. Use it like this:

cif::item_handle ih;
is.os("The result of ", 1, " * ", 42, " is of course ", 42);

And the content will then be The result of 1 * 42 is of course 42.

Template Parameters

Ts – Types of the parameters

Parameters

v – The parameters to concatenate

void swap(item_handle &b)

Swap contents of this and b

template<typename T = std::string>
inline auto as() const -> T

Return the contents of this item as type

Template Parameters

T

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.

template<typename T>
inline int compare(const T &value, bool icase = true) const

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.

Template Parameters

T – Type of the value value

Parameters
  • value – The value to compare with

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

Returns

-1, 0 or 1

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

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

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

inline bool empty() const

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

inline explicit operator bool() const

Easy way to test for an empty item

inline bool is_null() const

is_null return true if the item contains ‘.’

inline bool is_unknown() const

is_unknown returns true if the item contains ‘?’

std::string_view text() const

Return a std::string_view for the contents

inline item_handle(uint16_t item, row_handle &row)

Construct a new item handle object.

Parameters
  • item – Item index

  • row – Reference to the row

Public Static Attributes

static CIFPP_EXPORT const item_handle s_null_item

A variable holding an empty item

Friends

inline friend void swap(item_handle a, item_handle b)

friend to swap two item handles