|
bool | derived_from (const std::string &type, const std::string &base, const Options &options) |
|
std::vector< size_t > | dimensions (const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options) |
|
std::vector< size_t > | dimensions (const std::filesystem::path &path, Options &options) |
|
std::vector< size_t > | dimensions (const std::filesystem::path &path) |
|
size_t | height (const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options) |
|
size_t | height (const std::filesystem::path &path, Options &options) |
|
size_t | height (const std::filesystem::path &path) |
|
bool | satisfies_interface (const std::string &type, const std::string &interface, const Options &options) |
|
void | validate (const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options) |
|
void | validate (const std::filesystem::path &path, Options &options) |
|
void | validate (const std::filesystem::path &path) |
|
ObjectMetadata | reformat_object_metadata (millijson::Base *raw) |
|
ObjectMetadata | read_object_metadata (const std::filesystem::path &path) |
|
takane validation functions.
bool takane::derived_from |
( |
const std::string & | type, |
|
|
const std::string & | base, |
|
|
const Options & | options ) |
|
inline |
Check whether a particular object type is derived from a base object type. Derived types satisfy the same file requirements of the base type, but usually add more files to represent additional functionality. This can be used by specifications to check whether arbitrary objects satisfy the file structure expectations for a particular base type.
Applications can add their own derived types for a given base class in Options::custom_derived_from
. This extends the default relationships whereby derived_from()
will take the union of all derived object types in the default and custom sets. Note that derived types must be manually included in every base type's set, e.g., if B is derived from A and C is derived from B, C must be added to the sets for both A and B.
- Parameters
-
type | Object type. |
base | Base object type. |
options | Validation options, containing custom derived/base relationships. |
- Returns
- Whether
type
is derived from base
or is equal to base
.
size_t takane::height |
( |
const std::filesystem::path & | path, |
|
|
const ObjectMetadata & | metadata, |
|
|
Options & | options ) |
|
inline |
Get the height of an object in a subdirectory, based on the supplied object type.
height()
is used to check the shape of objects stored in vertical containers, e.g., columns of a data_frame
. For vectors or other 1-dimensional objects, the height is usually just the length of the object (for some object-specific definition of "length"). For higher-dimensional objects, the height is usually the extent of the first dimension.
Applications can supply custom height functions for a given type via Options::custom_height
. If available, the supplied custom function will be used instead of the default.
- Parameters
-
path | Path to a directory representing an object. |
metadata | Metadata for the object, typically determined from its OBJECT file. |
options | Validation options. |
- Returns
- The object's height.
bool takane::satisfies_interface |
( |
const std::string & | type, |
|
|
const std::string & | interface, |
|
|
const Options & | options ) |
|
inline |
Check whether a particular object type satisfies a particular object interface. This can be used by specifications to check that child components satisfy certain user-level expectations for an abstract object (e.g., data frames, lists).
Applications can extend the takane framework by adding custom types to Options::custom_satisfies_interface
. This extends the default relationships whereby satisfies_interface()
will take the union of all object types in the default and custom sets. Note that, if a type is included in a particular set, it is not necessary to add its derived types, as satisfies_interface()
will automatically call derived_from()
.
- Parameters
-
type | Object type. |
interface | Interface type. |
options | Validation options, containing custom object interface relationships. |
- Returns
- Whether
type
satisfies interface
.