Tool: make members private

Some of the members were not used externally at all, others were just
read-only externally.

Change-Id: I8fbe5c9c027e7d0adf516b311aafb6b66134776e
This commit is contained in:
Miklos Vajna
2019-01-03 09:05:18 +01:00
parent b3e4c42ab9
commit f204ff2333

View File

@ -45,6 +45,11 @@ class Tool: public Poco::Util::Application
public:
Tool();
const std::string& getServerURI() const { return _serverURI; }
const std::string& getDestinationFormat() const { return _destinationFormat; }
const std::string& getDestinationDir() const { return _destinationDir; }
private:
unsigned _numWorkers;
std::string _serverURI;
std::string _destinationFormat;
@ -71,9 +76,9 @@ using Poco::Util::OptionSet;
/// Thread class which performs the conversion.
class Worker: public Runnable
{
public:
Tool& _app;
std::vector< std::string > _files;
public:
Worker(Tool& app, const std::vector< std::string > & files) :
_app(app), _files(files)
{
@ -87,10 +92,10 @@ public:
void convertFile(const std::string& document)
{
Poco::URI uri(_app._serverURI);
Poco::URI uri(_app.getServerURI());
Poco::Net::HTTPClientSession *session;
if (_app._serverURI.compare(0, 5, "https") == 0)
if (_app.getServerURI().compare(0, 5, "https") == 0)
session = new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort());
else
session = new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
@ -100,7 +105,7 @@ public:
try {
Poco::Net::HTMLForm form;
form.setEncoding(Poco::Net::HTMLForm::ENCODING_MULTIPART);
form.set("format", _app._destinationFormat);
form.set("format", _app.getDestinationFormat());
form.addPart("data", new Poco::Net::FilePartSource(document));
form.prepareSubmit(request);
@ -121,7 +126,7 @@ public:
std::istream& responseStream = session->receiveResponse(response);
Poco::Path path(document);
std::string outPath = _app._destinationDir + "/" + path.getBaseName() + "." + _app._destinationFormat;
std::string outPath = _app.getDestinationDir() + "/" + path.getBaseName() + "." + _app.getDestinationFormat();
std::ofstream fileStream(outPath);
Poco::StreamCopier::copyStream(responseStream, fileStream);