[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5398] Add and use functions to manipulate attributes as i
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5398] Add and use functions to manipulate attributes as integers |
Date: |
Sat, 18 Feb 2012 13:07:29 +0000 |
Revision: 5398
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5398
Author: chicares
Date: 2012-02-18 13:07:28 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
Add and use functions to manipulate attributes as integers
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/xml_lmi.cpp
lmi/trunk/xml_lmi.hpp
lmi/trunk/xml_serializable.tpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2012-02-18 07:06:04 UTC (rev 5397)
+++ lmi/trunk/ChangeLog 2012-02-18 13:07:28 UTC (rev 5398)
@@ -29657,3 +29657,31 @@
ihs_avmly.cpp
Apply changes discussed 20120208T2159Z.
+20120217T1802Z <address@hidden> [575]
+
+ ihs_irc7702a.cpp
+Improve a diagnostic message.
+
+20120218T0706Z <address@hidden> [575]
+
+ emit_ledger.cpp
+ group_values.cpp
+ group_values.hpp
+ illustrator.cpp
+ illustrator.hpp
+ main_cgi.cpp
+ mec_server.cpp
+ mec_server.hpp
+ timer.cpp
+ timer.hpp
+ timer_test.cpp
+ vector_test.cpp
+Fix defect introduced 20050605T0355Z: usec confused with sec.
+
+20120218T1307Z <address@hidden> [575]
+
+ xml_lmi.cpp
+ xml_lmi.hpp
+ xml_serializable.tpp
+Add and use functions to manipulate attributes as integers.
+
Modified: lmi/trunk/xml_lmi.cpp
===================================================================
--- lmi/trunk/xml_lmi.cpp 2012-02-18 07:06:04 UTC (rev 5397)
+++ lmi/trunk/xml_lmi.cpp 2012-02-18 13:07:28 UTC (rev 5398)
@@ -30,6 +30,7 @@
#include "alert.hpp"
#include "istream_to_string.hpp"
+#include "value_cast.hpp"
#include <xmlwrapp/attributes.h>
#include <xmlwrapp/document.h>
@@ -356,6 +357,24 @@
}
}
+bool get_attr
+ (xml::element const& element
+ ,std::string const& name
+ ,int& value
+ )
+{
+ std::string s;
+ if(get_attr(element, name, s))
+ {
+ value = value_cast<int>(s);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
void set_attr
(xml::element& element
,std::string const& name
@@ -372,6 +391,15 @@
throw "Unreachable--silences a compiler diagnostic.";
}
}
+
+void set_attr
+ (xml::element& element
+ ,std::string const& name
+ ,int value
+ )
+{
+ set_attr(element, name, value_cast<std::string>(value));
+}
} // namespace xml_lmi
std::ostream& operator<<(std::ostream& os, xml_lmi::xml_document const& d)
Modified: lmi/trunk/xml_lmi.hpp
===================================================================
--- lmi/trunk/xml_lmi.hpp 2012-02-18 07:06:04 UTC (rev 5397)
+++ lmi/trunk/xml_lmi.hpp 2012-02-18 13:07:28 UTC (rev 5398)
@@ -116,6 +116,11 @@
,std::string const& name
,std::string& value
);
+ bool get_attr
+ (xml::element const&
+ ,std::string const& name
+ ,int& value
+ );
/// Set a given attribute of an xml element.
@@ -124,6 +129,11 @@
,std::string const& name
,std::string const& value
);
+ void set_attr
+ (xml::element&
+ ,std::string const& name
+ ,int value
+ );
} // namespace xml_lmi
std::ostream& operator<<(std::ostream&, xml_lmi::xml_document const&);
Modified: lmi/trunk/xml_serializable.tpp
===================================================================
--- lmi/trunk/xml_serializable.tpp 2012-02-18 07:06:04 UTC (rev 5397)
+++ lmi/trunk/xml_serializable.tpp 2012-02-18 13:07:28 UTC (rev 5398)
@@ -29,10 +29,9 @@
#include "xml_serializable.hpp"
#include "alert.hpp"
-#include "any_member.hpp" // MemberSymbolTable<>
+#include "any_member.hpp" // MemberSymbolTable<>
#include "contains.hpp"
-#include "platform_dependent.hpp" // access()
-#include "value_cast.hpp"
+#include "platform_dependent.hpp" // access()
#include "xml_lmi.hpp"
#include <boost/static_assert.hpp>
@@ -40,8 +39,8 @@
#include <xmlwrapp/nodes_view.h>
-#include <algorithm> // std::copy(), std::find()
-#include <iterator> // std::back_inserter
+#include <algorithm> // std::copy(), std::find()
+#include <iterator> // std::back_inserter
#include <sstream>
#include <vector>
@@ -101,13 +100,11 @@
;
}
- std::string file_version_string;
- if(!xml_lmi::get_attr(x, "version", file_version_string))
+ int file_version = 0;
+ if(!xml_lmi::get_attr(x, "version", file_version))
{
handle_missing_version_attribute();
- file_version_string = "0";
}
- int file_version = value_cast<int>(file_version_string);
// COMPILER !! Borland doesn't find operator==() in ns xml.
#ifdef __BORLANDC__
@@ -198,9 +195,7 @@
template<typename T>
void xml_serializable<T>::immit_members_into(xml::element& root) const
{
-// XMLWRAPP !! There's no way to set an integer attribute.
- std::string const version(value_cast<std::string>(class_version()));
- xml_lmi::set_attr(root, "version", version.c_str());
+ xml_lmi::set_attr(root, "version", class_version());
std::vector<std::string>::const_iterator i;
for(i = t().member_names().begin(); i != t().member_names().end(); ++i)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5398] Add and use functions to manipulate attributes as integers,
Greg Chicares <=