From 3d60d33280743a750646b8647b77b65df38405d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 30 Dec 2010 22:07:27 +0100 Subject: [PATCH] Added comments --- lib/errorlogger.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 0560c5801..bd558f690 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -31,14 +31,24 @@ ErrorLogger::ErrorMessage::ErrorMessage() ErrorLogger::ErrorMessage::ErrorMessage(const std::list &callStack, Severity::SeverityType severity, const std::string &msg, const std::string &id) { + // locations for this error message _callStack = callStack; + + // severity for this error message _severity = severity; + + // set the summary and verbose messages setmsg(msg); + + // set the message id _id = id; } void ErrorLogger::ErrorMessage::setmsg(const std::string &msg) { + // The summary and verbose message are separated by a newline + // If there is no newline then both the summary and verbose messages + // are the given message const std::string::size_type pos = msg.find("\n"); if (pos == std::string::npos) { @@ -54,6 +64,7 @@ void ErrorLogger::ErrorMessage::setmsg(const std::string &msg) std::string ErrorLogger::ErrorMessage::serialize() const { + // Serialize this message into a simple string std::ostringstream oss; oss << _id.length() << " " << _id; oss << Severity::toString(_severity).length() << " " << Severity::toString(_severity); @@ -135,13 +146,19 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data) std::string ErrorLogger::ErrorMessage::getXMLHeader(int xml_version) { + // xml_version 1 is the default xml format + + // standard xml header std::ostringstream ostr; ostr << "\n"; + // version 1 header if (xml_version <= 1) { ostr << ""; } + + // version 2 header else { ostr << "\n"; @@ -158,6 +175,7 @@ std::string ErrorLogger::ErrorMessage::getXMLFooter() static std::string stringToXml(std::string s) { + // convert a string so it can be save as xml attribute data std::string::size_type pos = 0; while ((pos = s.find_first_of("<>&\"\n", pos)) != std::string::npos) { @@ -179,8 +197,10 @@ static std::string stringToXml(std::string s) std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const { + // Save this ErrorMessage as an XML element std::ostringstream xml; + // The default xml format if (version == 1) { xml << ""; } + + // The xml format you get when you use --xml-version=2 else if (version == 2) { xml << "