attr_rule.ipp
来自「著名的Parser库Spirit在VC6上的Port」· IPP 代码 · 共 212 行
IPP
212 行
/*=============================================================================
Attributed rules
Spirit V1.3.1
Copyright (c) 2001, Hartmut Kaiser
This software is provided 'as-is', without any express or implied
warranty. In no event will the copyright holder be held liable for
any damages arising from the use of this software.
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:
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.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
Acknowledgements:
Special thanks to Dan Nuffer, John (EBo) David, Chris Uzdavinis,
and Doug Gregor. These people are most instrumental in steering
Spirit in the right direction.
Special thanks also to people who have contributed to the code base
and sample code, ported Spirit to various platforms and compilers,
gave suggestions, reported and provided bug fixes. Alexander
Hirner, Andy Elvey, Bogdan Kushnir, Brett Calcott, Bruce Florman,
Changzhe Han, Colin McPhail, Hakki Dogusan, Jan Bares, Joseph
Smith, Martijn W. van der Lee, Raghavendra Satish, Remi Delcos, Tom
Spilman, Vladimir Prus, W. Scott Dillman, David A. Greene, Bob
Bailey, Hartmut Kaiser.
Finally special thanks also to people who gave feedback and
valuable comments, particularly members of Spirit's Source Forge
mailing list and boost.org.
URL: http://spirit.sourceforge.net/
=============================================================================*/
#ifndef SPIRIT_ATTR_RULE_IPP
#define SPIRIT_ATTR_RULE_IPP
///////////////////////////////////////////////////////////////////////////////
#include "boost/spirit/MSVC/attr_rule.hpp"
///////////////////////////////////////////////////////////////////////////////
namespace spirit {
///////////////////////////////////////////////////////////////////////////////
//
// attr_match class implementation
//
///////////////////////////////////////////////////////////////////////////////
template <typename TypeT, typename BaseT>
inline
attr_match<TypeT, BaseT>::attr_match() : value()
{
}
template <typename TypeT, typename BaseT>
inline
attr_match<TypeT, BaseT>::attr_match(unsigned length) : value(), BaseT(length)
{
}
//template <typename TypeT, typename BaseT>
//inline attr_match<TypeT, BaseT>::attr_match(match const &hit) :
// BaseT(hit.length())
//{
//}
template <typename TypeT, typename BaseT>
inline
attr_match<TypeT, BaseT>::attr_match(BaseT const &hit) : value(), BaseT(hit)
{
}
template <typename TypeT, typename BaseT>
inline
attr_match<TypeT, BaseT>&
attr_match<TypeT, BaseT>::operator += (match const& other)
{
assert(*this && other);
data += other.data;
return *this;
}
template <typename TypeT, typename BaseT>
inline TypeT const &
attr_match<TypeT, BaseT>::attr_value() const
{
return value;
}
template <typename TypeT, typename BaseT>
inline void
attr_match<TypeT, BaseT>::attr_value(TypeT const &value_)
{
value = value_;
}
template <typename TypeT, typename BaseT>
inline attr_match<TypeT, BaseT>
operator+(attr_match<TypeT, BaseT> const& a, match const& b)
{
return attr_match<TypeT, BaseT>(a) += b;
}
template <typename TypeT, typename BaseT>
inline attr_match<TypeT, BaseT>
operator+(match const& a, attr_match<TypeT, BaseT> const& b)
{
return attr_match<TypeT, BaseT>(b) += a;
}
///////////////////////////////////////////////////////////////////////////////
//
// param_parser class implementation
//
///////////////////////////////////////////////////////////////////////////////
template <typename TupleT, typename ParserT, typename InitTupleT>
inline
param_parser<TupleT, ParserT, InitTupleT>::param_parser(
InitTupleT const &init_, TupleT *&ptr_, ParserT const& parser_) :
unary<ParserT>(parser_), init(init_), ptr(ptr_)
{
#if defined(SPIRIT_DEBUG)
debug.name (std::string("param parser: ") + parser_.debug.name());
#endif
}
//////////////////////////////////
#ifdef SPIRIT_DEBUG
template <typename TupleT>
void
print_closure_info(bool hit, int level, bool close, std::string const &name, TupleT *ptr);
#endif
///////////////////////////////////////////////////////////////////////////////
//
// attr_rule class implementation
//
///////////////////////////////////////////////////////////////////////////////
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>::attr_rule() :
init(ptr, rule_base())
{
}
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>
::attr_rule(attr_rule const& other) :
rule_t(static_cast<rule_t const &>(other)),
init(ptr, rule_base())
{
}
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>
::attr_rule(rule_t const& other) :
rule_t(other),
init(ptr, rule_base())
{
}
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>::~attr_rule()
{
}
// rule specific functions
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>&
attr_rule<ClosureT, IteratorT, MatchTraitsT>
::operator=(attr_rule const& other)
{
if (this != &other)
*static_cast<rule_t *>(this) = other;
return *this;
}
template <typename ClosureT, typename IteratorT, typename MatchTraitsT>
inline attr_rule<ClosureT, IteratorT, MatchTraitsT>&
attr_rule<ClosureT, IteratorT, MatchTraitsT>
::operator=(rule_t const& other)
{
*static_cast<rule_t *>(this) = other;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace Spirit
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?