From 8b7a4ed569eed304c8f2cabf442ac67d660bd52b Mon Sep 17 00:00:00 2001 From: elvez Date: Mon, 28 Aug 2006 22:29:43 +0000 Subject: [PATCH] - Fixed bug in serialization which caused threads to be saved with a "lats-for" field of 0 - Added some comments to the string_to code git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@956 3ecf2c5c-341e-0410-92b4-d18e462d057c --- plugins/xmlsave/src/xml_visitor.cc | 4 ++-- src/backend/string_utils.cc | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/xmlsave/src/xml_visitor.cc b/plugins/xmlsave/src/xml_visitor.cc index 86f3a80..fda6438 100644 --- a/plugins/xmlsave/src/xml_visitor.cc +++ b/plugins/xmlsave/src/xml_visitor.cc @@ -228,8 +228,8 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali Glib::ustring strLastsTime; to_string(obj.get_base_priority(), strPriority); to_string(obj.get_arrival_time(), strArrivalTime); - to_string(obj.get_elapsed_time(), strLastsTime); - // get_elapsed_time() or get_total_cpu_time() ??? + to_string(obj.get_total_cpu_time(), strLastsTime); + xmlNodePtr thread_node = xmlNewChild(parent, NULL, (const xmlChar *) "thread", NULL); xmlNewProp(thread_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str()); xmlNewProp(thread_node, (const xmlChar *) "priority", (const xmlChar *) strPriority.c_str()); diff --git a/src/backend/string_utils.cc b/src/backend/string_utils.cc index 7d35a21..53b78cb 100644 --- a/src/backend/string_utils.cc +++ b/src/backend/string_utils.cc @@ -51,6 +51,8 @@ namespace sgpem if (tokens.size() != 1) throw domain_error(_("too few or too many tokens")); + // use the token, not the string, so whitespaces at the end of the string are + // not considered errors by the last test istringstream iss(tokens[0]); T result; @@ -65,10 +67,10 @@ namespace sgpem throw domain_error(e.what()); } - // disable exceptions, otherwise peek() will throw them! - // how useless!!! + // disable exceptions, otherwise peek() will throw them on eof! iss.exceptions(ios_base::goodbit); + // check if there is still stuff in the stream, there shouldn't if (iss.peek() != istringstream::traits_type::eof()) throw domain_error(_("incorrect number format")); @@ -85,6 +87,8 @@ namespace sgpem if (tokens.size() != 1) throw domain_error(_("too few or too many tokens")); + // use the token, not the string, so whitespaces at the end of the string are + // not considered errors by the last test istringstream iss(tokens[0]); bool value; @@ -99,10 +103,10 @@ namespace sgpem throw domain_error(e.what()); } - // disable exceptions, otherwise peek() will throw them! - // how useless!!! + // disable exceptions, otherwise peek() will throw them on eof! iss.exceptions(ios_base::goodbit); + // check if there is still stuff in the stream, there shouldn't if (iss.peek() != istringstream::traits_type::eof()) throw domain_error(_("incorrect boolean"));