1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 http://spirit.sourceforge.net/
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 #ifndef BOOST_SPIRIT_SYMBOLS_IPP
10 #define BOOST_SPIRIT_SYMBOLS_IPP
12 ///////////////////////////////////////////////////////////////////////////////
13 #include <boost/spirit/home/classic/symbols/impl/tst.ipp>
14 #include <boost/detail/workaround.hpp>
16 // MSVC: void warning about the use of 'this' pointer in constructors
17 #if defined(BOOST_MSVC)
19 #pragma warning(disable : 4355)
22 ///////////////////////////////////////////////////////////////////////////////
23 namespace boost { namespace spirit {
25 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
27 ///////////////////////////////////////////////////////////////////////////////
29 // symbols class implementation
31 ///////////////////////////////////////////////////////////////////////////////
32 template <typename T, typename CharT, typename SetT>
33 inline symbols<T, CharT, SetT>::symbols()
39 //////////////////////////////////
40 template <typename T, typename CharT, typename SetT>
41 symbols<T, CharT, SetT>::symbols(symbols const& other)
43 // Tru64 CXX seems to be confused by the explicit call of the default
44 // constructor and generates wrong code which invalidates the just contructed
45 // first base class in the line above.
46 #if !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041))
47 , parser<symbols<T, CharT, SetT> >()
53 //////////////////////////////////
54 template <typename T, typename CharT, typename SetT>
55 inline symbols<T, CharT, SetT>::~symbols()
58 //////////////////////////////////
59 template <typename T, typename CharT, typename SetT>
60 inline symbols<T, CharT, SetT>&
61 symbols<T, CharT, SetT>::operator=(symbols const& other)
63 SetT::operator=(other);
67 //////////////////////////////////
68 template <typename T, typename CharT, typename SetT>
69 inline symbol_inserter<T, SetT> const&
70 symbols<T, CharT, SetT>::operator=(CharT const* str)
75 ///////////////////////////////////////////////////////////////////////////////
77 // Symbol table utilities
79 ///////////////////////////////////////////////////////////////////////////////
80 template <typename T, typename CharT, typename SetT>
82 find(symbols<T, CharT, SetT> const& table, CharT const* sym)
84 CharT const* last = sym;
87 scanner<CharT const *> scan(sym, last);
88 T* result = table.find(scan);
89 return scan.at_end()? result: 0;
92 //////////////////////////////////
93 template <typename T, typename CharT, typename SetT>
95 add(symbols<T, CharT, SetT>& table, CharT const* sym, T const& data)
97 CharT const* first = sym;
98 CharT const* last = sym;
101 scanner<CharT const *> scan(first, last);
102 if (table.find(scan) && scan.at_end())
103 return 0; // symbol already contained in symbol table
104 table.add(sym, last, data);
106 return table.find(scan); // refind the inserted symbol
109 ///////////////////////////////////////////////////////////////////////////////
110 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
112 }} // namespace boost::spirit
114 #if defined(BOOST_MSVC)