LCOV - code coverage report
Current view: top level - usr/include/boost/spirit/home/classic/core/non_terminal - parser_id.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 4 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*=============================================================================
       2             :     Copyright (c) 2001-2003 Joel de Guzman
       3             :     Copyright (c) 2001 Daniel Nuffer
       4             :     http://spirit.sourceforge.net/
       5             : 
       6             :   Distributed under the Boost Software License, Version 1.0. (See accompanying
       7             :   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       8             : =============================================================================*/
       9             : #if !defined(BOOST_SPIRIT_PARSER_ID_HPP)
      10             : #define BOOST_SPIRIT_PARSER_ID_HPP
      11             : 
      12             : #if defined(BOOST_SPIRIT_DEBUG)
      13             : #   include <ostream>
      14             : #endif
      15             : #include <boost/spirit/home/classic/namespace.hpp>
      16             : 
      17             : ///////////////////////////////////////////////////////////////////////////////
      18             : namespace boost { namespace spirit {
      19             : 
      20             : BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
      21             : 
      22             :     ///////////////////////////////////////////////////////////////////////////
      23             :     //
      24             :     //  parser_id class
      25             :     //
      26             :     ///////////////////////////////////////////////////////////////////////////
      27             :     class parser_id
      28             :     {
      29             :     public:
      30             :                     parser_id()                     : p(0) {}
      31             :         explicit    parser_id(void const* prule)    : p(prule) {}
      32           0 :                     parser_id(std::size_t l_)       : l(l_) {}
      33             : 
      34           0 :         bool operator==(parser_id const& x) const   { return p == x.p; }
      35             :         bool operator!=(parser_id const& x) const   { return !(*this == x); }
      36             :         bool operator<(parser_id const& x) const    { return p < x.p; }
      37             :         std::size_t to_long() const                 { return l; }
      38             : 
      39             :     private:
      40             : 
      41             :         union
      42             :         {
      43             :             void const* p;
      44             :             std::size_t l;
      45             :         };
      46             :     };
      47             : 
      48             :     #if defined(BOOST_SPIRIT_DEBUG)
      49             :     inline std::ostream&
      50             :     operator<<(std::ostream& out, parser_id const& rid)
      51             :     {
      52             :         out << (unsigned int)rid.to_long();
      53             :         return out;
      54             :     }
      55             :     #endif
      56             : 
      57             :     ///////////////////////////////////////////////////////////////////////////
      58             :     //
      59             :     //  parser_tag_base class: base class of all parser tags
      60             :     //
      61             :     ///////////////////////////////////////////////////////////////////////////
      62             :     struct parser_tag_base {};
      63             :     
      64             :     ///////////////////////////////////////////////////////////////////////////
      65             :     //
      66             :     //  parser_address_tag class: tags a parser with its address
      67             :     //
      68             :     ///////////////////////////////////////////////////////////////////////////
      69             :     struct parser_address_tag : parser_tag_base
      70             :     {
      71           0 :         parser_id id() const
      72           0 :         { return parser_id(reinterpret_cast<std::size_t>(this)); }
      73             :     };
      74             : 
      75             :     ///////////////////////////////////////////////////////////////////////////
      76             :     //
      77             :     //  parser_tag class: tags a parser with an integer ID
      78             :     //
      79             :     ///////////////////////////////////////////////////////////////////////////
      80             :     template <int N>
      81             :     struct parser_tag : parser_tag_base
      82             :     {
      83             :         static parser_id id()
      84             :         { return parser_id(std::size_t(N)); }
      85             :     };
      86             : 
      87             :     ///////////////////////////////////////////////////////////////////////////
      88             :     //
      89             :     //  dynamic_parser_tag class: tags a parser with a dynamically changeable
      90             :     //  integer ID
      91             :     //
      92             :     ///////////////////////////////////////////////////////////////////////////
      93             :     class dynamic_parser_tag : public parser_tag_base
      94             :     {
      95             :     public:
      96             :     
      97             :         dynamic_parser_tag() 
      98             :         : tag(std::size_t(0)) {}
      99             :         
     100             :         parser_id 
     101             :         id() const
     102             :         { 
     103             :             return 
     104             :                 tag.to_long() 
     105             :                 ? tag 
     106             :                 : parser_id(reinterpret_cast<std::size_t>(this)); 
     107             :         }
     108             : 
     109             :         void set_id(parser_id id_) { tag = id_; } 
     110             :         
     111             :     private:
     112             :     
     113             :         parser_id tag;
     114             :     };
     115             : 
     116             : ///////////////////////////////////////////////////////////////////////////////
     117             : BOOST_SPIRIT_CLASSIC_NAMESPACE_END
     118             : 
     119             : }} // namespace BOOST_SPIRIT_CLASSIC_NS
     120             : 
     121             : #endif
     122             : 

Generated by: LCOV version 1.14