Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53268 - in trunk/libs/graph: doc src test
From: jewillco_at_[hidden]
Date: 2009-05-25 21:08:51


Author: jewillco
Date: 2009-05-25 21:08:48 EDT (Mon, 25 May 2009)
New Revision: 53268
URL: http://svn.boost.org/trac/boost/changeset/53268

Log:
Added support for HTML identifiers
Text files modified:
   trunk/libs/graph/doc/read_graphviz.html | 3 ---
   trunk/libs/graph/doc/read_graphviz.rst | 2 --
   trunk/libs/graph/src/read_graphviz_new.cpp | 33 +++++++++++++++++++++++++++++++--
   trunk/libs/graph/test/graphviz_test.cpp | 10 ++++++++++
   4 files changed, 41 insertions(+), 7 deletions(-)

Modified: trunk/libs/graph/doc/read_graphviz.html
==============================================================================
--- trunk/libs/graph/doc/read_graphviz.html (original)
+++ trunk/libs/graph/doc/read_graphviz.html 2009-05-25 21:08:48 EDT (Mon, 25 May 2009)
@@ -497,11 +497,8 @@
 <h1><a class="toc-backref" href="#id8">Future Work</a></h1>
 <blockquote>
 <ul class="simple">
-<li>Support for HTML strings.</li>
 <li>Passing port information to BGL.</li>
 <li>Expanding escape codes in the same way GraphViz does.</li>
-<li>Enforcement of the <tt class="docutils literal"><span class="pre">strict</span></tt> keyword (ignoring self-loops and parallel
-edges).</li>
 <li>Support for optional recognition of subgraphs as distinct entities.</li>
 </ul>
 </blockquote>

Modified: trunk/libs/graph/doc/read_graphviz.rst
==============================================================================
--- trunk/libs/graph/doc/read_graphviz.rst (original)
+++ trunk/libs/graph/doc/read_graphviz.rst 2009-05-25 21:08:48 EDT (Mon, 25 May 2009)
@@ -225,8 +225,6 @@
 Future Work
 -----------
 
- - Support for HTML strings.
-
  - Passing port information to BGL.
 
  - Expanding escape codes in the same way GraphViz does.

Modified: trunk/libs/graph/src/read_graphviz_new.cpp
==============================================================================
--- trunk/libs/graph/src/read_graphviz_new.cpp (original)
+++ trunk/libs/graph/src/read_graphviz_new.cpp 2009-05-25 21:08:48 EDT (Mon, 25 May 2009)
@@ -129,6 +129,8 @@
     boost::regex punctuation_token;
     boost::regex number_token;
     boost::regex quoted_string_token;
+ boost::regex xml_tag_token;
+ boost::regex cdata;
 
     tokenizer(const std::string& str) : begin(str.begin()), end(str.end())
     {
@@ -147,6 +149,8 @@
       punctuation_token = "\\A([][{};=,:+()@]|[-][>-])";
       number_token = "\\A([-]?(?:(?:\\.\\d+)|(?:\\d+(?:\\.\\d*)?)))";
       quoted_string_token = "\\A(\"(?:[^\"\\\\]|(?:[\\\\].))*\")";
+ xml_tag_token = "\\A<(/?)(?:[^!?'\"]|(?:'[^']*?')|(?:\"[^\"]*?\"))*?(/?)>";
+ cdata = "\\A\\Q<![CDATA[\\E.*?\\Q]]>\\E";
     }
 
     void skip() {
@@ -245,8 +249,33 @@
         return token(token::quoted_string, str);
       }
       if (*begin == '<') {
- throw_lex_error("HTML strings not supported");
- return token();
+ std::string::const_iterator saved_begin = begin;
+ int counter = 0;
+ do {
+ if (begin == end) throw_lex_error("Unclosed HTML string");
+ if (*begin != '<') {
+ ++begin;
+ continue;
+ }
+ found = boost::regex_search(begin, end, results, xml_tag_token);
+ if (found) {
+ begin = results.suffix().first;
+ if (results[1].str() == "/") { // Close tag
+ --counter;
+ } else if (results[2].str() == "/") { // Empty tag
+ } else { // Open tag
+ ++counter;
+ }
+ continue;
+ }
+ found = boost::regex_search(begin, end, results, cdata);
+ if (found) {
+ begin = results.suffix().first;
+ continue;
+ }
+ throw_lex_error("Invalid contents in HTML string");
+ } while (counter > 0);
+ return token(token::identifier, std::string(saved_begin, begin));
       } else {
         throw_lex_error("Invalid character");
         return token();

Modified: trunk/libs/graph/test/graphviz_test.cpp
==============================================================================
--- trunk/libs/graph/test/graphviz_test.cpp (original)
+++ trunk/libs/graph/test/graphviz_test.cpp 2009-05-25 21:08:48 EDT (Mon, 25 May 2009)
@@ -248,6 +248,16 @@
                                             graph_name)));
   }
 
+ // Graph Property Test 3 (HTML)
+ {
+ mass_map_t masses;
+ insert ( masses ) ("a",0.0f) ("c",0.0f) ("e", 6.66f);
+ std::string graph_name = "<html title=\"x'\" title2='y\"'>foo<b><![CDATA[><bad tag&>]]>bar</b>\n<br/>\nbaz</html>";
+ gs_t gs("digraph { name=" + graph_name + " a c e [mass = 6.66] }");
+ BOOST_CHECK((test_graph<directedS,vecS>(gs,3,masses,weight_map_t(),"",
+ graph_name)));
+ }
+
   // Comments embedded in strings
   {
     gs_t gs(


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