34 #include "../../Main/Exception.hpp" 35 #include "../../Wrapper/ZipArchive.hpp" 56 std::string
compress(
const std::vector<StringString>& fileContents);
57 std::vector<StringString>
decompress(
const std::string& compressedContent);
88 inline std::string
compress(
const std::vector<StringString>& fileContents) {
92 if(!archive.
valid()) {
97 for(
const auto& fileContent : fileContents) {
98 if(!archive.
addFile(fileContent.first, fileContent.second,
false)) {
106 archive.
close(result);
126 inline std::vector<StringString>
decompress(
const std::string& compressed) {
127 if(compressed.empty()) {
std::vector< StringString > decompress(const std::string &compressedContent)
Decompresses zip-compressed content.
Definition: Zip.hpp:126
Class for zip exceptions.
Definition: Zip.hpp:70
bool valid() const noexcept
Checks whether the underlying archive is valid.
Definition: ZipArchive.hpp:194
Namespace for compressing and decompressing zip.
Definition: Zip.hpp:44
bool addFile(const std::string &fileName, const std::string &content, bool overwrite)
Adds a file to the archive.
Definition: ZipArchive.hpp:270
#define MAIN_EXCEPTION_CLASS()
Macro used to easily define classes for general exceptions.
Definition: Exception.hpp:50
std::string compress(const std::vector< StringString > &fileContents)
Compresses files using zip.
Definition: Zip.hpp:88
RAII wrapper for ZIP archives used by libzip.
Definition: ZipArchive.hpp:65
std::pair< std::string, std::string > StringString
A pair of strings.
Definition: Zip.hpp:51
std::string getError()
Get the last occurred error as string.
Definition: ZipArchive.hpp:205
void close() noexcept
Closes the underlying archive if necessary.
Definition: ZipArchive.hpp:319