summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-02 21:13:54 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-02 21:13:54 +0100
commitefe31dfb0ff6b75fa00bd65da592d7c400b01ddb (patch)
tree0a990652e43c621849f973dd0450583c59db066c
parentDelete couchSession for being a mess... and using couchdb (diff)
downloadproject2-efe31dfb0ff6b75fa00bd65da592d7c400b01ddb.tar.bz2
project2-efe31dfb0ff6b75fa00bd65da592d7c400b01ddb.tar.xz
project2-efe31dfb0ff6b75fa00bd65da592d7c400b01ddb.zip
Use libadhocutilproject2-1.1.5
-rw-r--r--project2/Jamfile.jam4
-rw-r--r--project2/basics/Jamfile.jam2
-rw-r--r--project2/basics/caches/memoryCache.cpp2
-rw-r--r--project2/basics/tasks/iterate.cpp1
-rw-r--r--project2/basics/views/autotree.cpp2
-rw-r--r--project2/basics/views/flatView.cpp2
-rw-r--r--project2/basics/views/rowView.cpp9
-rw-r--r--project2/basics/views/singleton.cpp4
-rw-r--r--project2/cgi/FCgiIO.cpp2
-rw-r--r--project2/cgi/Jamfile.jam7
-rw-r--r--project2/cgi/cgiAppEngine.cpp8
-rw-r--r--project2/cgi/cgiAppEngine.h2
-rw-r--r--project2/cgi/cgiProgRouter.cpp2
-rw-r--r--project2/cgi/cgiRequestContext.h4
-rw-r--r--project2/cgi/cgiRequestID.cpp4
-rw-r--r--project2/cgi/cgiStagePresent.cpp2
-rw-r--r--project2/cgi/testCgi.cpp4
-rw-r--r--project2/cli/Jamfile.jam1
-rw-r--r--project2/common/Jamfile.jam7
-rw-r--r--project2/common/commonObjects.cpp4
-rw-r--r--project2/common/iHaveParameters.cpp2
-rw-r--r--project2/common/instanceStore.h4
-rw-r--r--project2/common/logger.h4
-rw-r--r--project2/common/rowProcessor.cpp6
-rw-r--r--project2/common/rowSet.cpp4
-rw-r--r--project2/common/scriptLoader.cpp1
-rw-r--r--project2/common/session.cpp2
-rw-r--r--project2/common/sourceObject.cpp2
-rw-r--r--project2/common/taskHost.cpp4
-rw-r--r--project2/common/variables/lookup.cpp2
-rw-r--r--project2/compression/Jamfile.jam1
-rw-r--r--project2/console/Jamfile.jam2
-rw-r--r--project2/console/consoleAppEngine.cpp2
-rw-r--r--project2/daemon/Jamfile.jam1
-rw-r--r--project2/daemon/lib/Jamfile.jam1
-rw-r--r--project2/files/Jamfile.jam3
-rw-r--r--project2/files/fileStream.cpp4
-rw-r--r--project2/files/pch.hpp2
-rw-r--r--project2/files/presenterCache.cpp2
-rw-r--r--project2/files/unittests/testConfig.cpp2
-rw-r--r--project2/ice/Jamfile.jam12
-rw-r--r--project2/ice/buildComms.cpp2
-rw-r--r--project2/ice/iceCompile.cpp6
-rw-r--r--project2/ice/iceDaemon.cpp5
-rw-r--r--project2/ice/sliceCompile.cpp4
-rw-r--r--project2/ice/unittests/Jamfile.jam3
-rw-r--r--project2/ice/unittests/testClient.cpp4
-rw-r--r--project2/ice/unittests/testClientCompile.cpp1
-rw-r--r--project2/json/Jamfile.jam4
-rw-r--r--project2/mail/Jamfile.jam1
-rw-r--r--project2/processes/Jamfile.jam3
-rw-r--r--project2/processes/processStream.cpp13
-rw-r--r--project2/regex/Jamfile.jam1
-rw-r--r--project2/sql/Jamfile.jam8
-rw-r--r--project2/sql/mockDatabase.cpp2
-rw-r--r--project2/sql/mockDatasource.cpp2
-rw-r--r--project2/sql/sql-modMySQL.cpp2
-rw-r--r--project2/sql/sql-modODBC.cpp2
-rw-r--r--project2/sql/sql-modPQ.cpp2
-rw-r--r--project2/sql/sql-modSQLite.cpp2
-rw-r--r--project2/sql/sqlBulkLoad.cpp4
-rw-r--r--project2/sql/sqlCache.cpp20
-rw-r--r--project2/sql/sqlMergeTask.cpp12
-rw-r--r--project2/sql/sqlWriter.cpp10
-rw-r--r--project2/sql/sqlWriter.h10
-rw-r--r--project2/sql/tablepatch.cpp15
-rw-r--r--project2/sql/tablepatch.h2
-rw-r--r--project2/sql/unittests/Jamfile.jam2
-rw-r--r--project2/streams/Jamfile.jam3
-rw-r--r--project2/streams/streamNvpRows.cpp1
-rw-r--r--project2/streams/streamRows.cpp1
-rw-r--r--project2/streams/viewStream.cpp4
-rw-r--r--project2/url/Jamfile.jam4
-rw-r--r--project2/url/curlHelper.cpp8
-rw-r--r--project2/url/curlHelper.h5
-rw-r--r--project2/url/downloadToFile.cpp5
-rw-r--r--project2/url/urlStream.cpp1
-rw-r--r--project2/ut/testPresenter.cpp2
-rw-r--r--project2/xml/Jamfile.jam8
-rw-r--r--project2/xml/transformText.cpp13
-rw-r--r--project2/xml/xmlDocumentCache.cpp87
-rw-r--r--project2/xml/xmlDocumentCache.h9
-rw-r--r--project2/xml/xpathRows.cpp3
83 files changed, 168 insertions, 264 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam
index bb983d9..6779ba8 100644
--- a/project2/Jamfile.jam
+++ b/project2/Jamfile.jam
@@ -6,6 +6,8 @@ feature pq : yes no : propagated ;
feature mysql : yes no : propagated ;
feature sqlite : yes no : propagated ;
+lib adhocutil : : : : <include>/usr/include/adhocutil ;
+
alias p2parts : : : :
<library>url//p2url
<library>files//p2files
@@ -19,7 +21,6 @@ alias p2parts : : : :
<library>compression//p2compression
<library>streams//p2streams
<library>basics//p2basics
- <library>lib//p2lib
<odbc>yes:<library>sql//p2sqlmodODBC
<pq>yes:<library>sql//p2sqlmodPQ
<mysql>yes:<library>sql//p2sqlmodMySQL
@@ -45,6 +46,5 @@ build-project files//unittests ;
explicit install ;
package.install install : : finalbin : finallib ;
package.install installheaders : <install-source-root>. : : : [ glob-tree *.h ] ;
-package.install installheadersmisc : : : : [ glob ../libmisc/*.h ] ;
package.install installheadersdb : : : : [ glob ../libdbpp/*.h ] ;
diff --git a/project2/basics/Jamfile.jam b/project2/basics/Jamfile.jam
index c540c68..f8ea872 100644
--- a/project2/basics/Jamfile.jam
+++ b/project2/basics/Jamfile.jam
@@ -8,7 +8,6 @@ lib dl ;
build-project unittests ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
;
@@ -17,7 +16,6 @@ lib p2basics :
[ glob-tree *.cpp : unittests ]
:
<include>.
- <include>../../libmisc
<library>glibmm
<library>dl
<library>boost_filesystem
diff --git a/project2/basics/caches/memoryCache.cpp b/project2/basics/caches/memoryCache.cpp
index 6e5aab6..2bec824 100644
--- a/project2/basics/caches/memoryCache.cpp
+++ b/project2/basics/caches/memoryCache.cpp
@@ -24,7 +24,7 @@ class MemoryCache : public RowSetCache {
return *columns;
}
RowAttribute resolveAttr(const Glib::ustring & attrName) const {
- return boost::bind(&safeMapLookup<AttributeDoesNotExist, AttrMap>, attrs, attrName);
+ return boost::bind(&AdHoc::safeMapLookup<AttributeDoesNotExist, AttrMap>, attrs, attrName);
}
private:
friend class CachedRowSet;
diff --git a/project2/basics/tasks/iterate.cpp b/project2/basics/tasks/iterate.cpp
index ae73cdb..d2a767a 100644
--- a/project2/basics/tasks/iterate.cpp
+++ b/project2/basics/tasks/iterate.cpp
@@ -3,7 +3,6 @@
#include "logger.h"
#include <boost/bind.hpp>
#include "scriptLoader.h"
-#include "scopeObject.h"
DECLARE_LOADER("iterate", Iterate);
diff --git a/project2/basics/views/autotree.cpp b/project2/basics/views/autotree.cpp
index 2f5bb68..48cb643 100644
--- a/project2/basics/views/autotree.cpp
+++ b/project2/basics/views/autotree.cpp
@@ -1,9 +1,7 @@
#include <pch.hpp>
#include "autotree.h"
#include "presenter.h"
-#include "scopeObject.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
#include <boost/bind.hpp>
DECLARE_LOADER("autotree", AutoTree);
diff --git a/project2/basics/views/flatView.cpp b/project2/basics/views/flatView.cpp
index af49d0d..ad13105 100644
--- a/project2/basics/views/flatView.cpp
+++ b/project2/basics/views/flatView.cpp
@@ -1,9 +1,7 @@
#include "pch.hpp"
#include "flatView.h"
#include "presenter.h"
-#include "scopeObject.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
#include <boost/bind.hpp>
DECLARE_LOADER("flatview", FlatView);
diff --git a/project2/basics/views/rowView.cpp b/project2/basics/views/rowView.cpp
index 9727480..8ec5417 100644
--- a/project2/basics/views/rowView.cpp
+++ b/project2/basics/views/rowView.cpp
@@ -1,9 +1,8 @@
#include <pch.hpp>
#include "rowView.h"
#include "presenter.h"
-#include "scopeObject.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include <boost/bind.hpp>
DECLARE_LOADER("view", RowView);
@@ -73,10 +72,10 @@ RowView::execute(const MultiRowSetPresenter * p, ExecContext * ec) const
p->addNewRowSet(rootName(ec));
}
bool rowsFound = false;
- ScopeObject pres(rootName(ec).isNull() ? ScopeObject::Event() : boost::bind(&MultiRowSetPresenter::finishRowSet, p));
+ AdHoc::ScopeExit pres(rootName(ec).isNull() ? AdHoc::ScopeExit::Event() : boost::bind(&MultiRowSetPresenter::finishRowSet, p));
{
p->addNewArray(recordName(ec), true);
- ScopeObject pres(boost::bind(&MultiRowSetPresenter::finishArray, p, true));
+ AdHoc::ScopeExit pres(boost::bind(&MultiRowSetPresenter::finishArray, p, true));
RowProcessor::execute(ec, boost::bind(&RowView::rowReady, this, _1, p, ec, boost::ref(rowsFound)));
}
if (required(ec) && !rowsFound) {
@@ -85,7 +84,7 @@ RowView::execute(const MultiRowSetPresenter * p, ExecContext * ec) const
for (SetAggregateCPtr s : setAggregates) {
p->addNewArray(s->name, false);
- ScopeObject pres(boost::bind(&MultiRowSetPresenter::finishArray, p, false));
+ AdHoc::ScopeExit pres(boost::bind(&MultiRowSetPresenter::finishArray, p, false));
s->onResultValues(boost::bind(&MultiRowSetPresenter::addNamedValue, p, "value", _1));
s->reset();
}
diff --git a/project2/basics/views/singleton.cpp b/project2/basics/views/singleton.cpp
index c67fb12..29b32aa 100644
--- a/project2/basics/views/singleton.cpp
+++ b/project2/basics/views/singleton.cpp
@@ -2,7 +2,7 @@
#include "view.h"
#include "iHaveParameters.h"
#include "presenter.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
class Singleton : public View {
public:
@@ -19,7 +19,7 @@ class Singleton : public View {
void execute(const MultiRowSetPresenter * p, ExecContext * ec) const
{
p->addNewRowSet(rootName(ec));
- ScopeObject pres(boost::bind(&MultiRowSetPresenter::finishRowSet, p));
+ AdHoc::ScopeExit pres(boost::bind(&MultiRowSetPresenter::finishRowSet, p));
for (const Columns::value_type & col : viewColumns) {
p->addNamedValue(col.first, col.second(ec));
}
diff --git a/project2/cgi/FCgiIO.cpp b/project2/cgi/FCgiIO.cpp
index e47b62e..9d26329 100644
--- a/project2/cgi/FCgiIO.cpp
+++ b/project2/cgi/FCgiIO.cpp
@@ -83,7 +83,7 @@ cgicc::FCgiIO::getenv(const char *varName)
std::string
cgicc::FCgiIO::getenv(const std::string & varName) const
{
- return defaultMapFind(fEnv, varName, "");
+ return AdHoc::defaultMapLookup(fEnv, varName, std::string());
}
std::ostream &
diff --git a/project2/cgi/Jamfile.jam b/project2/cgi/Jamfile.jam
index 14b681e..2de7856 100644
--- a/project2/cgi/Jamfile.jam
+++ b/project2/cgi/Jamfile.jam
@@ -9,7 +9,6 @@ lib fcgi++ : : <name>fcgi++ ;
lib gcrypt : : <name>gcrypt ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<library>cgicc
<library>glibmm
<library>../common//p2common
@@ -21,11 +20,10 @@ lib p2cgicommon :
[ glob cgi*.cpp ]
:
<include>.
- <include>../libmisc
<library>cgicc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>boost_filesystem
<library>../xml//p2xml
<library>gcrypt
@@ -39,7 +37,6 @@ exe p2cgi :
p2webCgi.cpp
:
<library>p2cgicommon
- <include>../../libmisc
;
exe p2fcgi :
@@ -49,7 +46,6 @@ exe p2fcgi :
:
<library>p2cgicommon
<library>boost_filesystem
- <include>../../libmisc
;
exe testCgi :
@@ -57,5 +53,4 @@ exe testCgi :
:
<library>p2cgicommon
<library>../cli//p2cli
- <include>../../libmisc
;
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index 53e0c95..c569617 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -8,7 +8,7 @@
#include "cgiRequestContext.h"
#include <boost/bind.hpp>
#include "ostreamWrapper.h"
-#include "scopeObject.h"
+#include "scopeExit.h"
#include "logger.h"
#include <boost/date_time/microsec_time_clock.hpp>
#include <boost/uuid/uuid_io.hpp>
@@ -174,10 +174,10 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const
}
if (TransformSourcePtr ts = currentStage.get<2>()) {
TransformSourcePtr final = finalTransformSource(ts);
- ScopeObject emptyFinal([final] { final->clearTargets(); });
+ AdHoc::ScopeExit emptyFinal([final] { final->clearTargets(); });
boost::shared_ptr<std::fstream> ddd;
ostreamWrapper * osw = NULL;
- ScopeObject removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } });
+ AdHoc::ScopeExit removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } });
if (!dumpdatadoc.empty()) {
ddd = boost::shared_ptr<std::fstream>(new std::fstream(dumpdatadoc.c_str(), std::fstream::trunc | std::fstream::out));
if (ddd->good()) {
@@ -196,7 +196,7 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const
p->flushCache();
}
if (rs->caches.front()->check(0, crc)) {
- ScopeObject emptyFinal([rs] { rs->caches.front()->clearTargets(); });
+ AdHoc::ScopeExit emptyFinal([rs] { rs->caches.front()->clearTargets(); });
rs->caches.front()->addTarget(new CgiResult(header, IO,
rs && rs->outputOptions ? rs->outputOptions->Encoding(crc).as<std::string>() : OutputOptions::encoding), crc, NULL);
rs->caches.front()->doTransforms(crc);
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
index 83b34d5..d964d07 100644
--- a/project2/cgi/cgiAppEngine.h
+++ b/project2/cgi/cgiAppEngine.h
@@ -103,7 +103,7 @@ class CgiApplicationEngine : AppInstance {
virtual HttpHeaderPtr getHeader(CgiRequestContext *) const;
protected:
HttpHeaderPtr header;
- LazyPointer<MultiRowSetPresenter> presenter;
+ AdHoc::LazyPointer<MultiRowSetPresenter> presenter;
};
/// Stage to return previous cached output
diff --git a/project2/cgi/cgiProgRouter.cpp b/project2/cgi/cgiProgRouter.cpp
index 1d69151..3e84637 100644
--- a/project2/cgi/cgiProgRouter.cpp
+++ b/project2/cgi/cgiProgRouter.cpp
@@ -162,7 +162,7 @@ class ProgRouter : public Router {
return false;
}
VariableType routeParameter(const VariableType & vp) const {
- return safeMapLookup<UriElementNotFound>(vars, vp);
+ return AdHoc::safeMapLookup<UriElementNotFound>(vars, vp);
}
unsigned int parameterCount() const {
return vars.size();
diff --git a/project2/cgi/cgiRequestContext.h b/project2/cgi/cgiRequestContext.h
index 9501a20..d79a0e4 100644
--- a/project2/cgi/cgiRequestContext.h
+++ b/project2/cgi/cgiRequestContext.h
@@ -42,14 +42,14 @@ class CgiRequestContext : public ExecContext {
time_t getRequestModifiedSince() const;
std::string getCookieValue(const std::string & name) const;
boost::optional<RangeRequest> getRequestRange() const;
- LazyPointer<Router> router;
+ AdHoc::LazyPointer<Router> router;
boost::posix_time::ptime startTime;
boost::posix_time::ptime endTime;
private:
const CgiEnvInput & cgienv;
- LazyPointer<Session> session;
+ AdHoc::LazyPointer<Session> session;
SessionPtr getSessionInternal() const;
};
diff --git a/project2/cgi/cgiRequestID.cpp b/project2/cgi/cgiRequestID.cpp
index 60baa1e..038fff5 100644
--- a/project2/cgi/cgiRequestID.cpp
+++ b/project2/cgi/cgiRequestID.cpp
@@ -4,7 +4,7 @@
#include <scriptLoader.h>
#include <scriptStorage.h>
#include <gcrypt.h>
-#include <scopeObject.h>
+#include <scopeExit.h>
#include <iomanip>
/// Variable implementation that returns a unique ID for a page request
@@ -19,7 +19,7 @@ class CgiRequestID : public VariableImplDyn {
{
gcry_md_hd_t state;
gcry_md_open(&state, GCRY_MD_SHA1, 0);
- ScopeObject gcryClose([&state] { gcry_md_close(state); });
+ AdHoc::ScopeExit gcryClose([&state] { gcry_md_close(state); });
auto crc = static_cast<const CgiRequestContext *>(ec);
gcryApplyString(state, crc->getRedirectURL());
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index a708bc0..5e33df3 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -35,7 +35,7 @@ CgiApplicationEngine::PresentStage::run(CgiRequestContext * crc)
CgiRequestContext::ETags etags = crc->getRequestETags();
for (const PresenterCachePtr & pc : caches) {
if (pc->check(root->script->modifiedTime(), crc)) {
- if (reqMS >= pc->getModifiedTime() && (etags.empty() || containerContains(etags, pc->getSHA1()))) {
+ if (reqMS >= pc->getModifiedTime() && (etags.empty() || AdHoc::containerContains(etags, pc->getSHA1()))) {
header = HttpHeaderPtr(new Project2HttpHeader("304 Not Modified"));
return NextStage(NULL, this, NULL, NULL);
}
diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp
index 196ecc3..4ab13d1 100644
--- a/project2/cgi/testCgi.cpp
+++ b/project2/cgi/testCgi.cpp
@@ -40,12 +40,12 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {
std::string getenv(const std::string & varName) const
{
StrPtr def(new std::string());
- return *defaultMapFind(optStore(), varName, def);
+ return *AdHoc::defaultMapLookup(optStore(), varName, def);
}
virtual std::string getenv(const char * varName)
{
StrPtr def(new std::string());
- return *defaultMapFind(optStore(), varName, def);
+ return *AdHoc::defaultMapLookup(optStore(), varName, def);
}
void run()
{
diff --git a/project2/cli/Jamfile.jam b/project2/cli/Jamfile.jam
index 28487aa..1fdcd0d 100644
--- a/project2/cli/Jamfile.jam
+++ b/project2/cli/Jamfile.jam
@@ -7,7 +7,6 @@ lib p2cli :
[ glob *.cpp ]
:
<include>.
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
: :
diff --git a/project2/common/Jamfile.jam b/project2/common/Jamfile.jam
index 6514b1e..775d61c 100644
--- a/project2/common/Jamfile.jam
+++ b/project2/common/Jamfile.jam
@@ -10,8 +10,7 @@ lib boost_date_time : : <name>boost_date_time ;
build-project unittests ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>glibmm
;
@@ -25,10 +24,10 @@ lib p2common :
<library>boost_system
<library>boost_filesystem
<library>boost_date_time
- <library>../lib//p2lib
+ <library>..//adhocutil
: :
<include>.
<library>boost_system
- <library>../lib//p2lib
+ <library>..//adhocutil
;
diff --git a/project2/common/commonObjects.cpp b/project2/common/commonObjects.cpp
index a25bb9f..3ffa47f 100644
--- a/project2/common/commonObjects.cpp
+++ b/project2/common/commonObjects.cpp
@@ -29,7 +29,7 @@ CommonObjects::~CommonObjects()
RowSetPtr
CommonObjects::getSource(const std::string & name) const
{
- return safeMapLookup<DataSourceNotFound>(rowSets, name);
+ return AdHoc::safeMapLookup<DataSourceNotFound>(rowSets, name);
}
CommonObjects::DataSources::const_iterator
@@ -38,7 +38,7 @@ CommonObjects::loadDataSource(const std::string & name) const
ScriptReaderPtr dbs = ScriptReader::resolveScript(datasourceRoot, name, true);
dbs->loader.addLoadTarget(dbs->root(), Storer::into<ElementLoader>(&datasources));
dbs->load(NULL, false);
- return safeMapFind<DataSourceNotFound>(datasources, name);
+ return AdHoc::safeMapFind<DataSourceNotFound>(datasources, name);
}
void
diff --git a/project2/common/iHaveParameters.cpp b/project2/common/iHaveParameters.cpp
index cb9241a..b63acb3 100644
--- a/project2/common/iHaveParameters.cpp
+++ b/project2/common/iHaveParameters.cpp
@@ -17,7 +17,7 @@ IHaveParameters::~IHaveParameters()
VariableType
IHaveParameters::getParameter(const Glib::ustring & name, ExecContext * ec) const
{
- return safeMapLookup<ParamNotFound>(parameters, name)(ec);
+ return AdHoc::safeMapLookup<ParamNotFound>(parameters, name)(ec);
}
const IHaveParameters::Parameters &
diff --git a/project2/common/instanceStore.h b/project2/common/instanceStore.h
index fc57be7..4fd4519 100644
--- a/project2/common/instanceStore.h
+++ b/project2/common/instanceStore.h
@@ -31,9 +31,9 @@ class InstanceMap : public InstanceStore<Type, std::map<KeyType, boost::shared_p
static void Add(const KeyType & k, const boost::shared_ptr<Type> & p);
static void Remove(const KeyType &);
- template <class E> static boost::shared_ptr<Type> Get(const KeyType & n)
+ template <class E> static boost::shared_ptr<Type> Get(const KeyType & n)
{
- return safeMapLookup<E>(InstanceStore<Type, Store>::GetAll(), n);
+ return AdHoc::safeMapLookup<E>(InstanceStore<Type, Store>::GetAll(), n);
}
static void OnEach(const boost::function<void(const Value &)> & func);
diff --git a/project2/common/logger.h b/project2/common/logger.h
index 7f6e7a0..d472ac6 100644
--- a/project2/common/logger.h
+++ b/project2/common/logger.h
@@ -9,7 +9,7 @@
#include <boost/format.hpp>
#include "intrusivePtrBase.h"
#include "genLoader.h"
-#include <misc.h>
+#include <buffer.h>
/// Base class for classes providing a logging facility
class LogDriverBase : public virtual IntrusivePtrBase {
@@ -40,7 +40,7 @@ class Log {
template <typename... Args>
void messagebf(int priority, const char * msgfmt, const Args & ... args) const {
if (priority > lowestLevel) return;
- boost::shared_ptr<boost::format> fmt = getFormat(msgfmt);
+ boost::shared_ptr<boost::format> fmt = AdHoc::Buffer::getFormat(msgfmt);
messagebf(priority, *fmt, args...);
}
void vmessagef(int priority, const char * msgfmt, va_list) const;
diff --git a/project2/common/rowProcessor.cpp b/project2/common/rowProcessor.cpp
index 5156f62..acfaec5 100644
--- a/project2/common/rowProcessor.cpp
+++ b/project2/common/rowProcessor.cpp
@@ -2,7 +2,7 @@
#include "rowProcessor.h"
#include "logger.h"
#include "commonObjects.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include <boost/algorithm/string/predicate.hpp>
#include "execContext.h"
@@ -27,7 +27,7 @@ void
RowProcessor::execute(ExecContext * ec, const RowProcessorCallback & cb) const
{
ec->ParametersPush(this);
- ScopeObject _ihp(
+ AdHoc::ScopeExit _ihp(
boost::bind(&ExecContext::ParametersPop, ec),
boost::bind(&RowProcessor::saveCaches, this, ec),
boost::bind((CROE ? &RowProcessor::saveCaches : &RowProcessor::discardCaches), this, ec),
@@ -43,7 +43,7 @@ RowProcessor::execute(ExecContext * ec, const RowProcessorCallback & cb) const
}
Logger()->messagebf(LOG_DEBUG, "Executing from source '%s'", source->name);
if (const SourceObject * so = dynamic_cast<const SourceObject *>(this)) {
- ScopeObject onComplete(boost::bind(&SourceObject::send, so, Complete));
+ AdHoc::ScopeExit onComplete(boost::bind(&SourceObject::send, so, Complete));
}
const auto rowReadyCallback = boost::bind(&RowProcessor::rowReadyInternal, this, _1, cb, ec);
if (IRSE) {
diff --git a/project2/common/rowSet.cpp b/project2/common/rowSet.cpp
index cb7dd31..a050bab 100644
--- a/project2/common/rowSet.cpp
+++ b/project2/common/rowSet.cpp
@@ -1,7 +1,7 @@
#include <pch.hpp>
#include "rowSet.h"
#include "commonObjects.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include "logger.h"
#include "variables.h"
#include <boost/bind.hpp>
@@ -22,7 +22,7 @@ RowState::process(ExecContext * ec, const RowProcessorCallback & rp, bool r)
{
rowNum += 1;
ec->RowValuesPush(this);
- ScopeObject s(boost::bind(&ExecContext::RowValuesPop, ec));
+ AdHoc::ScopeExit s(boost::bind(&ExecContext::RowValuesPop, ec));
rp(this);
if (r) {
reset();
diff --git a/project2/common/scriptLoader.cpp b/project2/common/scriptLoader.cpp
index 56461d9..523a316 100644
--- a/project2/common/scriptLoader.cpp
+++ b/project2/common/scriptLoader.cpp
@@ -1,5 +1,4 @@
#include <pch.hpp>
-#include "scopeObject.h"
#include "scriptLoader.h"
#include "scriptStorage.h"
#include "library.h"
diff --git a/project2/common/session.cpp b/project2/common/session.cpp
index cba5397..716c8b0 100644
--- a/project2/common/session.cpp
+++ b/project2/common/session.cpp
@@ -37,7 +37,7 @@ Session::Empty() const
VariableType
Session::GetValue(const Glib::ustring & name) const
{
- return safeMapLookup<VariableNotFound>(vars, name);
+ return AdHoc::safeMapLookup<VariableNotFound>(vars, name);
}
void
diff --git a/project2/common/sourceObject.cpp b/project2/common/sourceObject.cpp
index 6ddec89..45c7d19 100644
--- a/project2/common/sourceObject.cpp
+++ b/project2/common/sourceObject.cpp
@@ -45,7 +45,7 @@ SourceObject::registerFor(int eventID, const Event & event) const
SourceObject *
SourceObject::findComponent(const std::string & name) const
{
- return safeMapLookup<ComponentNotFound>(script->namedComponents, name);
+ return AdHoc::safeMapLookup<ComponentNotFound>(script->namedComponents, name);
}
INSTANTIATESTORE(std::string, ComponentLoader);
diff --git a/project2/common/taskHost.cpp b/project2/common/taskHost.cpp
index 943e09a..035e701 100644
--- a/project2/common/taskHost.cpp
+++ b/project2/common/taskHost.cpp
@@ -2,7 +2,7 @@
#include "taskHost.h"
#include "noOutputExecute.h"
#include "dataSource.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include "scriptLoader.h"
#include "commonObjects.h"
@@ -29,7 +29,7 @@ void
TaskHost::execute(ExecContext * ec) const
{
loadScriptComponents();
- ScopeObject txHandler(ScopeObject::Event(), boost::bind(&TaskHost::commitAll, this), boost::bind(&TaskHost::rollbackAll, this));
+ AdHoc::ScopeExit txHandler(AdHoc::ScopeExit::Event(), boost::bind(&TaskHost::commitAll, this), boost::bind(&TaskHost::rollbackAll, this));
run(tasks, ec);
}
diff --git a/project2/common/variables/lookup.cpp b/project2/common/variables/lookup.cpp
index c90ce46..42ddff2 100644
--- a/project2/common/variables/lookup.cpp
+++ b/project2/common/variables/lookup.cpp
@@ -46,7 +46,7 @@ class VariableLookup : public VariableImplDyn, public RowProcessor {
for (const Parameters::value_type & p : parameters) {
k.push_back(p.second(ec));
}
- return safeMapLookup<NotFound>(map, k);
+ return AdHoc::safeMapLookup<NotFound>(map, k);
}
private:
void fillCache(ExecContext * ec) const
diff --git a/project2/compression/Jamfile.jam b/project2/compression/Jamfile.jam
index b1715cb..bafb3ab 100644
--- a/project2/compression/Jamfile.jam
+++ b/project2/compression/Jamfile.jam
@@ -8,7 +8,6 @@ lib libz : : <name>z ;
lib p2compression :
[ glob *.cpp ]
:
- <include>../../libmisc
<library>glibmm
<library>libz
<library>../common//p2common
diff --git a/project2/console/Jamfile.jam b/project2/console/Jamfile.jam
index 24d8504..ba37b7d 100644
--- a/project2/console/Jamfile.jam
+++ b/project2/console/Jamfile.jam
@@ -3,7 +3,6 @@ alias glibmm : : : :
<linkflags>"`pkg-config --libs glibmm-2.4`"
;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<library>glibmm
<library>..//p2parts
;
@@ -16,6 +15,5 @@ exe p2console :
<library>../common//p2common
<library>../basics//p2basics
<library>../cli//p2cli
- <include>../../libmisc
;
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp
index 487c1f1..54c9b2f 100644
--- a/project2/console/consoleAppEngine.cpp
+++ b/project2/console/consoleAppEngine.cpp
@@ -99,7 +99,7 @@ ConsoleApplicationEngine::getSession() const
VariableType
ConsoleApplicationEngine::getParameter(const VariableType & key) const
{
- return safeMapLookup<ParamNotFound>(parameters, key);
+ return AdHoc::safeMapLookup<ParamNotFound>(parameters, key);
}
void
diff --git a/project2/daemon/Jamfile.jam b/project2/daemon/Jamfile.jam
index 1a159c3..410882d 100644
--- a/project2/daemon/Jamfile.jam
+++ b/project2/daemon/Jamfile.jam
@@ -11,7 +11,6 @@ exe p2daemon :
<library>..//p2daemonparts
<library>../common//p2common
<library>../cli//p2cli
- <include>../../libmisc
<library>boost_filesystem
;
diff --git a/project2/daemon/lib/Jamfile.jam b/project2/daemon/lib/Jamfile.jam
index c46ff32..6aa3b0f 100644
--- a/project2/daemon/lib/Jamfile.jam
+++ b/project2/daemon/lib/Jamfile.jam
@@ -5,7 +5,6 @@ alias glibmm : : : :
lib p2daemonlib :
[ glob *.cpp ]
:
- <include>../../../libmisc
<library>glibmm
<library>../../common//p2common
: :
diff --git a/project2/files/Jamfile.jam b/project2/files/Jamfile.jam
index 23fd351..bf3b75c 100644
--- a/project2/files/Jamfile.jam
+++ b/project2/files/Jamfile.jam
@@ -17,14 +17,13 @@ lib p2files :
[ glob-tree *.cpp *.ll : unittests bin ]
:
<include>.
- <include>../libmisc
<library>glibmm
<library>boost_filesystem
<library>boost_system
<library>boost_iostreams
<library>gcrypt
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
: :
<include>.
;
diff --git a/project2/files/fileStream.cpp b/project2/files/fileStream.cpp
index 707b37e..62bfa5b 100644
--- a/project2/files/fileStream.cpp
+++ b/project2/files/fileStream.cpp
@@ -1,6 +1,6 @@
#include <pch.hpp>
#include "logger.h"
-#include <scopeObject.h>
+#include <scopeExit.h>
#include "stream.h"
#include "rowProcessor.h"
#include "scriptLoader.h"
@@ -28,7 +28,7 @@ class FileStream : public Stream {
if (!file) {
throw syscall_error(errno);
}
- ScopeObject so([&] { fclose(file); });
+ AdHoc::ScopeExit so([&] { fclose(file); });
while (!feof(file)) {
char buf[BUFSIZ];
size_t len = fread(buf, 1, BUFSIZ, file);
diff --git a/project2/files/pch.hpp b/project2/files/pch.hpp
index 4b9183d..58f05b9 100644
--- a/project2/files/pch.hpp
+++ b/project2/files/pch.hpp
@@ -20,7 +20,7 @@
#include "optionsSource.h"
#include "rowProcessor.h"
#include "rowSet.h"
-#include "scopeObject.h"
+#include "scopeExit.h"
#include "scriptLoader.h"
#include "scripts.h"
#include "scriptStorage.h"
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index 3fbe1f6..1c6cae6 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -96,7 +96,7 @@ class FilePresenterCache : public PresenterCache {
{
Key key = getCacheKey(ec);
try {
- CacheFilePtr f = defaultMapFind(openCaches, key);
+ CacheFilePtr f = AdHoc::defaultMapLookup(openCaches, key);
if (!f) {
f = openCacheFile(key, ec);
}
diff --git a/project2/files/unittests/testConfig.cpp b/project2/files/unittests/testConfig.cpp
index 45fafac..6880824 100644
--- a/project2/files/unittests/testConfig.cpp
+++ b/project2/files/unittests/testConfig.cpp
@@ -22,7 +22,7 @@ class TestConfigConsumer : public ConfigConsumer {
const Glib::ustring & operator()(const Glib::ustring & name, const Glib::ustring & platform) const
{
- return safeMapLookup<NotFound>(options, {name, platform});
+ return AdHoc::safeMapLookup<NotFound>(options, {name, platform});
}
const Options::Option * get(const Glib::ustring &) const override { return NULL; }
mutable OptionsMap options;
diff --git a/project2/ice/Jamfile.jam b/project2/ice/Jamfile.jam
index 22e74b6..42e1c99 100644
--- a/project2/ice/Jamfile.jam
+++ b/project2/ice/Jamfile.jam
@@ -14,8 +14,7 @@ lib slicer : : <name>slicer : : <include>/usr/include/slicer ;
build-project unittests ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>../common//p2common
<library>glibmm
<library>slicer
@@ -24,10 +23,9 @@ cpp-pch pch : pch.hpp :
lib p2iceclient :
pch iceDataSource.cpp iceClient.cpp buildClient.cpp slice2Task.cpp slice2Rows.cpp iceRows.cpp
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>p2ice
<library>dl
<library>Ice
@@ -44,10 +42,9 @@ lib p2iceclient :
lib p2icedaemon :
pch iceDaemon.cpp iceModule.cpp buildDaemon.cpp slice2Daemon.cpp iceViewSerializer.cpp
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>../basics//p2basics
<library>../daemon/lib//p2daemonlib
<library>p2ice
@@ -65,10 +62,9 @@ lib p2icedaemon :
lib p2ice :
pch iceConvert.cpp iceCompile.cpp sliceCompile.cpp buildComms.cpp slice2Common.cpp iceBase.cpp
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>dl
<library>Ice
<library>Slice
diff --git a/project2/ice/buildComms.cpp b/project2/ice/buildComms.cpp
index 3ee548c..5bf80e7 100644
--- a/project2/ice/buildComms.cpp
+++ b/project2/ice/buildComms.cpp
@@ -1,7 +1,7 @@
#include <pch.hpp>
#include "buildComms.h"
#include <logger.h>
-#include <misc.h>
+#include <buffer.h>
#include <boost/filesystem/operations.hpp>
#include <slicer/parser.h>
diff --git a/project2/ice/iceCompile.cpp b/project2/ice/iceCompile.cpp
index a518cde..9eb5cf5 100644
--- a/project2/ice/iceCompile.cpp
+++ b/project2/ice/iceCompile.cpp
@@ -2,7 +2,7 @@
#include "iceCompile.h"
#include <boost/filesystem/operations.hpp>
#include <logger.h>
-#include <misc.h>
+#include <buffer.h>
#include <dlfcn.h>
namespace fs = boost::filesystem;
@@ -102,11 +102,9 @@ IceCompile::Compile(const fs::path & in, const fs::path & out)
if (components == 0) return;
const auto compile = stringbf(
- "%s %s -o %s -x c++ -c -I %s -I %s -I ../libmisc/ -I %s -I %s -I %s -I %s -I %s `pkg-config --cflags glibmm-2.4` %s",
+ "%s %s -o %s -x c++ -c -I %s -I %s -I /usr/include/adhocutil -I %s -I %s -I %s `pkg-config --cflags glibmm-2.4` %s",
cxx, cxxopts, out, tmpdir,
slicerheaderdir,
- headerdir.parent_path() / "libmisc",
- headerdir / "lib",
headerdir / "common",
headerdir / "ice",
headerdir / "daemon" / "lib",
diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp
index 14e7c90..ccd64a0 100644
--- a/project2/ice/iceDaemon.cpp
+++ b/project2/ice/iceDaemon.cpp
@@ -15,7 +15,6 @@
#include <views/flatView.h>
#include <taskHost.h>
#include <execContext.h>
-#include <misc.h>
#include <exceptions.h>
#include "appInstance.h"
@@ -80,7 +79,7 @@ IceDaemon::setup() const
Logger()->messagebf(LOG_DEBUG, " %s starting...", __PRETTY_FUNCTION__);
adapter->activate();
}
-
+
void
IceDaemon::run() const
@@ -125,7 +124,7 @@ class IceCallContext : public ExecContext {
VariableType getParameter(const VariableType & key) const
{
- return safeMapLookup<ParamNotFound>(params, key);
+ return AdHoc::safeMapLookup<ParamNotFound>(params, key);
}
SessionPtr getSession() const
diff --git a/project2/ice/sliceCompile.cpp b/project2/ice/sliceCompile.cpp
index b879965..0544aea 100644
--- a/project2/ice/sliceCompile.cpp
+++ b/project2/ice/sliceCompile.cpp
@@ -1,6 +1,6 @@
#include <pch.hpp>
#include "sliceCompile.h"
-#include <scopeObject.h>
+#include <scopeExit.h>
#include <mutex>
std::mutex slicePreprocessor;
@@ -23,7 +23,7 @@ SliceCompile::build(const boost::filesystem::path & in, FILE * out) const
}
Slice::UnitPtr u = Slice::Unit::createUnit(false, false, false, false);
- ScopeObject uDestroy(boost::bind(&Slice::Unit::destroy, u.get()));
+ AdHoc::ScopeExit uDestroy(boost::bind(&Slice::Unit::destroy, u.get()));
int parseStatus = u->parse(in.string(), cppHandle, false);
diff --git a/project2/ice/unittests/Jamfile.jam b/project2/ice/unittests/Jamfile.jam
index 4c9f94a..fe4ce51 100644
--- a/project2/ice/unittests/Jamfile.jam
+++ b/project2/ice/unittests/Jamfile.jam
@@ -8,8 +8,7 @@ lib unittestc :
<variant>component
<include>..
<include>../../common
- <include>../../lib
- <include>../../../libmisc
+ <include>/usr/include/adhocutil
<library>..//glibmm
: :
<include>.
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp
index 87ec04f..e979f82 100644
--- a/project2/ice/unittests/testClient.cpp
+++ b/project2/ice/unittests/testClient.cpp
@@ -10,7 +10,7 @@
#include <scripts.h>
#include <xmlScriptParser.h>
#include <testScriptHost.h>
-#include <scopeObject.h>
+#include <scopeExit.h>
#include <unittest.h>
#include <unittestComplex.h>
#include <testAppInstance.h>
@@ -125,7 +125,7 @@ commonTests(ExecContext * ec)
adapter->add(dummy, ic->stringToIdentity("testObject"));
adapter->add(dummyComplex, ic->stringToIdentity("testObjectComplex"));
adapter->activate();
- ScopeObject _([&ic]{ ic->destroy(); });
+ AdHoc::ScopeExit _([&ic]{ ic->destroy(); });
BOOST_TEST_CHECKPOINT("Execute test script");
boost::intrusive_ptr<TestScriptHost> sr = new TestScriptHost(r);
diff --git a/project2/ice/unittests/testClientCompile.cpp b/project2/ice/unittests/testClientCompile.cpp
index 5369884..0332da7 100644
--- a/project2/ice/unittests/testClientCompile.cpp
+++ b/project2/ice/unittests/testClientCompile.cpp
@@ -7,7 +7,6 @@
#include <exceptions.h>
#include <scripts.h>
#include <testScriptHost.h>
-#include <scopeObject.h>
#include <testAppInstance.h>
#define XSTR(s) STR(s)
diff --git a/project2/json/Jamfile.jam b/project2/json/Jamfile.jam
index 0f87d50..40cdcba 100644
--- a/project2/json/Jamfile.jam
+++ b/project2/json/Jamfile.jam
@@ -7,7 +7,6 @@ lib boost_date_time : : <name>boost_date_time ;
lib jsonpp ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
;
@@ -15,11 +14,10 @@ lib p2json :
pch [ glob *.cpp ]
:
<include>.
- <include>../libmisc
<library>glibmm
<library>jsonpp
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
<library>../url//p2url
<library>boost_filesystem
<library>boost_date_time
diff --git a/project2/mail/Jamfile.jam b/project2/mail/Jamfile.jam
index 91e507d..b0acf35 100644
--- a/project2/mail/Jamfile.jam
+++ b/project2/mail/Jamfile.jam
@@ -7,7 +7,6 @@ lib esmtp : : <name>esmtp ;
lib p2mail :
sendmailTask.cpp
:
- <include>../../libmisc
<library>glibmm
<library>esmtp
<library>../common//p2common
diff --git a/project2/processes/Jamfile.jam b/project2/processes/Jamfile.jam
index 99f6ffd..97e2ee2 100644
--- a/project2/processes/Jamfile.jam
+++ b/project2/processes/Jamfile.jam
@@ -5,9 +5,8 @@ alias glibmm : : : :
lib p2processes :
[ glob *.cpp ]
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
;
diff --git a/project2/processes/processStream.cpp b/project2/processes/processStream.cpp
index 3067533..a4b5567 100644
--- a/project2/processes/processStream.cpp
+++ b/project2/processes/processStream.cpp
@@ -1,11 +1,10 @@
#include "iHaveParameters.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
+#include <processPipes.h>
#include "scripts.h"
#include "stream.h"
#include <exception>
#include <sys/wait.h>
-#include <misc.h>
SimpleMessageException(SubProcessFailedToStart);
SimpleMessageException(SubProcessFailed);
@@ -28,15 +27,9 @@ class ProcessStream : public Stream, IHaveParameters {
for (const Parameters::value_type & p : parameters) {
callProc.push_back(p.second(ec));
}
- int fds[2];
- popenrw(callProc, fds);
-
- ScopeObject doClose([&] {
- close(fds[0]);
- close(fds[1]);
- });
+ AdHoc::System::ProcessPipes fds(callProc, false, true, false);
char buf[BUFSIZ];
- while (ssize_t r = read(fds[1], buf, BUFSIZ) != 0) {
+ while (ssize_t r = read(fds.fdOut(), buf, BUFSIZ) != 0) {
if (r < 0) {
throw syscall_error(errno);
}
diff --git a/project2/regex/Jamfile.jam b/project2/regex/Jamfile.jam
index 1849b45..4f4eb01 100644
--- a/project2/regex/Jamfile.jam
+++ b/project2/regex/Jamfile.jam
@@ -5,7 +5,6 @@ alias glibmm : : : :
lib p2regex :
[ glob *.cpp ]
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
;
diff --git a/project2/sql/Jamfile.jam b/project2/sql/Jamfile.jam
index 17c0223..4bf1088 100644
--- a/project2/sql/Jamfile.jam
+++ b/project2/sql/Jamfile.jam
@@ -14,7 +14,6 @@ lib p2sqlmodMySQL :
sql-modMySQL.cpp :
<library>../../libmysqlpp//mysqlpp
<library>glibmm
- <include>../../libmisc
<library>../common//p2common
<library>p2sql
: :
@@ -26,7 +25,6 @@ lib p2sqlmodSQLite :
sql-modSQLite.cpp :
<library>../../libsqlitepp//sqlitepp
<library>glibmm
- <include>../../libmisc
<library>../common//p2common
<library>p2sql
<library>boost_filesystem
@@ -39,7 +37,6 @@ lib p2sqlmodODBC :
sql-modODBC.cpp :
<library>../../libodbcpp//odbcpp
<library>glibmm
- <include>../../libmisc
<library>../common//p2common
<library>p2sql
: :
@@ -51,7 +48,6 @@ lib p2sqlmodPQ :
sql-modPQ.cpp :
<library>../../libpqpp//pqpp
<library>glibmm
- <include>../../libmisc
<library>../common//p2common
<library>p2sql
: :
@@ -59,7 +55,6 @@ lib p2sqlmodPQ :
;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<include>../../libdbpp
<library>glibmm
<library>../common//p2common
@@ -76,8 +71,7 @@ lib p2sql :
<library>boost_filesystem
<library>../common//p2common
<library>../basics//p2basics
- <library>../lib//p2lib
- <include>../../libmisc
+ <library>..//adhocutil
<library>fl
: :
<include>.
diff --git a/project2/sql/mockDatabase.cpp b/project2/sql/mockDatabase.cpp
index b73001a..3ad409d 100644
--- a/project2/sql/mockDatabase.cpp
+++ b/project2/sql/mockDatabase.cpp
@@ -1,6 +1,6 @@
#include "mockDatabase.h"
#include "mockDatasource.h"
-#include <misc.h>
+#include <buffer.h>
#include <logger.h>
#include <fstream>
#include <modifycommand.h>
diff --git a/project2/sql/mockDatasource.cpp b/project2/sql/mockDatasource.cpp
index df5d325..6c281e1 100644
--- a/project2/sql/mockDatasource.cpp
+++ b/project2/sql/mockDatasource.cpp
@@ -10,6 +10,6 @@ unsigned int MockConnectionLoader::mocked = 0;
DB::Connection *
MockConnectionLoader::create(const std::string & n) const
{
- return safeMapFind<std::runtime_error>(mocks, n)->second->openConnection();
+ return AdHoc::safeMapFind<std::runtime_error>(mocks, n)->second->openConnection();
}
diff --git a/project2/sql/sql-modMySQL.cpp b/project2/sql/sql-modMySQL.cpp
index 0466cbc..728c9e1 100644
--- a/project2/sql/sql-modMySQL.cpp
+++ b/project2/sql/sql-modMySQL.cpp
@@ -1,7 +1,7 @@
#include "connectionLoader.h"
#include "../libmysqlpp/connection.h"
#include "sql-modMySQL.h"
-#include <misc.h>
+#include <buffer.h>
#include <scripts.h>
#include <logger.h>
#include <fstream>
diff --git a/project2/sql/sql-modODBC.cpp b/project2/sql/sql-modODBC.cpp
index 29d2441..5b9c858 100644
--- a/project2/sql/sql-modODBC.cpp
+++ b/project2/sql/sql-modODBC.cpp
@@ -1,7 +1,7 @@
#include "connectionLoader.h"
#include "../libodbcpp/connection.h"
#include "sql-modODBC.h"
-#include <misc.h>
+#include <buffer.h>
#include <scripts.h>
#include <logger.h>
diff --git a/project2/sql/sql-modPQ.cpp b/project2/sql/sql-modPQ.cpp
index ec2fcf3..84a9411 100644
--- a/project2/sql/sql-modPQ.cpp
+++ b/project2/sql/sql-modPQ.cpp
@@ -1,7 +1,7 @@
#include "connectionLoader.h"
#include "../libpqpp/connection.h"
#include "sql-modPQ.h"
-#include <misc.h>
+#include <buffer.h>
#include <scripts.h>
#include <logger.h>
diff --git a/project2/sql/sql-modSQLite.cpp b/project2/sql/sql-modSQLite.cpp
index ef8e133..2f19302 100644
--- a/project2/sql/sql-modSQLite.cpp
+++ b/project2/sql/sql-modSQLite.cpp
@@ -1,7 +1,7 @@
#include "connectionLoader.h"
#include "../libsqlitepp/connection.h"
#include "sql-modSQLite.h"
-#include <misc.h>
+#include <buffer.h>
#include <scripts.h>
#include <logger.h>
#include <boost/filesystem/operations.hpp>
diff --git a/project2/sql/sqlBulkLoad.cpp b/project2/sql/sqlBulkLoad.cpp
index 813323c..d976997 100644
--- a/project2/sql/sqlBulkLoad.cpp
+++ b/project2/sql/sqlBulkLoad.cpp
@@ -2,7 +2,7 @@
#include "task.h"
#include <commonObjects.h>
#include "rdbmsDataSource.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include "stream.h"
class SqlBulkLoad : public Task {
@@ -27,7 +27,7 @@ class SqlBulkLoad : public Task {
{
auto wdb = db->getWritable();
wdb->beginBulkUpload(targetTable(ec), extras(ec));
- ScopeObject tidy([]{},
+ AdHoc::ScopeExit tidy([]{},
[&]{ wdb->endBulkUpload(NULL); },
[&]{ wdb->endBulkUpload("Stack unwind in progress"); });
stream->runStream(boost::bind(&DB::Connection::bulkUploadData, wdb.get(), _1, _2), ec);
diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp
index 142bf6f..cf33f8e 100644
--- a/project2/sql/sqlCache.cpp
+++ b/project2/sql/sqlCache.cpp
@@ -32,7 +32,7 @@ class SqlCache : public RowSetCache {
db = co->dataSource<RdbmsDataSource>(DataSource);
}
- static void appendKeyCols(Buffer * sql, unsigned int * off, const Glib::ustring & col)
+ static void appendKeyCols(AdHoc::Buffer * sql, unsigned int * off, const Glib::ustring & col)
{
if ((*off)++) {
sql->append(", ");
@@ -40,7 +40,7 @@ class SqlCache : public RowSetCache {
sql->append(col.c_str());
}
- static void appendKeyBinds(Buffer * sql, unsigned int * off)
+ static void appendKeyBinds(AdHoc::Buffer * sql, unsigned int * off)
{
if ((*off)++) {
sql->append(", ");
@@ -48,7 +48,7 @@ class SqlCache : public RowSetCache {
sql->append("?");
}
- static void appendKeyAnds(Buffer * sql, const Glib::ustring & col)
+ static void appendKeyAnds(AdHoc::Buffer * sql, const Glib::ustring & col)
{
sql->appendf(" AND h.%s = ?", col.c_str());
}
@@ -127,7 +127,7 @@ class SqlCache : public RowSetCache {
RowSetCPtr getCachedRowSet(ExecContext * ec, const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps) const
{
- Buffer sql;
+ AdHoc::Buffer sql;
sql.appendf("SELECT r.* \
FROM %s p, %s_%s_%s h LEFT OUTER JOIN %s_%s_%s_rows r \
ON h.p2_cacheid = r.p2_cacheid \
@@ -166,7 +166,7 @@ class SqlCache : public RowSetCache {
cols[name] = value;
}
void finishRow() const {
- Buffer sql;
+ AdHoc::Buffer sql;
sql.appendf("INSERT INTO %s_%s_%s_rows(p2_row", HeaderTable.c_str(), n.c_str(), f.c_str());
for (const Values::value_type & a : attrs) {
sql.appendf(", p2attr_%s", a.first.c_str());
@@ -206,19 +206,19 @@ class SqlCache : public RowSetCache {
RowSetPresenterPtr openFor(ExecContext * ec, const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps)
{
- Buffer sp;
+ AdHoc::Buffer sp;
sp.appendf("SAVEPOINT sp%p", this);
auto con = db->getWritable();
ModifyPtr s = ModifyPtr(con->newModifyCommand(sp));
s->execute();
// Header
- Buffer del;
+ AdHoc::Buffer del;
del.appendf("INSERT INTO %s(p2_time) VALUES(?)", HeaderTable.c_str());
ModifyPtr h = ModifyPtr(con->newModifyCommand(del));
h->bindParamT(0, boost::posix_time::microsec_clock::universal_time());
h->execute();
// Record set header
- Buffer sql;
+ AdHoc::Buffer sql;
sql.appendf("INSERT INTO %s_%s_%s(", HeaderTable.c_str(), n.c_str(), f.c_str());
unsigned int offset = 0;
applyKeys(ec, boost::bind(appendKeyCols, &sql, &offset, _1), ps);
@@ -235,7 +235,7 @@ class SqlCache : public RowSetCache {
void save(ExecContext *, const Glib::ustring & , const Glib::ustring & , const IHaveParameters * )
{
- Buffer sp;
+ AdHoc::Buffer sp;
sp.appendf("RELEASE SAVEPOINT sp%p", this);
auto con = db->getWritable();
ModifyPtr s = ModifyPtr(con->newModifyCommand(sp));
@@ -244,7 +244,7 @@ class SqlCache : public RowSetCache {
void discard(ExecContext *, const Glib::ustring & , const Glib::ustring & , const IHaveParameters * )
{
- Buffer sp;
+ AdHoc::Buffer sp;
sp.appendf("ROLLBACK TO SAVEPOINT sp%p", this);
auto con = db->getWritable();
ModifyPtr s = ModifyPtr(con->newModifyCommand(sp));
diff --git a/project2/sql/sqlMergeTask.cpp b/project2/sql/sqlMergeTask.cpp
index 91bf3e0..b6c504f 100644
--- a/project2/sql/sqlMergeTask.cpp
+++ b/project2/sql/sqlMergeTask.cpp
@@ -6,9 +6,9 @@
#include "exceptions.h"
#include "sqlVariableBinder.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
+#include <scopeExit.h>
#include "execContext.h"
-#include <misc.h>
+#include <buffer.h>
#include <stdio.h>
#include <stdexcept>
#include <boost/algorithm/string/join.hpp>
@@ -145,7 +145,7 @@ SqlMergeTask::execute(ExecContext * ec) const
{
auto savepoint(stringf("sqlmerge_savepoint_%p", this));
destdb->savepoint(savepoint);
- ScopeObject SPHandler(NULL,
+ AdHoc::ScopeExit SPHandler(NULL,
boost::bind(&DB::Connection::releaseSavepoint, destdb.get(), savepoint),
boost::bind(&DB::Connection::rollbackToSavepoint, destdb.get(), savepoint));
createTempTable();
@@ -223,7 +223,7 @@ SqlMergeTask::createTempKey() const
{
if (useView(NULL)) return;
/* Primary key */
- Buffer idx;
+ AdHoc::Buffer idx;
idx.appendf("ALTER TABLE %s ADD CONSTRAINT pk_%s PRIMARY KEY(%s)",
dtablet.c_str(), dtablet.c_str(),
boost::algorithm::join(keys, ", ").c_str());
@@ -244,7 +244,7 @@ SqlMergeTask::createTempKey() const
DB::ModifyCommand *
SqlMergeTask::insertCommand() const
{
- Buffer ins;
+ AdHoc::Buffer ins;
ins.appendf("INSERT INTO %s(", dtablet.c_str());
foreach(Columns::const_iterator, cols, c) {
if (c != cols.begin()) {
@@ -323,7 +323,7 @@ SqlMergeTask::copyToTempTable(ExecContext * ec) const
i->execute(ec);
}
if (sqlCommand) {
- Buffer ins;
+ AdHoc::Buffer ins;
ins.appendf("INSERT INTO %s(", dtablet.c_str());
foreach(Columns::const_iterator, cols, c) {
if (c != cols.begin()) {
diff --git a/project2/sql/sqlWriter.cpp b/project2/sql/sqlWriter.cpp
index f654636..e3f632e 100644
--- a/project2/sql/sqlWriter.cpp
+++ b/project2/sql/sqlWriter.cpp
@@ -49,13 +49,13 @@ DynamicSql::SqlCommand::getSqlFor(const Glib::ustring & f) const
for (const SqlCommand::Filters::value_type & filter : filters) {
filter.second->active = (filter.second->name == f);
}
- Buffer sql;
+ AdHoc::Buffer sql;
writeSql(sql);
return Glib::ustring(sql.str());
}
void
-DynamicSql::SqlCommand::writeSql(Buffer & sql) const
+DynamicSql::SqlCommand::writeSql(AdHoc::Buffer & sql) const
{
for (const SqlWriterPtr & w : writers) {
w->writeSql(sql);
@@ -80,7 +80,7 @@ DynamicSql::SqlFilter::SqlFilter(ScriptNodePtr p) :
}
void
-DynamicSql::SqlFilter::writeSql(Buffer & sql) const
+DynamicSql::SqlFilter::writeSql(AdHoc::Buffer & sql) const
{
if (active) {
for (const SqlWriterPtr & w : writers) {
@@ -105,7 +105,7 @@ DynamicSql::SqlParameter::SqlParameter(ScriptNodePtr n) :
}
void
-DynamicSql::SqlParameter::writeSql(Buffer & sql) const
+DynamicSql::SqlParameter::writeSql(AdHoc::Buffer & sql) const
{
sql.append("?");
}
@@ -122,7 +122,7 @@ DynamicSql::SqlText::SqlText(const Glib::ustring & n) :
}
void
-DynamicSql::SqlText::writeSql(Buffer & sql) const
+DynamicSql::SqlText::writeSql(AdHoc::Buffer & sql) const
{
sql.append(text);
}
diff --git a/project2/sql/sqlWriter.h b/project2/sql/sqlWriter.h
index 33a57fb..7fb9fa0 100644
--- a/project2/sql/sqlWriter.h
+++ b/project2/sql/sqlWriter.h
@@ -18,14 +18,14 @@ namespace DynamicSql {
public:
SqlWriter();
virtual ~SqlWriter();
- virtual void writeSql(Buffer & sql) const = 0;
+ virtual void writeSql(AdHoc::Buffer & sql) const = 0;
virtual void bindParams(ExecContext *, DB::Command *, unsigned int & offset) const = 0;
};
class SqlText : public SqlWriter {
public:
SqlText(const Glib::ustring &);
- virtual void writeSql(Buffer & sql) const;
+ virtual void writeSql(AdHoc::Buffer & sql) const;
virtual void bindParams(ExecContext *, DB::Command *, unsigned int & offset) const;
const Glib::ustring text;
@@ -34,14 +34,14 @@ namespace DynamicSql {
class SqlParameter : public SqlWriter, Variable {
public:
SqlParameter(ScriptNodePtr);
- virtual void writeSql(Buffer & sql) const;
+ virtual void writeSql(AdHoc::Buffer & sql) const;
virtual void bindParams(ExecContext *, DB::Command *, unsigned int & offset) const;
};
class SqlFilter : public SqlWriter {
public:
SqlFilter(ScriptNodePtr);
- virtual void writeSql(Buffer & sql) const;
+ virtual void writeSql(AdHoc::Buffer & sql) const;
virtual void bindParams(ExecContext *, DB::Command *, unsigned int & offset) const;
const Glib::ustring name;
@@ -55,7 +55,7 @@ namespace DynamicSql {
class SqlCommand : public SqlWriter {
public:
SqlCommand(ScriptNodePtr);
- virtual void writeSql(Buffer & sql) const;
+ virtual void writeSql(AdHoc::Buffer & sql) const;
virtual void bindParams(ExecContext *, DB::Command *, unsigned int & offset) const;
typedef std::multimap<Glib::ustring, SqlFilterPtr> Filters;
Glib::ustring getSqlFor(const Glib::ustring & f) const;
diff --git a/project2/sql/tablepatch.cpp b/project2/sql/tablepatch.cpp
index f49c4ee..2c634d6 100644
--- a/project2/sql/tablepatch.cpp
+++ b/project2/sql/tablepatch.cpp
@@ -1,10 +1,9 @@
#include <pch.hpp>
#include "tablepatch.h"
#include <stdio.h>
-#include <misc.h>
+#include <buffer.h>
#include <selectcommand.h>
#include <column.h>
-#include <buffer.h>
#include <boost/algorithm/string/join.hpp>
using namespace DB;
@@ -56,7 +55,7 @@ TablePatch::patch(ExecContext * ec, DynamicSql::SqlWriterPtr insteadOfDelete, Dy
void
TablePatch::doDeletes(ExecContext * ec, DynamicSql::SqlWriterPtr insteadOfDelete, DynamicSql::SqlWriterPtr where, DynamicSql::SqlWriterPtr order)
{
- Buffer toDelSql;
+ AdHoc::Buffer toDelSql;
switch (db.bulkDeleteStyle()) {
case BulkDeleteUsingSubSelect:
{
@@ -195,7 +194,7 @@ TablePatch::doUpdates(ExecContext * ec, DynamicSql::SqlWriterPtr where, DynamicS
// -----------------------------------------------------------------
// Build SQL for list of updates to perform ------------------------
// -----------------------------------------------------------------
- Buffer toUpdSel;
+ AdHoc::Buffer toUpdSel;
toUpdSel.append("SELECT ");
foreach (Columns::const_iterator, cols, col) {
if (pk.find(*col) == pk.end()) {
@@ -247,7 +246,7 @@ TablePatch::doUpdates(ExecContext * ec, DynamicSql::SqlWriterPtr where, DynamicS
// -----------------------------------------------------------------
// Build SQL to perform updates ------------------------------------
// -----------------------------------------------------------------
- Buffer updSql;
+ AdHoc::Buffer updSql;
updSql.appendf("UPDATE %s SET ",
dest.c_str());
first = true;
@@ -300,7 +299,7 @@ TablePatch::doUpdates(ExecContext * ec, DynamicSql::SqlWriterPtr where, DynamicS
// -----------------------------------------------------------------
// Build SQL for list of updates to perform ------------------------
// -----------------------------------------------------------------
- Buffer updSql;
+ AdHoc::Buffer updSql;
updSql.appendf("UPDATE %s a SET ",
dest.c_str());
bool first = true;
@@ -370,7 +369,7 @@ TablePatch::doUpdates(ExecContext * ec, DynamicSql::SqlWriterPtr where, DynamicS
// -----------------------------------------------------------------
// Build SQL for list of updates to perform ------------------------
// -----------------------------------------------------------------
- Buffer updSql;
+ AdHoc::Buffer updSql;
updSql.appendf("UPDATE %s a, %s b SET ",
dest.c_str(), src.c_str());
bool first = true;
@@ -442,7 +441,7 @@ TablePatch::doInserts(ExecContext * ec, DynamicSql::SqlWriterPtr order)
// -----------------------------------------------------------------
// Build SQL for copying new records -------------------------------
// -----------------------------------------------------------------
- Buffer toInsSql;
+ AdHoc::Buffer toInsSql;
toInsSql.appendf("INSERT INTO %s",
dest.c_str());
foreach (Columns::const_iterator, cols, col) {
diff --git a/project2/sql/tablepatch.h b/project2/sql/tablepatch.h
index df574bf..f08e543 100644
--- a/project2/sql/tablepatch.h
+++ b/project2/sql/tablepatch.h
@@ -10,6 +10,8 @@
#include <buffer.h>
#include "sqlWriter.h"
+#define foreach(_type, _con, _it) for (_type _it = ((_con).begin()); _it != ((_con).end()); _it++)
+
class TablePatch {
public:
typedef std::string Table;
diff --git a/project2/sql/unittests/Jamfile.jam b/project2/sql/unittests/Jamfile.jam
index 8fb6918..d59a62e 100644
--- a/project2/sql/unittests/Jamfile.jam
+++ b/project2/sql/unittests/Jamfile.jam
@@ -18,7 +18,7 @@ lib sqlTestCore :
<library>../../common//p2common
<library>../../basics//p2basics
<library>../../ut//p2ut
- <library>../../lib//p2lib
+ <library>../..//adhocutil
<library>../../xml//p2xml
<library>..//p2sql
<library>boost_system
diff --git a/project2/streams/Jamfile.jam b/project2/streams/Jamfile.jam
index 530fac1..1941f55 100644
--- a/project2/streams/Jamfile.jam
+++ b/project2/streams/Jamfile.jam
@@ -6,9 +6,8 @@ alias glibmm : : : :
lib p2streams :
[ glob *.cpp ]
:
- <include>../../libmisc
<library>glibmm
<library>../common//p2common
- <library>../lib//p2lib
+ <library>..//adhocutil
;
diff --git a/project2/streams/streamNvpRows.cpp b/project2/streams/streamNvpRows.cpp
index 8bc5b87..2e97a5f 100644
--- a/project2/streams/streamNvpRows.cpp
+++ b/project2/streams/streamNvpRows.cpp
@@ -1,6 +1,5 @@
#include <pch.hpp>
#include "variables.h"
-#include "scopeObject.h"
#include "stream.h"
#include "definedColumns.h"
#include "rowProcessor.h"
diff --git a/project2/streams/streamRows.cpp b/project2/streams/streamRows.cpp
index 1b9063f..c8f7ee1 100644
--- a/project2/streams/streamRows.cpp
+++ b/project2/streams/streamRows.cpp
@@ -1,6 +1,5 @@
#include <pch.hpp>
#include "variables.h"
-#include "scopeObject.h"
#include "stream.h"
#include "definedColumns.h"
#include "rowProcessor.h"
diff --git a/project2/streams/viewStream.cpp b/project2/streams/viewStream.cpp
index 29917f6..17763ab 100644
--- a/project2/streams/viewStream.cpp
+++ b/project2/streams/viewStream.cpp
@@ -1,6 +1,6 @@
#include "scriptLoader.h"
#include "stream.h"
-#include <scopeObject.h>
+#include <scopeExit.h>
#include "ostreamWrapper.h"
#include "viewHost.h"
#include <boost/iostreams/stream.hpp>
@@ -37,7 +37,7 @@ class ViewStream : public Stream, public ViewHost {
ostreamWrapper * o = new ostreamWrapper(strm);
executeViews(ec);
t->addTarget(o, ec, NULL);
- ScopeObject remove([&t] { t->clearTargets(); });
+ AdHoc::ScopeExit remove([&t] { t->clearTargets(); });
doTransforms(ec);
}
}
diff --git a/project2/url/Jamfile.jam b/project2/url/Jamfile.jam
index b35eb03..aa55a78 100644
--- a/project2/url/Jamfile.jam
+++ b/project2/url/Jamfile.jam
@@ -6,11 +6,9 @@ lib curl : : <name>curl ;
lib p2url :
[ glob *.cpp ]
- ../../libmisc/curlsup.cpp
:
<library>../common//p2common
- <library>../lib//p2lib
- <include>../../libmisc
+ <library>..//adhocutil
<library>glibmm
<library>curl
: :
diff --git a/project2/url/curlHelper.cpp b/project2/url/curlHelper.cpp
index 2988be9..3e62c6e 100644
--- a/project2/url/curlHelper.cpp
+++ b/project2/url/curlHelper.cpp
@@ -22,6 +22,11 @@ CurlHelper::CurlHelper()
{
}
+Curl::Curl(const std::string & url) :
+ CurlHandle(url)
+{
+}
+
CurlHelper::~CurlHelper()
{
}
@@ -41,10 +46,9 @@ Curl::curlSendHelperHandle(char * ptr, size_t size, size_t nmemb, void *stream)
CurlPtr
CurlHelper::newCurl(ExecContext * ec) const
{
- CurlPtr c = new Curl();
+ CurlPtr c = new Curl(getUrl(ec));
c->setopt(CURLOPT_FOLLOWLOCATION, 1);
c->setopt(CURLOPT_ENCODING, "deflate, gzip");
- c->setopt(CURLOPT_URL, getUrl(ec).c_str());
c->setopt(CURLOPT_FAILONERROR, 1);
return c;
}
diff --git a/project2/url/curlHelper.h b/project2/url/curlHelper.h
index 76ac48f..d45e415 100644
--- a/project2/url/curlHelper.h
+++ b/project2/url/curlHelper.h
@@ -2,10 +2,11 @@
#define CURLHELPER_H
#include "variables.h"
-#include <curlsup.h>
+#include <curlHandle.h>
-class Curl : public CurlHandle {
+class Curl : public AdHoc::Net::CurlHandle {
public:
+ Curl(const std::string & url);
virtual ~Curl() { }
typedef boost::function2<size_t, const char *, size_t> ReadHandler;
diff --git a/project2/url/downloadToFile.cpp b/project2/url/downloadToFile.cpp
index 2f6726e..af23112 100644
--- a/project2/url/downloadToFile.cpp
+++ b/project2/url/downloadToFile.cpp
@@ -1,9 +1,8 @@
#include "curlHelper.h"
#include "task.h"
-#include <scopeObject.h>
+#include <scopeExit.h>
#include "scriptLoader.h"
#include "exceptions.h"
-#include "../libmisc/curlsup.h"
/// Project2 component to create a row set from the contents of a file accessible via libcurl
class Download : public Task, VariableCurlHelper {
@@ -23,7 +22,7 @@ class Download : public Task, VariableCurlHelper {
if (!file) {
throw syscall_error(errno);
}
- ScopeObject tidy([=]{ fclose(file); });
+ AdHoc::ScopeExit tidy([=]{ fclose(file); });
c->performRead([=](const char * data, size_t len) -> size_t { return fwrite(data, 1, len, file); });
}
diff --git a/project2/url/urlStream.cpp b/project2/url/urlStream.cpp
index d9fa336..e3ee862 100644
--- a/project2/url/urlStream.cpp
+++ b/project2/url/urlStream.cpp
@@ -2,7 +2,6 @@
#include "stream.h"
#include "scriptLoader.h"
#include "scripts.h"
-#include "../libmisc/curlsup.h"
/// Project2 component to create a row set from the contents of a file accessible via libcurl
class UrlStream : public Stream, VariableCurlHelper {
diff --git a/project2/ut/testPresenter.cpp b/project2/ut/testPresenter.cpp
index 2b9c952..f31309c 100644
--- a/project2/ut/testPresenter.cpp
+++ b/project2/ut/testPresenter.cpp
@@ -1,5 +1,5 @@
#include "testPresenter.h"
-#include "misc.h"
+#include <buffer.h>
#include <boost/filesystem/operations.hpp>
#include <boost/test/test_tools.hpp>
#include <fstream>
diff --git a/project2/xml/Jamfile.jam b/project2/xml/Jamfile.jam
index 4a69457..d52bec8 100644
--- a/project2/xml/Jamfile.jam
+++ b/project2/xml/Jamfile.jam
@@ -6,9 +6,10 @@ alias libxslt : : : :
<linkflags>"`pkg-config --libs libexslt`" ;
lib boost_filesystem : : <name>boost_filesystem ;
lib boost_date_time : : <name>boost_date_time ;
+lib Ice ;
+lib IceUtil ;
cpp-pch pch : pch.hpp :
- <include>../../libmisc
<library>libxmlpp
<library>../common//p2common
;
@@ -17,11 +18,12 @@ lib p2xml :
[ glob-tree *.cpp : unittests ]
:
<include>.
- <include>../libmisc
<library>libxmlpp
<library>../common//p2common
<library>../url//p2url
- <library>../lib//p2lib
+ <library>..//adhocutil
+ <library>Ice
+ <library>IceUtil
<library>libxslt
<library>boost_filesystem
<library>boost_date_time
diff --git a/project2/xml/transformText.cpp b/project2/xml/transformText.cpp
index edf8a8b..662674d 100644
--- a/project2/xml/transformText.cpp
+++ b/project2/xml/transformText.cpp
@@ -5,7 +5,7 @@
#include <libxml++/document.h>
#include "transformHtml.h"
#include <sys/wait.h>
-#include <misc.h>
+#include <processPipes.h>
#include <glibmm/convert.h>
TextDocument::TextDocument(ScriptNodePtr s, ObjectSource os) :
@@ -46,7 +46,6 @@ class TransformHtmlToText : public TransformImpl<HtmlDocument, TextDocument> {
{
xmlDoc * doc = const_cast<xmlDoc *>(cdoc->doc);
str->doc.clear();
- int fds[2];
std::vector<std::string> callLynx;
callLynx.push_back("/usr/bin/lynx");
callLynx.push_back("-dump");
@@ -57,20 +56,18 @@ class TransformHtmlToText : public TransformImpl<HtmlDocument, TextDocument> {
callLynx.push_back("-nonumbers");
callLynx.push_back("-nolist");
}
- popenrw(callLynx, fds);
- FILE * lynxIn = fdopen(fds[0], "w");
+ AdHoc::System::ProcessPipes fds(callLynx, true, true, false);
+ FILE * lynxIn = fdopen(fds.fdIn(), "w");
// Fixed encoding as we want the result to go back into a ustring
htmlNodeDumpFileFormat(lynxIn, doc, xmlDocGetRootElement(doc), "utf-8", 0);
fclose(lynxIn);
- close(fds[0]);
char buf[1024];
int r;
- while ((r = read(fds[1], buf, sizeof(buf))) > 0) {
+ while ((r = read(fds.fdOut(), buf, sizeof(buf))) > 0) {
str->doc.append(std::string(buf, r));
}
- close(fds[1]);
int status;
- wait(&status);
+ waitpid(fds.pid(), &status, 0);
if (status != 0) {
throw std::runtime_error("Lynx failed");
}
diff --git a/project2/xml/xmlDocumentCache.cpp b/project2/xml/xmlDocumentCache.cpp
index b0d850d..81833f9 100644
--- a/project2/xml/xmlDocumentCache.cpp
+++ b/project2/xml/xmlDocumentCache.cpp
@@ -5,13 +5,14 @@
#include <logger.h>
#include <libxml/HTMLparser.h>
#include <boost/bind.hpp>
+#include <net.h>
#include "exceptions.h"
#include "curlHelper.h"
#include "safeMapFind.h"
XmlDocumentCache::Documents XmlDocumentCache::documents;
XmlDocumentCache::Queued XmlDocumentCache::queued;
-CurlBulkFetcher XmlDocumentCache::cbf;
+AdHoc::Net::CurlMultiHandle XmlDocumentCache::cbf;
SimpleMessageException(XmlParseError);
SimpleMessageException(DownloadFailed);
@@ -20,87 +21,39 @@ template <class Exception>
static XmlDocumentCache::DocumentPtr helperThrow(const std::string & msg) {
throw Exception(msg);
}
-static XmlDocumentCache::DocumentPtr helperReturnDocument(XmlDocumentCache::DocumentPtr dp) {
- return dp;
+static XmlDocumentCache::DocumentPtr helperReturnDocument(XmlDocumentCache::DomParserPtr dp) {
+ return dp->get_document();
}
-class XmlDocumentCachePopulator : public CurlCompleteCallback {
- public:
- XmlDocumentCachePopulator(CurlPtr ch, const Glib::ustring & u, bool h, bool w, const char * e) :
- CurlCompleteCallback(ch),
- handler(boost::bind(&XmlDocumentCachePopulator::append, this, _1, _2)),
- url(u),
- html(h),
- warnings(w),
- encoding(e ? strdup(e) : NULL)
- {
- ch->setReadHandler(handler);
- }
- ~XmlDocumentCachePopulator()
- {
- free(encoding);
- }
- void call(CurlBulkFetcher *)
- {
- int flags = 0;
- flags |= warnings ? 0 : XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
- xmlDocPtr doc = html ?
- htmlReadMemory(buf.c_str(), buf.length(), url.c_str(), encoding, flags) :
- xmlReadMemory(buf.c_str(), buf.length(), url.c_str(), encoding, flags);
- if (!doc) {
- Logger()->messagebf(LOG_DEBUG, "Download of '%s' succeeded, but parsing failed with error '%s'", url, xmlGetLastError()->message);
- XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url,
- boost::bind(helperThrow<XmlParseError>, std::string(xmlGetLastError()->message))));
- return;
- }
-
- // Dirty hack alert
- // xmlpp doesn't play nicely with HTML documents...
- // sooo ummm, lie and hope it doesn't break something else
- doc->type = XML_DOCUMENT_NODE;
- // end hack
-
- XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url,
- boost::bind(helperReturnDocument, XmlDocumentCache::DocumentPtr(new xmlpp::Document(doc)))));
- Logger()->messagebf(LOG_DEBUG, "Download of '%s' completed, stored", url);
- }
- void error(CurlBulkFetcher *, const char * error)
- {
- Logger()->messagebf(LOG_DEBUG, "Download of '%s' failed with error '%s'", url, error);
- XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url,
- boost::bind(helperThrow<DownloadFailed>, std::string(error))));
- }
- size_t append(const char * c, size_t b)
- {
- buf.append(c, b);
- return b;
- }
-
- Curl::ReadHandler handler;
- std::string buf;
- const Glib::ustring url;
- const bool html;
- const bool warnings;
- char * encoding;
-};
-
XmlDocumentCache::DocumentPtr
XmlDocumentCache::getDocument(const Glib::ustring & url, const char * encoding, ExecContext * ec) const
{
Documents::const_iterator i = documents.find(url);
if (i == documents.end()) {
queue(url, encoding, ec);
- cbf.perform();
+ cbf.performAll();
queued.clear();
}
- return safeMapLookup<DownloadFailed>(documents, url)();
+ return AdHoc::safeMapLookup<DownloadFailed>(documents, url)();
}
void
-XmlDocumentCache::queue(const Glib::ustring & url, const char * encoding, ExecContext * ec) const
+XmlDocumentCache::queue(const Glib::ustring & url, const char *, ExecContext *) const
{
if (queued.find(url) == queued.end()) {
- cbf.curls.insert(new XmlDocumentCachePopulator(newCurl(ec), url, asHtml(ec), withWarnings(ec), encoding));
+ cbf.addCurl(url, [url](std::istream & strm) {
+ try {
+ DomParserPtr doc = DomParserPtr(new xmlpp::DomParser());
+ doc->parse_stream(strm);
+ XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url,
+ boost::bind(helperReturnDocument, doc)));
+ }
+ catch (const AdHoc::Net::CurlException & error) {
+ Logger()->messagebf(LOG_DEBUG, "Download of '%s' failed with error '%s'", url, error.message);
+ XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url,
+ boost::bind(helperThrow<DownloadFailed>, error.message)));
+ }
+ })->setopt(CURLOPT_ENCODING, "deflate, gzip");
queued.insert(url);
}
}
diff --git a/project2/xml/xmlDocumentCache.h b/project2/xml/xmlDocumentCache.h
index a7b7454..fb5a650 100644
--- a/project2/xml/xmlDocumentCache.h
+++ b/project2/xml/xmlDocumentCache.h
@@ -7,11 +7,14 @@
#include <curlHelper.h>
#include <glibmm/ustring.h>
#include <libxml++/document.h>
+#include <libxml++/parsers/domparser.h>
+#include <curlMultiHandle.h>
class XmlDocumentCache {
public:
typedef std::set<Glib::ustring> Queued;
- typedef boost::shared_ptr<xmlpp::Document> DocumentPtr;
+ typedef xmlpp::Document * DocumentPtr;
+ typedef boost::shared_ptr<xmlpp::DomParser> DomParserPtr;
typedef boost::function0<DocumentPtr> ReturnDocument;
typedef std::map<const Glib::ustring, ReturnDocument> Documents;
@@ -20,7 +23,7 @@ class XmlDocumentCache {
static Documents documents;
void queue(const Glib::ustring & url, const char * encoding, ExecContext *) const;
-
+
virtual CurlPtr newCurl(ExecContext *) const = 0;
virtual bool asHtml(ExecContext * ec) const = 0;
virtual bool withWarnings(ExecContext * ec) const = 0;
@@ -29,7 +32,7 @@ class XmlDocumentCache {
DocumentPtr getDocument(const Glib::ustring & url, const char * encoding, ExecContext * ec) const;
private:
- static CurlBulkFetcher cbf;
+ static AdHoc::Net::CurlMultiHandle cbf;
friend class XmlDocumentCachePopulator;
friend class XmlDocumentCacheClearer;
diff --git a/project2/xml/xpathRows.cpp b/project2/xml/xpathRows.cpp
index fab0882..656bbac 100644
--- a/project2/xml/xpathRows.cpp
+++ b/project2/xml/xpathRows.cpp
@@ -8,7 +8,6 @@
#include <boost/lexical_cast.hpp>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-#include "../libmisc/curlsup.h"
DECLARE_LOADER("xpathrows", XPathRows);
@@ -56,7 +55,7 @@ XPathRows::newCurl(ExecContext * ec) const
void
XPathRows::execute(const Glib::ustring & filter, const RowProcessorCallback & rp, ExecContext * ec) const
{
- FilterViewPtr fv = safeMapLookup<FilterNotFound>(fvs, filter);
+ FilterViewPtr fv = AdHoc::safeMapLookup<FilterNotFound>(fvs, filter);
typedef boost::shared_ptr<xmlXPathObject> xmlXPathObjectSPtr;
typedef boost::shared_ptr<xmlXPathContext> xmlXPathContextSPtr;