/usr/include/util/parser.hpp is in libparser++-dev 0.2.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* Copyright 2008 Simon Richter <Simon.Richter@hogyros.de>
*
* Released under the Boost Software Licence 1.0
*/
#ifndef util_parser_hpp_
#define util_parser_hpp_ 1
#include <boost/intrusive_ptr.hpp>
namespace util {
template<typename T>
void intrusive_ptr_add_ref(T *i, typename T::is_parser_impl * = 0)
{
++i->refcount;
}
template<typename T>
void intrusive_ptr_release(T *i, typename T::is_parser_impl * = 0)
{
if(!--i->refcount)
delete i;
}
template<typename T>
class parser
{
public:
class impl;
parser(void) : slave(0) { }
parser(boost::intrusive_ptr<impl> const &slave) : slave(slave) { }
typedef T value_type;
typedef std::forward_iterator_tag iterator_category;
typedef void difference_type;
typedef T const *pointer;
typedef T const &reference;
bool operator==(parser<T> const &rhs) const
{
return !slave && !rhs.slave;
}
bool operator!=(parser<T> const &rhs) const
{
return slave || rhs.slave;
}
pointer operator->(void) const
{
return slave->operator->();
}
reference operator*(void) const
{
return slave->operator*();
}
parser<T> &operator++(void)
{
slave->operator++();
if(!*slave)
slave = 0;
return *this;
}
class impl
{
public:
impl(void) throw() : refcount(0) { }
virtual ~impl(void) throw() { }
typedef typename parser<T>::value_type value_type;
typedef typename parser<T>::pointer pointer;
typedef typename parser<T>::reference reference;
virtual pointer operator->(void) const = 0;
virtual reference operator*(void) const = 0;
virtual impl &operator++(void) = 0;
virtual bool operator!(void) const = 0;
operator void const *(void) const
{
if(!*this)
return 0;
return this;
}
typedef void is_parser_impl;
private:
unsigned int refcount;
friend void intrusive_ptr_add_ref<>(impl *, is_parser_impl *);
friend void intrusive_ptr_release<>(impl *, is_parser_impl *);
};
private:
boost::intrusive_ptr<impl> slave;
};
}
#endif
|