Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ArchiveReader.h
Go to the documentation of this file.
1#pragma once
2
3#include <bit>
4#include <filesystem>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "storm-config.h"
10
11#ifdef STORM_HAVE_LIBARCHIVE
12#include <archive.h>
13#include <archive_entry.h>
14#endif
15
16namespace storm {
17
18namespace storage {
19class BitVector;
20}
21
22namespace io {
23static_assert(std::endian::native == std::endian::little || std::endian::native == std::endian::big, "This code is not supported for mixed endian systems.");
24
26 private:
27#ifdef STORM_HAVE_LIBARCHIVE
31 struct ArchiveDeleter {
32 void operator()(archive* arch) const noexcept;
33 };
34#endif
35 public:
40 public:
41#ifdef STORM_HAVE_LIBARCHIVE
42 ArchiveReadEntry(archive_entry* currentEntry, archive* archive);
43#endif
44
49 std::filesystem::path name() const;
50
54 bool isDir() const;
55
56 template<typename T>
57 using VectorType = std::conditional_t<std::is_same_v<T, bool>, storm::storage::BitVector, std::vector<T>>;
58
63 template<typename T, std::endian Endianness = std::endian::little>
64 requires(std::is_arithmetic_v<T>)
66
71 std::string toString();
72
73 private:
74#ifdef STORM_HAVE_LIBARCHIVE
75 static constexpr size_t BufferSize = 8192;
76 archive_entry* const _currentEntry;
77 archive* _archive;
78#endif
79 };
80 class Iterator {
81 public:
82 Iterator() = default;
83#ifdef STORM_HAVE_LIBARCHIVE
84 Iterator(std::filesystem::path const& filename);
85#endif
86
87 bool operator==(Iterator const& other) const;
88 bool operator!=(Iterator const& other) const;
89
94
96
97 private:
98#ifdef STORM_HAVE_LIBARCHIVE
99 std::unique_ptr<archive, ArchiveDeleter> _archive;
100 archive_entry* _currentEntry{nullptr};
101#endif
102 };
103
104 ArchiveReader(std::filesystem::path const& file);
105
110 bool isReadableArchive() const;
111
116 Iterator begin() const;
117
122 Iterator end() const;
123
124 private:
125 std::filesystem::path const file;
126};
127
133ArchiveReader openArchive(std::filesystem::path const& file);
134} // namespace io
135} // namespace storm
PositionIteratorType Iterator
Object that reads the archive entry.
VectorType< T > toVector()
extracts the current entry’s data as a vector of the given type.
bool isDir() const
std::conditional_t< std::is_same_v< T, bool >, storm::storage::BitVector, std::vector< T > > VectorType
std::string toString()
extracts the current entry’s data as a string
std::filesystem::path name() const
Get the current entry’s path (filename) inside the archive.
bool operator==(Iterator const &other) const
Iterator & operator++()
Move to the next entry in the archive.
ArchiveReadEntry operator*() const
bool operator!=(Iterator const &other) const
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
ArchiveReader openArchive(std::filesystem::path const &file)
Reads an archive file.
storage::BitVector BitVector