[Boost-bugs] [Boost C++ Libraries] #8846: Improvements to Spirit Qi Qt QString custom_string.cpp example

Subject: [Boost-bugs] [Boost C++ Libraries] #8846: Improvements to Spirit Qi Qt QString custom_string.cpp example
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-07-18 08:45:11


#8846: Improvements to Spirit Qi Qt QString custom_string.cpp example
-------------------------------------+--------------------------
 Reporter: mloskot | Owner: djowel
     Type: Patches | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost Development Trunk | Severity: Optimization
 Keywords: spirit qi qt qstring |
-------------------------------------+--------------------------
 Tim Angus asked me to submit this patch (Boost Trac was complaining for
 him with "Submission rejected as potential spam").


 There is an example of how to use Qi with a custom string (in this case a
 QString from the Qt framework). This is very helpful but it doesn't work
 in conjunction with the debug facilities. The following patch fixes this
 by adding a couple of template specialisations.

 Patch:
 {{{
 Index: libs/spirit/example/qi/custom_string.cpp
 ===================================================================
 --- libs/spirit/example/qi/custom_string.cpp (revision 85071)
 +++ libs/spirit/example/qi/custom_string.cpp (working copy)
 @@ -34,6 +34,26 @@
              return true;
          }
      };
 +
 + // Test if a QString is empty (required for debug)
 + template <>
 + struct is_empty_container<QString>
 + {
 + static bool call(QString const& c)
 + {
 + return c.isEmpty();
 + }
 + };
 +
 + // Define how to stream a QString (required for debug)
 + template <typename Out, typename Enable>
 + struct print_attribute_debug<Out, QString, Enable>
 + {
 + static void call(Out& out, QString const& val)
 + {
 + out << val.toStdString();
 + }
 + };
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8846>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC