From 12ce38327fba57dcb3dfe873ae8e82f1fb7c53f3 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 29 Mar 2018 21:20:25 +0200 Subject: [PATCH] implemented appendPage --- include/dokuwiki.h | 2 ++ source/dokuwiki.cpp | 4 ++++ source/dokuwiki.impl.cpp | 10 ++++++++++ source/dokuwiki.impl.h | 2 ++ 4 files changed, 18 insertions(+) diff --git a/include/dokuwiki.h b/include/dokuwiki.h index c4026de..cb8d825 100644 --- a/include/dokuwiki.h +++ b/include/dokuwiki.h @@ -29,6 +29,8 @@ class DokuWiki void putPage(const std::string &pageName, const std::string &content); void addPage(const std::string &pageName, const std::string &content); + void appendToPage(const std::string &pageName, const std::string &content); + private: class impl; std::unique_ptr pimpl; diff --git a/source/dokuwiki.cpp b/source/dokuwiki.cpp index 0ae6490..976854d 100644 --- a/source/dokuwiki.cpp +++ b/source/dokuwiki.cpp @@ -52,3 +52,7 @@ void DokuWiki::addPage(const std::string &pageName, const std::string &content) pimpl->addPage(pageName, content); } +void DokuWiki::appendToPage(const std::string &pageName, const std::string &content) +{ + pimpl->appendToPage(pageName, content); +} diff --git a/source/dokuwiki.impl.cpp b/source/dokuwiki.impl.cpp index 6fcae37..c7e0db0 100644 --- a/source/dokuwiki.impl.cpp +++ b/source/dokuwiki.impl.cpp @@ -180,3 +180,13 @@ void DokuWiki::impl::addPage(const std::string &pageName, const std::string &con putPage(pageName, content); } +void DokuWiki::impl::appendToPage(const std::string &pageName, const std::string &content) +{ + if (!executeCommand("dokuwiki.appendPage", { pageName, content }, + {{ "sum", xmlrpc_c::value_string("Added automatically") }, + {"minor", xmlrpc_c::value_boolean(false) }})) + { + throw std::runtime_error("failed to append to page"); + } +} + diff --git a/source/dokuwiki.impl.h b/source/dokuwiki.impl.h index 7ada3b0..bb97445 100644 --- a/source/dokuwiki.impl.h +++ b/source/dokuwiki.impl.h @@ -28,6 +28,8 @@ class DokuWiki::impl void putPage(const std::string &pageName, const std::string &content); void addPage(const std::string &pageName, const std::string &content); + void appendToPage(const std::string &pageName, const std::string &content); + template ReturnType executeCommand(const std::string &command, const std::list ¶ms = {},