source: NonGTP/Boost/boost/spirit/core/impl/match.ipp @ 857

Revision 857, 2.4 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 1998-2003 Joel de Guzman
3    http://spirit.sourceforge.net/
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#if !defined(BOOST_SPIRIT_MATCH_IPP)
10#define BOOST_SPIRIT_MATCH_IPP
11#include <algorithm>
12
13namespace boost { namespace spirit
14{
15    template <typename T>
16    inline match<T>::match()
17    : len(-1), val() {}
18
19    template <typename T>
20    inline match<T>::match(std::size_t length)
21    : len(length), val() {}
22
23    template <typename T>
24    inline match<T>::match(std::size_t length, ctor_param_t val_)
25    : len(length), val(val_) {}
26
27    template <typename T>
28    inline bool
29    match<T>::operator!() const
30    {
31        return len < 0;
32    }
33
34    template <typename T>
35    inline std::ptrdiff_t
36    match<T>::length() const
37    {
38        return len;
39    }
40
41    template <typename T>
42    inline bool
43    match<T>::has_valid_attribute() const
44    {
45        return val.is_initialized();
46    }
47
48    template <typename T>
49    inline typename match<T>::return_t
50    match<T>::value() const
51    {
52        BOOST_SPIRIT_ASSERT(val.is_initialized());
53        return *val;
54    }
55
56    template <typename T>
57    inline void
58    match<T>::swap(match& other)
59    {
60        std::swap(len, other.len);
61        std::swap(val, other.val);
62    }
63
64    inline match<nil_t>::match()
65    : len(-1) {}
66
67    inline match<nil_t>::match(std::size_t length)
68    : len(length) {}
69
70    inline match<nil_t>::match(std::size_t length, nil_t)
71    : len(length) {}
72
73    inline bool
74    match<nil_t>::operator!() const
75    {
76        return len < 0;
77    }
78
79    inline bool
80    match<nil_t>::has_valid_attribute() const
81    {
82        return false;
83    }
84
85    inline std::ptrdiff_t
86    match<nil_t>::length() const
87    {
88        return len;
89    }
90
91    inline nil_t
92    match<nil_t>::value() const
93    {
94        return nil_t();
95    }
96
97    inline void
98    match<nil_t>::value(nil_t) {}
99
100    inline void
101    match<nil_t>::swap(match<nil_t>& other)
102    {
103        std::swap(len, other.len);
104    }
105
106}} // namespace boost::spirit
107
108#endif
109
Note: See TracBrowser for help on using the repository browser.