16#include <initializer_list>
32 throw std::invalid_argument(
"unsupported Everett file kind");
40 if (
hex_.size() != 32)
throw std::invalid_argument(
"object ID must contain 32 lowercase hex digits");
42 if (!((c >=
'0' && c <=
'9') || (c >=
'a' && c <=
'f')))
43 throw std::invalid_argument(
"noncanonical object ID");
46 std::string
const &
hex() const noexcept {
return hex_; }
53 auto const & hex =
id.hex();
54 return std::filesystem::path(hex.substr(0, 2)) / hex.substr(2, 2) /
66 if (path.size() < 37 || path.size() > 40 || path[2] !=
'/' || path[5] !=
'/' || path[34] !=
'.')
67 throw std::invalid_argument(
"noncanonical sharded object path");
68 auto id =
object_id(std::string(path.substr(0, 2)) + std::string(path.substr(3, 2)) +
69 std::string(path.substr(6, 28)));
70 auto extension = path.substr(34);
72 if (extension ==
file_extension(kind))
return {std::move(
id), kind};
73 throw std::invalid_argument(
"unsupported Everett object extension");
Definition active_engine.h:18
parsed_object_path parse_object_path(std::string_view path)
Definition object_path.h:65
std::string_view file_extension(file_kind kind)
Definition object_path.h:27
std::filesystem::path object_path(object_id const &id, file_kind kind)
Definition object_path.h:52
file_kind
Definition object_path.h:25
Definition object_path.h:38
object_id(std::string hex)
Definition object_path.h:39
std::string const & hex() const noexcept
Definition object_path.h:46
std::string hex_
Definition object_path.h:49
bool operator==(object_id const &) const =default
static object_id from_hex(std::string_view hex)
Definition object_path.h:45
Definition object_path.h:58
file_kind kind
Definition object_path.h:60
object_id id
Definition object_path.h:59