diff options
author | deva <deva> | 2008-08-15 09:37:36 +0000 |
---|---|---|
committer | deva <deva> | 2008-08-15 09:37:36 +0000 |
commit | 5ccdf6dd987be086a8712a4960f770122b1b499b (patch) | |
tree | 7999dd2a4b9e4e3aaccf3493cd7826528ddd1c01 /server/src/transactionparser.cc | |
parent | b7be78948cad7629427fd19769ddcfdfea3fb666 (diff) |
Changes for read-loop-server.
Diffstat (limited to 'server/src/transactionparser.cc')
-rw-r--r-- | server/src/transactionparser.cc | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc index 0e64944..3d3024c 100644 --- a/server/src/transactionparser.cc +++ b/server/src/transactionparser.cc @@ -33,13 +33,16 @@ #include <string> #include <map> -TransactionParser::TransactionParser(TCPSocket &socket, Transaction &transaction) +TransactionParser::TransactionParser(Transaction *transaction) { - this->transaction = &transaction; - this->socket = &socket; + this->transaction = transaction; done = false; } +TransactionParser::~TransactionParser() +{ +} + void TransactionParser::startTag(std::string name, std::map< std::string, std::string> attributes) { if(name == "pracro") { @@ -74,8 +77,39 @@ void TransactionParser::endTag(std::string name) int TransactionParser::readData(char *data, size_t size) { + printf("readData is not uasble with transaction parser!.\nUse parse(std::string) instead.\n"); + return 0; +/* if(done) return 0; - return socket->read(data, size); + + int ret; + + // while((ret = socket->read(data, size, 1000)) == 0) { } + + if(ret == -1) { + printf("Transaction parser was interrupted.\n"); + return 0; + } + + return ret; +*/ +} + +bool TransactionParser::parse(std::string data) +{ + if(! XML_Parse(p, (char*)data.c_str(), data.size(), false) ) { + parseError((char*)data.c_str(), data.size(), XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p)); + return false; + } + + if(done) { + if(! XML_Parse(p, "", 0, true) ) { + parseError("", 0, XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p)); + return false; + } + } + + return done; } void TransactionParser::parseError(char *buf, size_t len, std::string error, int lineno) |