fix build
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 5 Feb 2008 10:37:54 +0000 (10:37 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 5 Feb 2008 10:37:54 +0000 (10:37 +0000)
zypp/CMakeLists.txt
zypp/parser/parser_utils.hpp [new file with mode: 0644]

index b4c3c6d..ee99662 100644 (file)
@@ -334,6 +334,7 @@ SET( zypp_parser_SRCS
   parser/LibXMLHelper.cc
   parser/XMLNodeIterator.cc
   parser/RepoFileReader.cc
+  parser/xml_escape_parser.cpp
 )
 
 SET( zypp_parser_HEADERS
@@ -346,6 +347,7 @@ SET( zypp_parser_HEADERS
   parser/XMLNodeIterator.h
   parser/xml_parser_assert.h
   parser/RepoFileReader.h
+  parser/xml_escape_parser.hpp
 )
 
 INSTALL(  FILES
diff --git a/zypp/parser/parser_utils.hpp b/zypp/parser/parser_utils.hpp
new file mode 100644 (file)
index 0000000..492b4de
--- /dev/null
@@ -0,0 +1,193 @@
+/*\r
+IoBind Library License:\r
+--------------------------\r
+\r
+The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
+\r
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
+\r
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
+\r
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
+\r
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
+\r
+3. This notice may not be removed or altered from any source distribution\r
+*/\r
+\r
+\r
+#ifndef IOBIND_PARSER_UTILS_HPP\r
+#define IOBIND_PARSER_UTILS_HPP\r
+\r
+#include <boost/spirit.hpp>\r
+#include <boost/call_traits.hpp>\r
+#include <string>\r
+\r
+namespace iobind{\r
+namespace parser{\r
+namespace detail{\r
+\r
+template<\r
+       typename Container,\r
+       typename Policy\r
+> \r
+class append_with_policy\r
+{\r
+public:\r
+    append_with_policy( Container& container_, Policy const& policy_)\r
+        : m_container(container_), m_policy(policy_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT const& first, IteratorT const& last) const\r
+    {\r
+               m_container.insert(m_container.end(), m_policy.encode( std::string(first, last) ) );\r
+    }\r
+\r
+private:\r
+    Container& m_container;\r
+       Policy const& m_policy;\r
+};\r
+\r
+template<\r
+       typename Container,\r
+       typename Policy\r
+> \r
+class insert_with_policy\r
+{\r
+public:\r
+    insert_with_policy( size_t& index_, Container& container_, Policy const& policy_)\r
+        : m_index(index_), m_container(container_), m_policy(policy_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT const& first, IteratorT const& last) const\r
+    {\r
+               if (m_index < m_container.size())\r
+                       m_container[m_index++]=m_policy.encode( std::string(first, last) );\r
+#ifdef _DEBUG\r
+               else\r
+                       std::cerr<<"insert_with_policy: could not add data"<<std::endl;\r
+#endif\r
+       }\r
+\r
+private:\r
+       size_t& m_index;\r
+    Container& m_container;\r
+       Policy const& m_policy;\r
+};\r
+\r
+template<\r
+       typename Pair,\r
+       typename FirstPolicy,\r
+       typename SecondPolicy\r
+> \r
+class assign_pair_with_policy\r
+{\r
+public:\r
\r
+       explicit assign_pair_with_policy( \r
+               Pair& pair_, \r
+               FirstPolicy const& first_policy_,\r
+               SecondPolicy const& second_policy_,\r
+               std::string const& first_,\r
+               std::string const& second_\r
+               )\r
+        : \r
+               m_pair(pair_), \r
+               m_first_policy(first_policy_),\r
+               m_second_policy(second_policy_),\r
+               m_first(first_),\r
+               m_second(second_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT first, IteratorT last) const\r
+    {\r
+               m_pair=Pair(\r
+                       m_first_policy.encode(m_first.c_str()),\r
+                       m_second_policy.encode(m_second.c_str())\r
+                       );\r
+    }\r
+\r
+private:\r
+    Pair& m_pair;\r
+       FirstPolicy const& m_first_policy;\r
+       SecondPolicy const& m_second_policy;\r
+       std::string const& m_first;\r
+       std::string const& m_second;\r
+};\r
+\r
+class concat_string\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_string( std::ostream& out_)\r
+        : out(out_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT first, IteratorT last) const\r
+    {\r
+               out<<std::string(first,last);\r
+    }\r
+\r
+       template <typename IteratorT>\r
+       void operator()(IteratorT single) const\r
+       {\r
+               out<<single;\r
+       }\r
+private:\r
+    std::ostream& out;\r
+};\r
+\r
+class concat_symbol\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_symbol( std::ostream& out_)\r
+        : out(out_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+       void operator()(std::string const& str) const\r
+       {\r
+               out<<str;\r
+       }\r
+private:\r
+    std::ostream& out;\r
+};\r
+\r
+class concat_pre_post_symbol\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_pre_post_symbol( std::ostream& out_, std::string const& pre_, std::string const& post_)\r
+        : m_out(out_),m_pre(pre_), m_post(post_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+       void operator()(std::string const& str_) const\r
+       {\r
+               m_out<<m_pre<<str_<<m_post;\r
+       }\r
+private:\r
+    std::ostream& m_out;\r
+       std::string m_pre;\r
+       std::string m_post;\r
+};\r
+\r
+};//details\r
+};//parser\r
+};//iobind\r
+\r
+#endif\r
+\r
+\r