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& vstring = internal_json::extract_version_for_type(metadata.other, "gmt_file");
34 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(), /* skip_patch = */ true);
35 if (version.major != 1) {
36 throw std::runtime_error("unsupported version string '" + vstring + "'");
37 }
38
39 auto fpath = path / "file.gmt.gz";
40 internal_files::check_gzip_signature(fpath);
41
42 if (options.gmt_file_strict_check) {
43 options.gmt_file_strict_check(path, metadata, options);
44 }
45}
46
47}
48
49}
50
51#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