summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-14 01:14:00 +0000
committerrandomdan <randomdan@localhost>2011-02-14 01:14:00 +0000
commitb5fcd57728f80701dea806b451c6ce36b1f3d867 (patch)
treef9d0f2319662a98cbc6e5a0fa04d258becd5e8d1
parentMinor tweaks to improve perforamce on PG bulk deletes (diff)
downloadproject2-b5fcd57728f80701dea806b451c6ce36b1f3d867.tar.bz2
project2-b5fcd57728f80701dea806b451c6ce36b1f3d867.tar.xz
project2-b5fcd57728f80701dea806b451c6ce36b1f3d867.zip
Fixes to compile with all gcc warnings as errors
Fixes to keep uuid impl choice entirely within uuid class Fix to collect all text in xslRows Error in unhandled compares Add support for no change check in PQ connector Move dumptask in p2console, soon to be removed Fix variable creation code to set type correctly
-rw-r--r--project2/Jamfile.jam14
-rw-r--r--project2/cgi/FCgiIO.cpp5
-rw-r--r--project2/console/consoleAppEngine.cpp6
-rw-r--r--project2/console/consoleEnvironment.cpp4
-rw-r--r--project2/fileRows.cpp4
-rw-r--r--project2/fileStarGlibIoChannel.cpp2
-rw-r--r--project2/sendmailTask.cpp2
-rw-r--r--project2/sqlCheck.cpp11
-rw-r--r--project2/sqlRows.cpp2
-rw-r--r--project2/urlRows.cpp4
-rw-r--r--project2/uuid.cpp80
-rw-r--r--project2/uuid.h28
-rw-r--r--project2/variables.cpp27
-rw-r--r--project2/xmlPresenter.cpp2
-rw-r--r--project2/xslRows.cpp18
15 files changed, 133 insertions, 76 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam
index 3b8e1e8..53ff5ef 100644
--- a/project2/Jamfile.jam
+++ b/project2/Jamfile.jam
@@ -43,12 +43,13 @@ lib p2uuid :
uuid.cpp
:
<uuid>ossp:<define>OSSP_UUID
+ <uuid>boost:<define>BOOST_UUID
<uuid>ossp:<library>osspuuid
;
lib p2common :
appEngine.cpp dataSource.cpp environment.cpp fileStarGlibIoChannel.cpp iHaveParameters.cpp
- iterate.cpp paramChecker.cpp presenter.cpp rawView.cpp dumpTask.cpp logger.cpp if.cpp
+ iterate.cpp paramChecker.cpp presenter.cpp rawView.cpp logger.cpp if.cpp
sourceObject.cpp task.cpp variables.cpp variableConvert.cpp view.cpp xmlObjectLoader.cpp exceptions.cpp
sessionClearTask.cpp session.cpp sessionSetTask.cpp commonObjects.cpp xmlPresenter.cpp
rowView.cpp rowSet.cpp rowUser.cpp rowProcessor.cpp config.cpp
@@ -97,7 +98,6 @@ lib p2xmlSession :
:
<library>../libmisc//misc
<library>libxmlpp
- <uuid>ossp:<define>OSSP_UUID
: :
<library>p2uuid
;
@@ -148,7 +148,6 @@ lib p2web :
<library>cgicc
<library>glibmm
<library>libxmlpp
- <uuid>ossp:<define>OSSP_UUID
: :
<library>p2parts
<library>p2xmlSession
@@ -158,7 +157,6 @@ exe p2cgi :
cgi/p2webCgi.cpp
:
<library>p2web
- <uuid>ossp:<define>OSSP_UUID
;
exe p2fcgi :
@@ -167,15 +165,17 @@ exe p2fcgi :
fcgi
:
<library>p2web
- <uuid>ossp:<define>OSSP_UUID
;
exe p2console :
- [ glob console/*.cpp ]
+ [ glob dumpTask.cpp console/*.cpp ]
:
<library>p2parts
;
-explicit install ;
+explicit install installp2con installp2cgi installp2fcgi ;
package.install install : : p2console p2cgi p2fcgi ;
+package.install installp2con : : p2console ;
+package.install installp2cgi : : p2cgi ;
+package.install installp2fcgi : : p2fcgi ;
diff --git a/project2/cgi/FCgiIO.cpp b/project2/cgi/FCgiIO.cpp
index 7a3dd09..8d52a77 100644
--- a/project2/cgi/FCgiIO.cpp
+++ b/project2/cgi/FCgiIO.cpp
@@ -52,8 +52,9 @@ cgicc::FCgiIO::FCgiIO(FCGX_Request& request)
}
cgicc::FCgiIO::FCgiIO(const FCgiIO& io)
- : CgiInput(io),
- std::ostream(&fOutBuf),
+ : std::ios(),
+ CgiInput(io),
+ std::ostream(&fOutBuf),
fRequest(io.fRequest),
fErr(&fErrBuf),
fEnv(io.fEnv)
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp
index 43b58c9..bd7c6c6 100644
--- a/project2/console/consoleAppEngine.cpp
+++ b/project2/console/consoleAppEngine.cpp
@@ -110,7 +110,7 @@ ConsoleApplicationEngine::session() const
}
void
-ConsoleApplicationEngine::addAppData(const Presenter * p) const
+ConsoleApplicationEngine::addAppData(const Presenter *) const
{
}
@@ -125,13 +125,13 @@ ConsoleApplicationEngine::ConsolePresenter::~ConsolePresenter()
}
void
-ConsoleApplicationEngine::ConsolePresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const
+ConsoleApplicationEngine::ConsolePresenter::pushSub(const Glib::ustring &, const Glib::ustring &) const
{
indent += 2;
}
void
-ConsoleApplicationEngine::ConsolePresenter::addField(const Glib::ustring & name, const Glib::ustring & ns, const Glib::ustring & value) const
+ConsoleApplicationEngine::ConsolePresenter::addField(const Glib::ustring &, const Glib::ustring &, const Glib::ustring &) const
{
}
diff --git a/project2/console/consoleEnvironment.cpp b/project2/console/consoleEnvironment.cpp
index 1c39dd0..31f9ac9 100644
--- a/project2/console/consoleEnvironment.cpp
+++ b/project2/console/consoleEnvironment.cpp
@@ -47,13 +47,13 @@ ConsoleEnvironment::postinit(const boost::program_options::options_description &
}
Glib::ustring
-ConsoleEnvironment::getParamUri(unsigned int idx) const
+ConsoleEnvironment::getParamUri(unsigned int) const
{
throw std::runtime_error("Not implemented");
}
Glib::ustring
-ConsoleEnvironment::getParamQuery(const std::string & idx) const
+ConsoleEnvironment::getParamQuery(const std::string &) const
{
throw std::runtime_error("Not implemented");
}
diff --git a/project2/fileRows.cpp b/project2/fileRows.cpp
index 315c987..e990f56 100644
--- a/project2/fileRows.cpp
+++ b/project2/fileRows.cpp
@@ -131,13 +131,13 @@ FileRows::getCurrentValue(unsigned int col) const
}
bool
-FileRows::isNull(unsigned int col) const
+FileRows::isNull(unsigned int) const
{
return false;
}
bool
-FileRows::isNull(const Glib::ustring & col) const
+FileRows::isNull(const Glib::ustring &) const
{
return false;
}
diff --git a/project2/fileStarGlibIoChannel.cpp b/project2/fileStarGlibIoChannel.cpp
index bbc6591..3ec26ce 100644
--- a/project2/fileStarGlibIoChannel.cpp
+++ b/project2/fileStarGlibIoChannel.cpp
@@ -27,7 +27,7 @@ FileStarChannel::close_vfunc()
}
Glib::IOStatus
-FileStarChannel::set_flags_vfunc(Glib::IOFlags flags)
+FileStarChannel::set_flags_vfunc(Glib::IOFlags)
{
return Glib::IO_STATUS_NORMAL;
}
diff --git a/project2/sendmailTask.cpp b/project2/sendmailTask.cpp
index 7f1274e..b1e3bb6 100644
--- a/project2/sendmailTask.cpp
+++ b/project2/sendmailTask.cpp
@@ -58,7 +58,7 @@ class BoundaryBegin : public SendMailTask::MailPart {
};
class BoundaryEnd : public SendMailTask::MailPart {
public:
- const char * write(char ** buf, int * len) {
+ const char * write(char **, int * len) {
*len = 19;
return "\r\n--<<divider>>--\r\n";
}
diff --git a/project2/sqlCheck.cpp b/project2/sqlCheck.cpp
index 458aa90..a6e71a1 100644
--- a/project2/sqlCheck.cpp
+++ b/project2/sqlCheck.cpp
@@ -9,6 +9,10 @@
DECLARE_LOADER("sqlcheck", SqlCheck);
+class CantCompareStrings : public std::exception { };
+class CantCompareDateTimes : public std::exception { };
+class CantCompareNulls : public std::exception { };
+
SqlCheck::SqlCheck(const xmlpp::Element * p) :
SourceObject(p),
IHaveParameters(p),
@@ -40,8 +44,10 @@ class HandleDoCompare : public DB::HandleField {
testOp(tO) {
}
void null() {
+ throw CantCompareNulls();
}
- void string(const char * c, size_t l) {
+ void string(const char *, size_t) {
+ throw CantCompareStrings();
}
void integer(int64_t i) {
floatingpoint(i);
@@ -66,7 +72,8 @@ class HandleDoCompare : public DB::HandleField {
retVal = true;
}
}
- void timestamp(const struct tm & t) {
+ void timestamp(const struct tm &) {
+ throw CantCompareDateTimes();
}
bool operator()() const {
return retVal;
diff --git a/project2/sqlRows.cpp b/project2/sqlRows.cpp
index 2a162ab..bb94034 100644
--- a/project2/sqlRows.cpp
+++ b/project2/sqlRows.cpp
@@ -230,7 +230,7 @@ SqlRows::SqlText::writeSql(Glib::ustring & sql) const
}
void
-SqlRows::SqlText::bindParams(const RowProcessor * rp, DB::SelectCommand * cmd, unsigned int & offset) const
+SqlRows::SqlText::bindParams(const RowProcessor *, DB::SelectCommand *, unsigned int &) const
{
}
diff --git a/project2/urlRows.cpp b/project2/urlRows.cpp
index b2c247d..cb97b7f 100644
--- a/project2/urlRows.cpp
+++ b/project2/urlRows.cpp
@@ -63,13 +63,13 @@ UrlRows::getCurrentValue(unsigned int col) const
}
bool
-UrlRows::isNull(unsigned int col) const
+UrlRows::isNull(unsigned int) const
{
return false;
}
bool
-UrlRows::isNull(const Glib::ustring & col) const
+UrlRows::isNull(const Glib::ustring &) const
{
return false;
}
diff --git a/project2/uuid.cpp b/project2/uuid.cpp
index 6b8bd0d..ddc0e50 100644
--- a/project2/uuid.cpp
+++ b/project2/uuid.cpp
@@ -1,99 +1,129 @@
-#include "uuid.h"
-
-#ifdef USINGBOOSTUUID
+#ifdef BOOST_UUID
+# include <boost/version.hpp>
+# if BOOST_VERSION < 104200
+# error "Boost UUIDs required v1.42 or above"
+# else
+# include <boost/uuid/uuid.hpp>
+# endif
#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>
+#define uuid_impl boost::uuids::uuid
+#include "uuid.h"
UUID::UUID()
{
- boost_uuid = boost::uuids::nil_generator()();
+ _uuid = new boost::uuids::uuid(boost::uuids::nil_generator()());
+}
+
+UUID::UUID(const UUID & other)
+{
+ _uuid = new boost::uuids::uuid(*other._uuid);
}
UUID::UUID(const std::string & str)
{
- boost_uuid = boost::lexical_cast<boost::uuids::uuid>(str);
+ _uuid = new boost::uuids::uuid(boost::uuids::string_generator()(str));
}
UUID
UUID::generate_random()
{
UUID u;
- u.boost_uuid = boost::uuids::random_generator()();
+ u._uuid = new boost::uuids::uuid(boost::uuids::random_generator()());
return u;
}
bool
UUID::is_nil() const
{
- return boost_uuid.is_nil();
+ return _uuid->is_nil();
}
std::string
UUID::str() const
{
- return boost::lexical_cast<std::string>(boost_uuid);
+ return boost::lexical_cast<std::string>(*_uuid);
}
-void
+UUID &
UUID::operator=(const std::string & str)
{
- boost_uuid = boost::lexical_cast<boost::uuids::uuid>(str);
-}
-
-bool
-UUID::operator!=(const UUID & other) const
-{
- return boost_uuid != other.boost_uuid;
+ *_uuid = boost::uuids::string_generator()(str);
+ return *this;
}
#endif
-#ifdef USINGOSSPUUID
+#ifdef OSSP_UUID
+# include <ossp/uuid++.hh>
+#define uuid_impl uuid
+#include "uuid.h"
UUID::UUID()
{
+ _uuid = new uuid();
+}
+
+UUID::UUID(const UUID & other)
+{
+ _uuid = new uuid(*other._uuid);
}
UUID::UUID(const std::string & str)
{
- ossp_uuid.import(str.c_str());
+ _uuid = new uuid();
+ _uuid->import(str.c_str());
}
UUID
UUID::generate_random()
{
UUID u;
- u.ossp_uuid.make(UUID_MAKE_V4);
+ u._uuid->make(UUID_MAKE_V4);
return u;
}
bool
UUID::is_nil() const
{
- return ossp_uuid.isnil();
+ return _uuid->isnil();
}
std::string
UUID::str() const
{
- char * s = ossp_uuid.string();
+ char * s = _uuid->string();
std::string r(s);
free(s);
return r;
}
-void
+UUID &
UUID::operator=(const std::string & str)
{
- ossp_uuid.import(str.c_str());
+ _uuid->import(str.c_str());
+ return *this;
+}
+
+#endif
+
+// Shared implementation
+UUID::~UUID()
+{
+ delete _uuid;
}
bool
UUID::operator!=(const UUID & other) const
{
- return ossp_uuid != other.ossp_uuid;
+ return *_uuid != *other._uuid;
}
-#endif
+UUID &
+UUID::operator=(const UUID & other)
+{
+ *_uuid = *other._uuid;
+ return *this;
+}
diff --git a/project2/uuid.h b/project2/uuid.h
index 9f7fbbe..4c60ae5 100644
--- a/project2/uuid.h
+++ b/project2/uuid.h
@@ -2,40 +2,30 @@
#define UUID_H
#include <iostream>
-#include <boost/version.hpp>
-
-#ifdef OSSP_UUID
-# define USINGOSSPUUID
-# include <ossp/uuid++.hh>
-#else
-# if BOOST_VERSION < 104200
-# error "Boost UUIDs required v1.42 or above"
-# else
-# include <boost/uuid/uuid.hpp>
-# define USINGBOOSTUUID
-# endif
+
+#ifndef uuid_impl
+class uuid_impl;
#endif
class UUID {
public:
UUID();
+ ~UUID();
+ UUID(const UUID &);
UUID(const std::string &);
static UUID generate_random();
+ UUID & operator=(const UUID & other);
+ UUID & operator=(const std::string &);
+
bool operator!=(const UUID & other) const;
bool is_nil() const;
- void operator=(const std::string &);
std::string str() const;
private:
-#ifdef USINGBOOSTUUID
- boost::uuids::uuid boost_uuid;
-#endif
-#ifdef USINGOSSPUUID
- mutable uuid ossp_uuid;
-#endif
+ uuid_impl * _uuid;
};
#endif
diff --git a/project2/variables.cpp b/project2/variables.cpp
index c5907ed..29e6353 100644
--- a/project2/variables.cpp
+++ b/project2/variables.cpp
@@ -33,8 +33,27 @@ enum VT_typeID {
};
static
+VT_typeID
+getVariableTypeFromName(const std::string & src)
+{
+ if (src.empty()) return String;
+ if (src == "string") return String;
+ if (src == "stringptr") return StringPtr;
+ if (src == "int") return Int;
+ if (src == "uint") return UInt;
+ if (src == "lint") return LInt;
+ if (src == "luint") return LUInt;
+ if (src == "llint") return LLInt;
+ if (src == "lluint") return LLUInt;
+ if (src == "float") return Float;
+ if (src == "double") return Double;
+ if (src == "datetime") return DateTime;
+ if (src == "datetimeptr") return DateTimePtr;
+ throw UnknownVariableType();
+}
+static
VariableType
-makeVariableType(const Glib::ustring & src, const std::string & type, const VT_typeID format = DefaultType)
+makeVariableType(const Glib::ustring & src, const VT_typeID format = DefaultType)
{
switch (format) {
case DefaultType:
@@ -100,8 +119,8 @@ VariableType::operator=(const VariableType & vt)
class VariableLiteral : public VariableImpl {
public:
- VariableLiteral(const Glib::ustring & src, const std::string & type = std::string()) :
- val(makeVariableType(src, type))
+ VariableLiteral(const Glib::ustring & src, const VT_typeID format = DefaultType) :
+ val(makeVariableType(src, format))
{
}
@@ -356,7 +375,7 @@ Variable::Variable(const xmlpp::Element * e, const Glib::ustring & n, bool requi
else if (source == "config")
var = new VariableConfig(c);
else if (source == "literal" || source.empty())
- var = new VariableLiteral(c->get_attribute_value("value"), c->get_attribute_value("type"));
+ var = new VariableLiteral(c->get_attribute_value("value"), getVariableTypeFromName(c->get_attribute_value("type")));
else
throw UnknownVariableSource();
return;
diff --git a/project2/xmlPresenter.cpp b/project2/xmlPresenter.cpp
index 32d28cb..9cf7a73 100644
--- a/project2/xmlPresenter.cpp
+++ b/project2/xmlPresenter.cpp
@@ -38,7 +38,7 @@ XmlPresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) cons
void
XmlPresenter::addAttr(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const
{
- nodeStack.back()->set_attribute(name, value);
+ nodeStack.back()->set_attribute(name, value, ns);
}
void
diff --git a/project2/xslRows.cpp b/project2/xslRows.cpp
index 3742e93..537a459 100644
--- a/project2/xslRows.cpp
+++ b/project2/xslRows.cpp
@@ -131,11 +131,21 @@ XslRows::execute(const RowProcessor * rp) const
else if (xpathObjI->stringval) {
values[xp.first] = boost::shared_ptr<const Glib::ustring>(new Glib::ustring((const char *)xpathObjI->stringval));
}
- else if (xpathObjI->nodesetval && xpathObjI->nodesetval->nodeNr == 1) {
- if (xpathObjI->nodesetval->nodeTab[0]->children && xpathObjI->nodesetval->nodeTab[0]->children->content) {
- xmlChar * val = xpathObjI->nodesetval->nodeTab[0]->children->content;
- values[xp.first] = boost::shared_ptr<const Glib::ustring>(new Glib::ustring((const char *)val));
+ else if (xpathObjI->nodesetval) {
+ boost::shared_ptr<Glib::ustring> str = boost::shared_ptr<Glib::ustring>(new Glib::ustring());
+ for (int i = 0; i < xpathObjI->nodesetval->nodeNr; i += 1) {
+ xmlNodePtr n = xpathObjI->nodesetval->nodeTab[i];
+ if (n->content) {
+ *str += (const char *)n->content;
+ }
+ for (n = n->children; n; n = n->next) {
+ xmlChar * val = n->content;
+ if (val) {
+ *str += (const char *)val;
+ }
+ }
}
+ values[xp.first] = str;
}
}
rp->rowReady();