vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
image_file_probe.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/byte.hpp>
6#include <vitrio/export.hpp>
7#include <vitrio/span.hpp>
8
9#include <cstddef>
10#include <string>
11#include <vector>
12
13namespace vitrio
14{
15
33{
34public:
38 VITRIO_API
39 static constexpr std::size_t max_leading_bytes = 4096;
40
50 VITRIO_API
51 explicit image_file_probe(std::string path);
52
53 VITRIO_API
55 VITRIO_API
56 image_file_probe(image_file_probe &&other) noexcept;
57 VITRIO_API
59
60 VITRIO_API
61 image_file_probe& operator=(const image_file_probe &other);
62 VITRIO_API
63 image_file_probe& operator=(image_file_probe &&other) noexcept;
64
70 VITRIO_API
71 const std::string& get_path() const noexcept;
72
82 VITRIO_API
83 const std::string& get_extension() const noexcept;
84
95 VITRIO_API
96 span<const byte> get_leading_bytes() const noexcept;
97
106 VITRIO_API
107 bool exists() const noexcept;
108
120 VITRIO_API
121 bool is_directory() const noexcept;
122
123private:
124 std::string m_path;
125 std::string m_extension;
126 std::vector<byte> m_leading_bytes;
127 bool m_exists;
128 bool m_is_directory;
129};
130
131} // namespace vitrio
image_file_probe(std::string path)
Construct a probe by reading the leading bytes of a file.
span< const byte > get_leading_bytes() const noexcept
Get the leading bytes of the probed file.
bool is_directory() const noexcept
Check whether the probed path names a directory.
const std::string & get_extension() const noexcept
Get the extension of the probed file.
bool exists() const noexcept
Check whether the probed file exists and could be read.
static constexpr std::size_t max_leading_bytes
Most bytes a probe reads off the front of a file.
Definition image_file_probe.hpp:39
const std::string & get_path() const noexcept
Get the path of the probed file.
A view of a contiguous sequence of elements.
Definition span.hpp:29