2020-12-15 14:25:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <Windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace untwine
|
|
|
|
{
|
|
|
|
|
|
|
|
class QgisUntwine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Option = std::pair<std::string, std::string>;
|
|
|
|
using Options = std::vector<Option>;
|
|
|
|
using StringList = std::vector<std::string>;
|
|
|
|
|
|
|
|
QgisUntwine(const std::string& untwinePath);
|
|
|
|
|
|
|
|
bool start(const StringList& files, const std::string& outputDir,
|
|
|
|
const Options& argOptions = Options());
|
|
|
|
bool stop();
|
|
|
|
bool running();
|
|
|
|
int progressPercent() const;
|
|
|
|
std::string progressMessage() const;
|
2022-03-22 21:29:43 +01:00
|
|
|
std::string errorMessage() const;
|
2020-12-15 14:25:09 +01:00
|
|
|
|
|
|
|
private:
|
2022-03-22 21:29:43 +01:00
|
|
|
const int32_t ProgressMsg = 1000;
|
|
|
|
const int32_t ErrorMsg = 1001;
|
2020-12-15 14:25:09 +01:00
|
|
|
std::string m_path;
|
|
|
|
mutable bool m_running;
|
2022-03-22 21:29:43 +01:00
|
|
|
mutable uint32_t m_percent;
|
2020-12-15 14:25:09 +01:00
|
|
|
mutable std::string m_progressMsg;
|
2022-03-22 21:29:43 +01:00
|
|
|
mutable std::string m_errorMsg;
|
2020-12-15 14:25:09 +01:00
|
|
|
#ifndef _WIN32
|
|
|
|
pid_t m_pid;
|
|
|
|
int m_progressFd;
|
|
|
|
#else
|
|
|
|
HANDLE m_pid;
|
|
|
|
HANDLE m_progressFd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool start(Options& options);
|
|
|
|
void readPipe() const;
|
|
|
|
void childStopped();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace untwine
|