summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/Jamfile.jam7
-rw-r--r--project2/cgi/cgiAppEngine.cpp6
-rw-r--r--project2/definedColumns.cpp84
-rw-r--r--project2/definedColumns.h50
-rw-r--r--project2/regexCheck.cpp11
-rw-r--r--project2/regexCheck.h2
-rw-r--r--project2/regexRows.cpp47
-rw-r--r--project2/regexRows.h22
-rw-r--r--project2/sqlCheck.cpp1
-rw-r--r--project2/streamRows.cpp79
-rw-r--r--project2/streamRows.h39
11 files changed, 216 insertions, 132 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam
index 1b8c17d..5d7186d 100644
--- a/project2/Jamfile.jam
+++ b/project2/Jamfile.jam
@@ -16,7 +16,6 @@ alias libxslt : : : :
lib dl : : <name>dl ;
lib fcgi : : <name>fcgi ;
lib fcgi++ : : <name>fcgi++ ;
-lib boost_regex : : <name>boost_regex ;
lib boost_system : : <name>boost_system ;
lib boost_filesystem : : <name>boost_filesystem ;
lib boost_date_time : : <name>boost_date_time ;
@@ -60,7 +59,7 @@ lib p2common :
sourceObject.cpp task.cpp variables.cpp variableConvert.cpp view.cpp xmlObjectLoader.cpp exceptions.cpp
sessionClearTask.cpp session.cpp sessionSetTask.cpp commonObjects.cpp xmlPresenter.cpp taskHost.cpp checkHost.cpp
rowView.cpp rowSet.cpp rowUser.cpp rowProcessor.cpp config.cpp fileStrmVarWriter.cpp noOutputExecute.cpp
- transform.cpp transformHtml.cpp transformText.cpp
+ transform.cpp transformHtml.cpp transformText.cpp definedColumns.cpp
../libmisc/buffer.cpp
../libmisc/misc.cpp
:
@@ -111,10 +110,9 @@ lib p2files :
;
lib p2regex :
- regexCheck.cpp
+ regexCheck.cpp regexRows.cpp
:
<include>../libmisc
- <library>boost_regex
<library>libxmlpp
<library>p2common
;
@@ -193,7 +191,6 @@ lib p2web :
<library>p2common
<library>p2uuid
<library>boost_program_options
- <library>boost_regex
<library>boost_filesystem
<library>p2xmlSession
: :
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index f4eb134..ee19331 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -5,11 +5,11 @@
#include "../iterate.h"
#include "../logger.h"
#include <boost/bind.hpp>
-#include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include "../sessionXml.h"
#include "../ostreamWrapper.h"
#include <boost/date_time/microsec_time_clock.hpp>
+#include <glibmm/regex.h>
const std::string SESSIONID = "sessionID";
typedef UUID SIDKey;
@@ -182,8 +182,8 @@ CgiApplicationEngine::session() const
bool
CgiApplicationEngine::checkDomain(const DomainPlatforms::value_type & i) const
{
- const std::string & h = _env->getServerName();
- return boost::regex_match(h.begin(), h.end(), boost::regex(i.first.raw()));
+ Glib::RefPtr<Glib::Regex> reg = Glib::Regex::create(i.first, Glib::REGEX_CASELESS | Glib::REGEX_DOTALL);
+ return reg->match(_env->getServerName());
}
Glib::ustring
diff --git a/project2/definedColumns.cpp b/project2/definedColumns.cpp
new file mode 100644
index 0000000..1361453
--- /dev/null
+++ b/project2/definedColumns.cpp
@@ -0,0 +1,84 @@
+#include "definedColumns.h"
+#include <boost/foreach.hpp>
+#include <libxml++/nodes/textnode.h>
+
+DefinedColumns::DefinedColumns(const xmlpp::Element * p) :
+ RowSet(p)
+{
+ unsigned int colNo = 0;
+ BOOST_FOREACH(const xmlpp::Node * node, p->find("columns/column")) {
+ const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node);
+ if (elem) {
+ columns.insert(Column(colNo++, elem));
+ }
+ }
+}
+
+DefinedColumns::Column::Column(unsigned int i, const Glib::ustring & c) :
+ idx(i),
+ col(c),
+ defValue(VariableType())
+{
+}
+
+DefinedColumns::Column::Column(unsigned int i, const xmlpp::Element * p) :
+ idx(i),
+ col(p->get_child_text()->get_content()),
+ defValue(p, "default", false)
+{
+}
+
+void
+DefinedColumns::Column::operator=(const VariableType & v) const
+{
+ value = v;
+}
+
+const Glib::ustring &
+DefinedColumns::getColumnName(unsigned int col) const
+{
+ Columns::index<byColIdx>::type::iterator i = columns.get<byColIdx>().find(col);
+ if (i != columns.get<byColIdx>().end()) {
+ return i->col;
+ }
+ throw RowSet::FieldOutOfRange(col);
+}
+
+unsigned int
+DefinedColumns::columnCount() const
+{
+ return columns.size();
+}
+
+VariableType
+DefinedColumns::getCurrentValue(unsigned int col) const
+{
+ Columns::index<byColIdx>::type::iterator i = columns.get<byColIdx>().find(col);
+ if (i != columns.get<byColIdx>().end()) {
+ return i->value;
+ }
+ throw RowSet::FieldOutOfRange(col);
+}
+
+bool
+DefinedColumns::isNull(unsigned int col) const
+{
+ return (columns.get<byColIdx>().find(col) == columns.get<byColIdx>().end());
+}
+
+bool
+DefinedColumns::isNull(const Glib::ustring & col) const
+{
+ return (columns.get<byColName>().find(col) == columns.get<byColName>().end());
+}
+
+VariableType
+DefinedColumns::getCurrentValue(const Glib::ustring & col) const
+{
+ Columns::const_iterator i = columns.get<byColName>().find(col);
+ if (i != columns.end()) {
+ return i->value;
+ }
+ throw RowSet::FieldDoesNotExist(col);
+}
+
diff --git a/project2/definedColumns.h b/project2/definedColumns.h
new file mode 100644
index 0000000..d6f2ba3
--- /dev/null
+++ b/project2/definedColumns.h
@@ -0,0 +1,50 @@
+#ifndef DEFINEDCOLUMNS_H
+#define DEFINEDCOLUMNS_H
+
+#include <libxml++/nodes/element.h>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include "variables.h"
+#include "rowSet.h"
+
+class DefinedColumns : public RowSet {
+ public:
+ DefinedColumns(const xmlpp::Element *);
+
+ unsigned int columnCount() const;
+ const Glib::ustring & getColumnName(unsigned int col) const;
+ VariableType getCurrentValue(const Glib::ustring & id) const;
+ VariableType getCurrentValue(unsigned int col) const;
+ bool isNull(unsigned int col) const;
+ bool isNull(const Glib::ustring & id) const;
+
+ protected:
+ class Column {
+ public:
+ Column(unsigned int idx, const Glib::ustring &);
+ Column(unsigned int idx, const xmlpp::Element * p);
+
+ void operator=(const VariableType &) const;
+
+ const unsigned int idx;
+ const Glib::ustring col;
+ mutable VariableType value;
+ const Variable defValue;
+ };
+ struct byColIdx {};
+ struct byColName {};
+ typedef boost::multi_index::multi_index_container<
+ Column,
+ boost::multi_index::indexed_by<
+ boost::multi_index::ordered_unique<
+ boost::multi_index::tag<byColName>, BOOST_MULTI_INDEX_MEMBER(Column, const Glib::ustring, col)>,
+ boost::multi_index::ordered_unique<
+ boost::multi_index::tag<byColIdx>, BOOST_MULTI_INDEX_MEMBER(Column, const unsigned int, idx)>
+ > > Columns;
+ mutable Columns columns;
+};
+
+#endif
+
+
diff --git a/project2/regexCheck.cpp b/project2/regexCheck.cpp
index b8504c8..b88a44c 100644
--- a/project2/regexCheck.cpp
+++ b/project2/regexCheck.cpp
@@ -1,7 +1,7 @@
#include "regexCheck.h"
#include "xmlObjectLoader.h"
#include "commonObjects.h"
-#include <boost/regex.hpp>
+#include <glibmm/regex.h>
DECLARE_LOADER("regexcheck", RegexCheck);
@@ -24,12 +24,7 @@ RegexCheck::loadComplete(const CommonObjects *)
bool
RegexCheck::performCheck() const
{
- return checkString(applyTo());
-}
-
-bool
-RegexCheck::checkString(const Glib::ustring & str) const
-{
- return boost::regex_match(str.begin(), str.end(), boost::regex(regex()));
+ Glib::RefPtr<Glib::Regex> reg = Glib::Regex::create(regex());
+ return reg->match(applyTo());
}
diff --git a/project2/regexCheck.h b/project2/regexCheck.h
index 602f822..17033de 100644
--- a/project2/regexCheck.h
+++ b/project2/regexCheck.h
@@ -15,8 +15,6 @@ class RegexCheck : public ParamChecker {
const Variable applyTo;
const Variable regex;
- private:
- bool checkString(const Glib::ustring & str) const;
};
#endif
diff --git a/project2/regexRows.cpp b/project2/regexRows.cpp
new file mode 100644
index 0000000..b950125
--- /dev/null
+++ b/project2/regexRows.cpp
@@ -0,0 +1,47 @@
+#include "regexRows.h"
+#include "xmlObjectLoader.h"
+#include "rowProcessor.h"
+#include <stdio.h>
+#include <glibmm/regex.h>
+
+DECLARE_LOADER("regexrows", RegexRows);
+
+RegexRows::RegexRows(const xmlpp::Element * p) :
+ DefinedColumns(p),
+ sourceText(p, "sourceText"),
+ regex(p, "regex")
+{
+}
+
+RegexRows::~RegexRows()
+{
+}
+
+void
+RegexRows::loadComplete(const CommonObjects*)
+{
+}
+
+void
+RegexRows::setFilter(const Glib::ustring&)
+{
+}
+
+void
+RegexRows::execute(const RowProcessor * rp) const
+{
+ rowNum = 1;
+ Glib::RefPtr<Glib::Regex> reg = Glib::Regex::create(regex(), Glib::REGEX_CASELESS | Glib::REGEX_DOTALL);
+ Glib::MatchInfo matches;
+ if (reg->match(sourceText(), matches)) {
+ do {
+ unsigned int cols = std::min<unsigned int>(matches.get_match_count(), DefinedColumns::columnCount() + 1);
+ for (unsigned int n = 1; n < cols; n += 1) {
+ *DefinedColumns::columns.get<byColIdx>().find(n - 1) = matches.fetch(n);
+ }
+ rp->rowReady();
+ rowNum += 1;
+ } while (matches.next());
+ }
+}
+
diff --git a/project2/regexRows.h b/project2/regexRows.h
new file mode 100644
index 0000000..b4b6446
--- /dev/null
+++ b/project2/regexRows.h
@@ -0,0 +1,22 @@
+#ifndef REGEXROWS_H
+#define REGEXROWS_H
+
+#include "definedColumns.h"
+#include "variables.h"
+
+/// Base class for Project2 components that create a row set based on the contents of a byte stream
+class RegexRows : public DefinedColumns {
+ public:
+ RegexRows(const xmlpp::Element * p);
+ ~RegexRows();
+ void loadComplete(const CommonObjects*);
+ void setFilter(const Glib::ustring&);
+ void execute(const RowProcessor*) const;
+
+ private:
+ const Variable sourceText;
+ const Variable regex;
+};
+
+#endif
+
diff --git a/project2/sqlCheck.cpp b/project2/sqlCheck.cpp
index c36c229..c89608b 100644
--- a/project2/sqlCheck.cpp
+++ b/project2/sqlCheck.cpp
@@ -3,7 +3,6 @@
#include "selectcommand.h"
#include "column.h"
#include "rdbmsDataSource.h"
-#include <boost/regex.hpp>
#include "commonObjects.h"
#include "sqlVariableBinder.h"
#include <boost/foreach.hpp>
diff --git a/project2/streamRows.cpp b/project2/streamRows.cpp
index 62d0d0f..4cf29e6 100644
--- a/project2/streamRows.cpp
+++ b/project2/streamRows.cpp
@@ -1,10 +1,8 @@
#include "streamRows.h"
#include "rowProcessor.h"
-#include <boost/foreach.hpp>
-#include <libxml++/nodes/textnode.h>
StreamRows::StreamRows(const xmlpp::Element * p) :
- RowSet(p),
+ DefinedColumns(p),
fieldSep(p->get_attribute_value("fieldSep")[0]),
quoteChar(p->get_attribute_value("quoteChar")[0]),
keepBlankRows(p->get_attribute_value("keepBlankRows") == "true"),
@@ -16,13 +14,6 @@ StreamRows::StreamRows(const xmlpp::Element * p) :
inQuotes(false),
prevWasQuote(false)
{
- unsigned int colNo = 0;
- BOOST_FOREACH(const xmlpp::Node * node, p->find("columns/column")) {
- const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node);
- if (elem) {
- columns.insert(Column(colNo++, elem));
- }
- }
mkCols = columns.empty();
}
@@ -30,54 +21,6 @@ StreamRows::~StreamRows()
{
}
-const Glib::ustring &
-StreamRows::getColumnName(unsigned int col) const
-{
- Columns::index<byColIdx>::type::iterator i = columns.get<byColIdx>().find(col);
- if (i != columns.get<byColIdx>().end()) {
- return i->col;
- }
- throw RowSet::FieldOutOfRange(col);
-}
-
-unsigned int
-StreamRows::columnCount() const
-{
- return columns.size();
-}
-
-VariableType
-StreamRows::getCurrentValue(unsigned int col) const
-{
- Columns::index<byColIdx>::type::iterator i = columns.get<byColIdx>().find(col);
- if (i != columns.get<byColIdx>().end()) {
- return i->value;
- }
- throw RowSet::FieldOutOfRange(col);
-}
-
-bool
-StreamRows::isNull(unsigned int col) const
-{
- return (columns.get<byColIdx>().find(col) == columns.get<byColIdx>().end());
-}
-
-bool
-StreamRows::isNull(const Glib::ustring & col) const
-{
- return (columns.get<byColName>().find(col) == columns.get<byColName>().end());
-}
-
-VariableType
-StreamRows::getCurrentValue(const Glib::ustring & col) const
-{
- Columns::const_iterator i = columns.get<byColName>().find(col);
- if (i != columns.end()) {
- return i->value;
- }
- throw RowSet::FieldDoesNotExist(col);
-}
-
void
StreamRows::addColumn(Glib::ustring & tok) const
{
@@ -92,26 +35,6 @@ StreamRows::addColumn(Glib::ustring & tok) const
columns.insert(Column(columns.size(), tok));
}
-StreamRows::Column::Column(unsigned int i, const Glib::ustring & c) :
- idx(i),
- col(c),
- defValue(VariableType())
-{
-}
-
-StreamRows::Column::Column(unsigned int i, const xmlpp::Element * p) :
- idx(i),
- col(p->get_child_text()->get_content()),
- defValue(p, "default", false)
-{
-}
-
-void
-StreamRows::Column::operator=(const VariableType & v) const
-{
- value = v;
-}
-
void
StreamRows::begin() const
{
diff --git a/project2/streamRows.h b/project2/streamRows.h
index 449a44b..338d997 100644
--- a/project2/streamRows.h
+++ b/project2/streamRows.h
@@ -1,25 +1,17 @@
#ifndef STREAMROWS_H
#define STREAMROWS_H
-#include "rowSet.h"
#include "variables.h"
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
+#include "definedColumns.h"
+
+class RowProcessor;
/// Base class for Project2 components that create a row set based on the contents of a byte stream
-class StreamRows : public RowSet {
+class StreamRows : public DefinedColumns {
public:
StreamRows(const xmlpp::Element * p);
~StreamRows();
- unsigned int columnCount() const;
- const Glib::ustring & getColumnName(unsigned int col) const;
- VariableType getCurrentValue(const Glib::ustring & id) const;
- VariableType getCurrentValue(unsigned int col) const;
- bool isNull(unsigned int col) const;
- bool isNull(const Glib::ustring & id) const;
-
protected:
void begin() const;
void pushChar(gunichar ch, const RowProcessor *) const;
@@ -27,29 +19,6 @@ class StreamRows : public RowSet {
private:
void addColumn(Glib::ustring & rawtok) const;
- class Column {
- public:
- Column(unsigned int idx, const Glib::ustring &);
- Column(unsigned int idx, const xmlpp::Element * p);
-
- void operator=(const VariableType &) const;
-
- const unsigned int idx;
- const Glib::ustring col;
- mutable VariableType value;
- const Variable defValue;
- };
- struct byColIdx {};
- struct byColName {};
- typedef boost::multi_index::multi_index_container<
- Column,
- boost::multi_index::indexed_by<
- boost::multi_index::ordered_unique<
- boost::multi_index::tag<byColName>, BOOST_MULTI_INDEX_MEMBER(Column, const Glib::ustring, col)>,
- boost::multi_index::ordered_unique<
- boost::multi_index::tag<byColIdx>, BOOST_MULTI_INDEX_MEMBER(Column, const unsigned int, idx)>
- > > Columns;
- mutable Columns columns;
public:
const gunichar fieldSep;