formatting
This commit is contained in:
parent
a0ac1a7975
commit
b7c3c4c042
@ -16,7 +16,8 @@ class DokuWiki
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DokuWiki(const std::string &url, const std::string &username, const std::string &password);
|
DokuWiki(const std::string &url, const std::string &username,
|
||||||
|
const std::string &password);
|
||||||
~DokuWiki();
|
~DokuWiki();
|
||||||
|
|
||||||
std::string getVersion();
|
std::string getVersion();
|
||||||
@ -35,4 +36,3 @@ class DokuWiki
|
|||||||
class impl;
|
class impl;
|
||||||
std::unique_ptr<impl> pimpl;
|
std::unique_ptr<impl> pimpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
DokuWiki::DokuWiki(const std::string &url, const std::string &username, const std::string &password)
|
DokuWiki::DokuWiki(const std::string &url, const std::string &username,
|
||||||
|
const std::string &password)
|
||||||
: pimpl{std::make_unique<impl>(url, username, password)}
|
: pimpl{std::make_unique<impl>(url, username, password)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -52,7 +53,8 @@ void DokuWiki::addPage(const std::string &pageName, const std::string &content)
|
|||||||
pimpl->addPage(pageName, content);
|
pimpl->addPage(pageName, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DokuWiki::appendToPage(const std::string &pageName, const std::string &content)
|
void DokuWiki::appendToPage(
|
||||||
|
const std::string &pageName, const std::string &content)
|
||||||
{
|
{
|
||||||
pimpl->appendToPage(pageName, content);
|
pimpl->appendToPage(pageName, content);
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,14 @@ xmlrpc_c::value DokuWiki::impl::executeCommand(const std::string &command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
xmlrpc_c::value_struct DokuWiki::impl::executeCommand(const std::string &command,
|
xmlrpc_c::value_struct DokuWiki::impl::executeCommand(
|
||||||
const std::list<std::string> ¶ms,
|
const std::string &command, const std::list<std::string> ¶ms,
|
||||||
const std::map<std::string, xmlrpc_c::value> &attributes)
|
const std::map<std::string, xmlrpc_c::value> &attributes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return xmlrpc_c::value_struct(executeCommand<xmlrpc_c::value>(
|
return xmlrpc_c::value_struct(
|
||||||
command, params, attributes));
|
executeCommand<xmlrpc_c::value>(command, params, attributes));
|
||||||
}
|
}
|
||||||
catch (girerr::error &e)
|
catch (girerr::error &e)
|
||||||
{
|
{
|
||||||
@ -52,8 +52,8 @@ std::string DokuWiki::impl::executeCommand(const std::string &command,
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return xmlrpc_c::value_string(executeCommand<xmlrpc_c::value>(
|
return xmlrpc_c::value_string(
|
||||||
command, params, attributes));
|
executeCommand<xmlrpc_c::value>(command, params, attributes));
|
||||||
}
|
}
|
||||||
catch (girerr::error &e)
|
catch (girerr::error &e)
|
||||||
{
|
{
|
||||||
@ -68,8 +68,8 @@ int DokuWiki::impl::executeCommand(const std::string &command,
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return xmlrpc_c::value_int(executeCommand<xmlrpc_c::value>(
|
return xmlrpc_c::value_int(
|
||||||
command, params, attributes));
|
executeCommand<xmlrpc_c::value>(command, params, attributes));
|
||||||
}
|
}
|
||||||
catch (girerr::error &e)
|
catch (girerr::error &e)
|
||||||
{
|
{
|
||||||
@ -84,8 +84,8 @@ bool DokuWiki::impl::executeCommand(const std::string &command,
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return xmlrpc_c::value_boolean(executeCommand<xmlrpc_c::value>(
|
return xmlrpc_c::value_boolean(
|
||||||
command, params, attributes));
|
executeCommand<xmlrpc_c::value>(command, params, attributes));
|
||||||
}
|
}
|
||||||
catch (girerr::error &e)
|
catch (girerr::error &e)
|
||||||
{
|
{
|
||||||
@ -100,7 +100,8 @@ DokuWiki::impl::impl(const std::string &url, const std::string &username,
|
|||||||
login(username, password);
|
login(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DokuWiki::impl::login(const std::string &username, const std::string &password)
|
void DokuWiki::impl::login(
|
||||||
|
const std::string &username, const std::string &password)
|
||||||
{
|
{
|
||||||
if (executeCommand<bool>("dokuwiki.login", {username, password}) == false)
|
if (executeCommand<bool>("dokuwiki.login", {username, password}) == false)
|
||||||
{
|
{
|
||||||
@ -137,12 +138,9 @@ DokuWiki::PageInfo DokuWiki::impl::getPageInfo(const std::string &pageName)
|
|||||||
|
|
||||||
std::time_t modificationTime = xmlrpc_c::value_int(values["version"]);
|
std::time_t modificationTime = xmlrpc_c::value_int(values["version"]);
|
||||||
|
|
||||||
DokuWiki::PageInfo pageInfo =
|
DokuWiki::PageInfo pageInfo = {xmlrpc_c::value_string(values["name"]),
|
||||||
{
|
|
||||||
xmlrpc_c::value_string(values["name"]),
|
|
||||||
xmlrpc_c::value_string(values["author"]),
|
xmlrpc_c::value_string(values["author"]),
|
||||||
std::asctime(std::localtime(&modificationTime))
|
std::asctime(std::localtime(&modificationTime))};
|
||||||
};
|
|
||||||
|
|
||||||
return pageInfo;
|
return pageInfo;
|
||||||
}
|
}
|
||||||
@ -160,7 +158,8 @@ bool DokuWiki::impl::pageExists(const std::string &pageName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DokuWiki::impl::putPage(const std::string &pageName, const std::string &content)
|
void DokuWiki::impl::putPage(
|
||||||
|
const std::string &pageName, const std::string &content)
|
||||||
{
|
{
|
||||||
if (!executeCommand<bool>("wiki.putPage", {pageName, content},
|
if (!executeCommand<bool>("wiki.putPage", {pageName, content},
|
||||||
{{"sum", xmlrpc_c::value_string("Added automatically")},
|
{{"sum", xmlrpc_c::value_string("Added automatically")},
|
||||||
@ -170,7 +169,8 @@ void DokuWiki::impl::putPage(const std::string &pageName, const std::string &con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DokuWiki::impl::addPage(const std::string &pageName, const std::string &content)
|
void DokuWiki::impl::addPage(
|
||||||
|
const std::string &pageName, const std::string &content)
|
||||||
{
|
{
|
||||||
if (pageExists(pageName))
|
if (pageExists(pageName))
|
||||||
{
|
{
|
||||||
@ -180,7 +180,8 @@ void DokuWiki::impl::addPage(const std::string &pageName, const std::string &con
|
|||||||
putPage(pageName, content);
|
putPage(pageName, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DokuWiki::impl::appendToPage(const std::string &pageName, const std::string &content)
|
void DokuWiki::impl::appendToPage(
|
||||||
|
const std::string &pageName, const std::string &content)
|
||||||
{
|
{
|
||||||
if (!executeCommand<bool>("dokuwiki.appendPage", {pageName, content},
|
if (!executeCommand<bool>("dokuwiki.appendPage", {pageName, content},
|
||||||
{{"sum", xmlrpc_c::value_string("Added automatically")},
|
{{"sum", xmlrpc_c::value_string("Added automatically")},
|
||||||
@ -189,4 +190,3 @@ void DokuWiki::impl::appendToPage(const std::string &pageName, const std::string
|
|||||||
throw std::runtime_error("failed to append to page");
|
throw std::runtime_error("failed to append to page");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ class DokuWiki::impl
|
|||||||
xmlrpc_c::clientXmlTransport_curl m_clientTransport;
|
xmlrpc_c::clientXmlTransport_curl m_clientTransport;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
impl(const std::string &url, const std::string &username, const std::string &password);
|
impl(const std::string &url, const std::string &username,
|
||||||
|
const std::string &password);
|
||||||
|
|
||||||
void login(const std::string &username, const std::string &password);
|
void login(const std::string &username, const std::string &password);
|
||||||
std::string getVersion();
|
std::string getVersion();
|
||||||
@ -35,4 +36,3 @@ class DokuWiki::impl
|
|||||||
const std::list<std::string> ¶ms = {},
|
const std::list<std::string> ¶ms = {},
|
||||||
const std::map<std::string, xmlrpc_c::value> &attributes = {});
|
const std::map<std::string, xmlrpc_c::value> &attributes = {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user