summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2008-07-11 06:30:14 +0000
committerjhurst <>2008-07-11 06:30:14 +0000
commit4e35856e1045d356d3fcad1b4db4e40e613847c6 (patch)
tree7a355c41268bb8b58b9a08459aa9d4bf1e91b320 /src
parent3c9d1a2d73ae08274cb0185bc6379ca42db19c3e (diff)
added ostream for log, SAX parser improvements
Diffstat (limited to 'src')
-rwxr-xr-xsrc/KM_log.cpp20
-rwxr-xr-xsrc/KM_log.h5
-rw-r--r--src/KM_xml.cpp14
3 files changed, 34 insertions, 5 deletions
diff --git a/src/KM_log.cpp b/src/KM_log.cpp
index 4778ffc..aa0303b 100755
--- a/src/KM_log.cpp
+++ b/src/KM_log.cpp
@@ -34,6 +34,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
+#include <iostream>
+#include <sstream>
#ifdef KM_WIN32
#define getpid GetCurrentProcessId
@@ -145,6 +147,24 @@ Kumu::StreamLogSink::WriteEntry(const LogEntry& Entry)
//------------------------------------------------------------------------------------------
//
+std::basic_ostream<char, std::char_traits<char> >&
+Kumu::operator<<(std::basic_ostream<char, std::char_traits<char> >& strm, LogEntry const& Entry)
+{
+ std::basic_ostringstream<char, std::char_traits<char> > s;
+ s.copyfmt(strm);
+ s.width(0);
+ std::string buf;
+
+ s << Entry.CreateStringWithOptions(buf, LOG_OPTION_ALL);
+
+ strm << s.str();
+ return strm;
+}
+
+//------------------------------------------------------------------------------------------
+
+
+//
bool
Kumu::LogEntry::TestFilter(i32_t filter) const
{
diff --git a/src/KM_log.h b/src/KM_log.h
index fb8d805..671c072 100755
--- a/src/KM_log.h
+++ b/src/KM_log.h
@@ -38,6 +38,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <KM_util.h>
#include <stdarg.h>
#include <errno.h>
+#include <iosfwd>
#define LOG_MSG_IMPL(t) \
va_list args; \
@@ -135,6 +136,10 @@ namespace Kumu
bool Unarchive(MemIOReader* Reader);
};
+ //
+ std::basic_ostream<char, std::char_traits<char> >&
+ operator<<(std::basic_ostream<char, std::char_traits<char> >& strm, LogEntry const& Entry);
+
typedef ArchivableList<LogEntry> LogEntryList;
diff --git a/src/KM_xml.cpp b/src/KM_xml.cpp
index b7b8c09..4792e9b 100644
--- a/src/KM_xml.cpp
+++ b/src/KM_xml.cpp
@@ -683,6 +683,7 @@ Kumu::XMLElement::ParseString(const std::string& document)
asdcp_init_xml_dom();
+ int errorCount = 0;
SAXParser* parser = new SAXParser();
parser->setDoValidation(true);
parser->setDoNamespaces(true); // optional
@@ -704,25 +705,28 @@ Kumu::XMLElement::ParseString(const std::string& document)
char* message = XMLString::transcode(e.getMessage());
DefaultLogSink().Error("Parser error: %s\n", message);
XMLString::release(&message);
- return false;
+ errorCount++;
}
catch (const SAXParseException& e)
{
char* message = XMLString::transcode(e.getMessage());
DefaultLogSink().Error("Parser error: %s at line %d\n", message, e.getLineNumber());
XMLString::release(&message);
- return false;
+ errorCount++;
}
catch (...)
{
DefaultLogSink().Error("Unexpected XML parser error\n");
- return false;
+ errorCount++;
}
- m_NamespaceOwner = (void*)docHandler->TakeNamespaceMap();
+ if ( errorCount == 0 )
+ m_NamespaceOwner = (void*)docHandler->TakeNamespaceMap();
+
delete parser;
delete docHandler;
- return true;
+
+ return errorCount > 0 ? false : true;
}
//