takane
Validators for ArtifactDB file formats
Loading...
Searching...
No Matches
gmt_file.hpp
Go to the documentation of this file.
1#ifndef TAKANE_GMT_FILE_HPP
2#define TAKANE_GMT_FILE_HPP
3
4#include "utils_files.hpp"
5#include "ritsuko/ritsuko.hpp"
6
7#include <filesystem>
8#include <stdexcept>
9#include <string>
10
16namespace takane {
17
22namespace gmt_file {
23
32inline void validate(const std::filesystem::path& path, const ObjectMetadata& metadata, Options& options) {
33 const std::string type_name = "gmt_file"; // use a separate variable to avoid dangling reference warnings from GCC.
34 const std::string& vstring = internal_json::extract_version_for_type(metadata.other, type_name);
35 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(), /* skip_patch = */ true);
36 if (version.major != 1) {
37 throw std::runtime_error("unsupported version string '" + vstring + "'");
38 }
39
40 auto fpath = path / "file.gmt.gz";
41 internal_files::check_gzip_signature(fpath);
42
43 if (options.gmt_file_strict_check) {
44 options.gmt_file_strict_check(path, metadata, options);
45 }
46}
47
48}
49
50}
51
52#endif
void validate(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition gmt_file.hpp:32
takane validation functions.
Definition _derived_from.hpp:15
Object metadata, including the type and other fields.
Definition utils_public.hpp:26
std::unordered_map< std::string, std::shared_ptr< millijson::Base > > other
Definition utils_public.hpp:35
Validation options.
Definition utils_public.hpp:94
std::function< void(const std::filesystem::path &, const ObjectMetadata &, Options &)> gmt_file_strict_check
Definition utils_public.hpp:222