Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53750 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2009-06-08 10:16:06


Author: jewillco
Date: 2009-06-08 10:16:06 EDT (Mon, 08 Jun 2009)
New Revision: 53750
URL: http://svn.boost.org/trac/boost/changeset/53750

Log:
Copied over character escaping code from property_tree since that library is not stable yet
Text files modified:
   trunk/boost/graph/graphml.hpp | 54 +++++++++++++++++++++++++++++++++++++++
   1 files changed, 53 insertions(+), 1 deletions(-)

Modified: trunk/boost/graph/graphml.hpp
==============================================================================
--- trunk/boost/graph/graphml.hpp (original)
+++ trunk/boost/graph/graphml.hpp 2009-06-08 10:16:06 EDT (Mon, 08 Jun 2009)
@@ -22,13 +22,64 @@
 #include <boost/mpl/vector.hpp>
 #include <boost/mpl/find.hpp>
 #include <boost/mpl/for_each.hpp>
+#if 0 // Change this back later
 #include <boost/property_tree/detail/xml_parser_utils.hpp>
+#endif
 #include <exception>
 #include <sstream>
 
 namespace boost
 {
 
+ // FIXME: Remove this once property_tree is stable
+ namespace graph_detail_from_property_tree {
+
+// ----------------------------------------------------------------------------
+// Copyright (C) 2002-2006 Marcin Kalicinski
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see www.boost.org
+// ----------------------------------------------------------------------------
+
+ // Naively convert narrow string to another character type
+ template<class Ch>
+ std::basic_string<Ch> widen(const char *text)
+ {
+ std::basic_string<Ch> result;
+ while (*text)
+ {
+ result += Ch(*text);
+ ++text;
+ }
+ return result;
+ }
+
+ template<class Ch>
+ std::basic_string<Ch> encode_char_entities(const std::basic_string<Ch> &s)
+ {
+ typedef typename std::basic_string<Ch> Str;
+ Str r;
+ typename Str::const_iterator end = s.end();
+ for (typename Str::const_iterator it = s.begin(); it != end; ++it)
+ {
+ switch (*it)
+ {
+ case Ch('<'): r += boost::graph_detail_from_property_tree::widen<Ch>("&lt;"); break;
+ case Ch('>'): r += boost::graph_detail_from_property_tree::widen<Ch>("&gt;"); break;
+ case Ch('&'): r += boost::graph_detail_from_property_tree::widen<Ch>("&amp;"); break;
+ case Ch('"'): r += boost::graph_detail_from_property_tree::widen<Ch>("&quot;"); break;
+ case Ch('\''): r += boost::graph_detail_from_property_tree::widen<Ch>("&apos;"); break;
+ default: r += *it; break;
+ }
+ }
+ return r;
+ }
+
+ }
+
 /////////////////////////////////////////////////////////////////////////////
 // Graph reader exceptions
 /////////////////////////////////////////////////////////////////////////////
@@ -228,7 +279,8 @@
     typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
     typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
 
- using boost::property_tree::xml_parser::encode_char_entities;
+ // using boost::property_tree::xml_parser::encode_char_entities;
+ using boost::graph_detail_from_property_tree::encode_char_entities;
 
     BOOST_STATIC_CONSTANT(bool,
                           graph_is_directed =


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk