]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/tools/quickbook/src/id_xml.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / quickbook / src / id_xml.cpp
index d69336b784e5526fe13eb129a16776f7f593e1ab..e220f6621058f2fe7233149082645535a0c3219a 100644 (file)
@@ -25,7 +25,7 @@ namespace quickbook
 
     xml_processor::xml_processor()
     {
-        static int const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*);
+        static std::size_t const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*);
         for (int i = 0; i != n_id_attributes; ++i)
         {
             id_attributes.push_back(id_attributes_[i]);
@@ -73,9 +73,9 @@ namespace quickbook
         while(it != end && !find_char(text, *it)) ++it;
     }
 
-    void xml_processor::parse(boost::string_ref source, callback& c)
+    void xml_processor::parse(quickbook::string_view source, callback& c)
     {
-        typedef boost::string_ref::const_iterator iterator;
+        typedef string_iterator iterator;
 
         c.start(source);
 
@@ -118,7 +118,7 @@ namespace quickbook
                         iterator name_start = it;
                         read_to_one_of(it, end, "= \t\n\r>");
                         if (it == end || *it == '>') break;
-                        boost::string_ref name(name_start, it - name_start);
+                        quickbook::string_view name(name_start, it - name_start);
                         ++it;
 
                         read_some_of(it, end, "= \t\n\r");
@@ -131,10 +131,10 @@ namespace quickbook
 
                         it = std::find(it, end, delim);
                         if (it == end) break;
-                        boost::string_ref value(value_start, it - value_start);
+                        quickbook::string_view value(value_start, it - value_start);
                         ++it;
 
-                        if (boost::find(id_attributes, detail::to_s(name))
+                        if (boost::find(id_attributes, name.to_s())
                                 != id_attributes.end())
                         {
                             c.id_value(value);
@@ -150,4 +150,78 @@ namespace quickbook
 
         c.finish(source);
     }
+
+    namespace detail {
+        std::string linkify(quickbook::string_view source, quickbook::string_view linkend)
+        {
+            typedef string_iterator iterator;
+
+            iterator it = source.begin(), end = source.end();
+
+            bool contains_link = false;
+
+            for(;!contains_link;)
+            {
+                read_past(it, end, "<");
+                if (it == end) break;
+
+                switch(*it)
+                {
+                case '?':
+                    ++it;
+                    read_past(it, end, "?>");
+                    break;
+
+                case '!':
+                    if (read(it, end, "!--")) {
+                        read_past(it, end, "-->");
+                    } else {
+                        read_past(it, end, ">");
+                    }
+                    break;
+
+                default:
+                    if ((*it >= 'a' && *it <= 'z') ||
+                            (*it >= 'A' && *it <= 'Z') ||
+                            *it == '_' || *it == ':')
+                    {
+                        iterator tag_name_start = it;
+                        read_to_one_of(it, end, " \t\n\r>");
+                        quickbook::string_view tag_name(tag_name_start, it - tag_name_start);
+                        if (tag_name == "link") { contains_link = true; }
+
+                        for (;;) {
+                            read_to_one_of(it, end, "\"'\n\r>");
+                            if (it == end || *it == '>') break;
+                            if (*it == '"' || *it == '\'') {
+                                char delim = *it;
+                                ++it;
+                                it = std::find(it, end, delim);
+                                if (it == end) break;
+                                ++it;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        read_past(it, end, ">");
+                    }
+                }
+            }
+
+            std::string result;
+
+            if (!contains_link) {
+                result += "<link linkend=\"";
+                result.append(linkend.begin(), linkend.end());
+                result += "\">";
+                result.append(source.begin(), source.end());
+                result += "</link>";
+            } else {
+                result.append(source.begin(), source.end());
+            }
+
+            return result;
+        }
+    }
 }