Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
ArchiveIO.h
1#ifndef _ARCHIVEIO_H
2#define _ARCHIVEIO_H
3
4extern "C" {
5#include <mz.h>
6#include <mz_strm.h>
7#include <mz_zip.h>
8#include <mz_zip_rw.h>
9}
10#include <stdexcept>
11#include <string>
12
13class ArchiveIOGeneralException : public std::runtime_error {
14 public:
15 explicit ArchiveIOGeneralException(int32_t status, const std::string& action,
16 const std::string& log_location,
17 int32_t expectedStatus = MZ_OK)
18 : std::runtime_error(log_location + "Failed to " + action +
19 " invalid status: " + std::to_string(status) + " (" +
20 std::to_string(expectedStatus) + " expected)") {}
21};
22class ArchiveIOSpecificException : public std::runtime_error {
23 public:
24 ArchiveIOSpecificException(int32_t status, const std::string& errMessage,
25 const std::string& log_location,
26 int32_t expectedStatus = MZ_OK)
27 : std::runtime_error(log_location + errMessage + "\ninvalid status: " +
28 std::to_string(status) + " (" +
29 std::to_string(expectedStatus) + " expected)") {}
30 ArchiveIOSpecificException(const std::string& errMessage,
31 const std::string& log_location)
32 : std::runtime_error(log_location + errMessage) {}
33};
34#include <filesystem>
35#include <shared_mutex>
36class ArchiveIO {
37 private:
38 std::filesystem::path archivePath_;
39
40 protected:
41 mutable std::shared_mutex mutex_;
42
43 virtual void Create() = 0;
44
45 public:
46 explicit ArchiveIO(const std::filesystem::path& archivePath)
47 : archivePath_(archivePath) {}
48 ArchiveIO() = default;
49 virtual ~ArchiveIO() = default;
50
51 std::filesystem::path ArchivePath() const { return archivePath_; }
52 void SetArchivePath(const std::filesystem::path& archivePath) {
53 archivePath_ = archivePath;
54 };
55
56 virtual int32_t Close() = 0;
57 virtual void Delete() = 0;
58
59 virtual int Open() = 0;
60 virtual void* InternalPointer() const = 0;
61};
62
63#endif // _ARCHIVEIO_H
Definition ArchiveIO.h:13
Definition ArchiveIO.h:22
Definition ArchiveIO.h:36