Class file
Defined in File file.hpp
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, 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
-
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.
-
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
-
file() = default