Class file

Inheritance Relationships

Base Type

  • public std::list< datablock >

Class Documentation

class file : public std::list<datablock>

The class file is actually a list of datablock objects.

Public Functions

file() = default
inline explicit file(const std::filesystem::path &p)

Construct a new file object using the data in the file p as content.

Parameters

p – Path to a file containing the data to load

inline explicit file(std::istream &is)

Construct a new file object using the data in the std::istream is.

Parameters

is – The istream containing the data to load

inline explicit file(const char *data, std::size_t length)

Construct a new file object with data in the constant string defined by data and length.

Parameters
  • data – The pointer to the character string with data to load

  • length – The length of the data

void set_validator(const validator *v)

Set the validator object to v.

inline const validator *get_validator() const

Get the validator object.

bool is_valid() const

Validate the content and return true if everything was valid.

Will throw an exception if there is no validator defined.

If each category was valid, validate_links will also be called.

Returns

true If the content is valid

Returns

false If the content is not valid

bool is_valid()

Validate the content and return true if everything was valid.

Will attempt to load the referenced dictionary if none was specified.

If each category was valid, validate_links will also be called.

Returns

true If the content is valid

Returns

false If the content is not valid

bool validate_links() const

Validate the links for all datablocks contained.

Will throw an exception if no validator was specified.

Returns

true If all links were valid

Returns

false If all links were not valid

void load_dictionary()

Attempt to load a dictionary (validator) based on the contents of the audit_conform category, if available.

void load_dictionary(std::string_view name)

Attempt to load the named dictionary name and create a validator based on it.

Parameters

name – The name of the dictionary to load

bool contains(std::string_view name) const

Return true if a datablock with the name name is part of this file.

inline datablock &front()

return a reference to the first datablock in the file

inline const datablock &front() const

return a const reference to the first datablock in the file

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

return a reference to the datablock named name

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

return a const reference to the datablock named name

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

Tries to find a datablock 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 datablock and a boolean indicating whether the datablock was created or not.

Parameters

name – The name for the datablock

Returns

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

void load(const std::filesystem::path &p)

Load the data from the file specified by p

void load(std::istream &is)

Load the data from is

void save(const std::filesystem::path &p) const

Save the data to the file specified by p

void save(std::ostream &os) const

Save the data to is

Friends

inline friend std::ostream &operator<<(std::ostream &os, const file &f)

Friend operator<< to write file f to std::ostream os.