Class datablock

Inheritance Relationships

Base Type

  • public std::list< category >

Class Documentation

class datablock : public std::list<category>

A datablock is a list of category objects with some additional features.

Public Functions

datablock() = default
inline datablock(std::string_view name)

Construct a new datablock object with name name.

Parameters

name – The name for the new datablock

inline const std::string &name() const

Return the name of this datablock.

inline void set_name(std::string_view name)

Set the name of this datablock to name.

Parameters

name – The new name

void set_validator(const validator *v)

Set the validator object to v.

Parameters

v – The new validator object, may be null

const validator *get_validator() const

Get the validator object.

Returns

const validator* The validator or nullptr if there is none

bool is_valid() const

Validates the content of this datablock and all its content.

Returns

true If the content is valid

Returns

false If the content is not valid

bool is_valid()

Validates the content of this datablock and all its content and updates or removes the audit_conform category to match the result.

Returns

true If the content is valid

Returns

false If the content is not valid

bool validate_links() const

Validates all contained data for valid links between parents and children as defined in the validator.

Returns

true If all links are valid

Returns

false If all links are not valid

category &operator[](std::string_view name)

Return the category named name, will create a new and empty category named name if it does not exist.

Parameters

name – The name of the category to return

Returns

category& Reference to the named category

const category &operator[](std::string_view name) const

Return the const category named name, will return a reference to a static empty category if it was not found.

Parameters

name – The name of the category to return

Returns

category& Reference to the named category

category *get(std::string_view name)

Return a pointer to the category named name or nullptr if it does not exist.

Parameters

name – The name of the category

Returns

category* Pointer to the category found or nullptr

const category *get(std::string_view name) const

Return a pointer to the category named name or nullptr if it does not exist.

Parameters

name – The name of the category

Returns

category* Pointer to the category found or nullptr

std::tuple<iterator, bool> emplace(std::string_view name)

Tries to find a category with name name and will create a new one if it is not found. The result is a tuple of an iterator pointing to the category and a boolean indicating whether the category was created or not.

Parameters

name – The name for the category

Returns

std::tuple<iterator, bool> A tuple containing an iterator pointing at the category and a boolean indicating whether the category was newly created.

inline std::vector<std::string> get_tag_order() const

Get the preferred order of the categories when writing them.

std::vector<std::string> get_item_order() const

Get the preferred order of the categories when writing them.

void write(std::ostream &os) const

Write out the contents to os.

void write(std::ostream &os, const std::vector<std::string> &item_name_order)

Write out the contents to os using the order defined in item_name_order.

bool operator==(const datablock &rhs) const

Comparison operator to compare two datablock for equal content.

Friends

inline friend void swap_(datablock &a, datablock &b) noexcept
inline friend std::ostream &operator<<(std::ostream &os, const datablock &db)

Friend operator<< to write datablock db to std::ostream os.