File indexing completed on 2025-01-31 10:02:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_SPIRIT_SYMBOLS_IPP
0010 #define BOOST_SPIRIT_SYMBOLS_IPP
0011
0012
0013 #include <boost/spirit/home/classic/symbols/impl/tst.ipp>
0014 #include <boost/detail/workaround.hpp>
0015
0016
0017 #if defined(BOOST_MSVC)
0018 #pragma warning(push)
0019 #pragma warning(disable : 4355)
0020 #endif
0021
0022
0023 namespace boost { namespace spirit {
0024
0025 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0026
0027
0028
0029
0030
0031
0032 template <typename T, typename CharT, typename SetT>
0033 inline symbols<T, CharT, SetT>::symbols()
0034 : SetT()
0035 , add(*this)
0036 {
0037 }
0038
0039
0040 template <typename T, typename CharT, typename SetT>
0041 symbols<T, CharT, SetT>::symbols(symbols const& other)
0042 : SetT(other)
0043
0044
0045
0046 #if !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041))
0047 , parser<symbols<T, CharT, SetT> >()
0048 #endif
0049 , add(*this)
0050 {
0051 }
0052
0053
0054 template <typename T, typename CharT, typename SetT>
0055 inline symbols<T, CharT, SetT>::~symbols()
0056 {}
0057
0058
0059 template <typename T, typename CharT, typename SetT>
0060 inline symbols<T, CharT, SetT>&
0061 symbols<T, CharT, SetT>::operator=(symbols const& other)
0062 {
0063 SetT::operator=(other);
0064 return *this;
0065 }
0066
0067
0068 template <typename T, typename CharT, typename SetT>
0069 inline symbol_inserter<T, SetT> const&
0070 symbols<T, CharT, SetT>::operator=(CharT const* str)
0071 {
0072 return add, str;
0073 }
0074
0075
0076
0077
0078
0079
0080 template <typename T, typename CharT, typename SetT>
0081 inline T*
0082 find(symbols<T, CharT, SetT> const& table, CharT const* sym)
0083 {
0084 CharT const* last = sym;
0085 while (*last)
0086 last++;
0087 scanner<CharT const *> scan(sym, last);
0088 T* result = table.find(scan);
0089 return scan.at_end()? result: 0;
0090 }
0091
0092
0093 template <typename T, typename CharT, typename SetT>
0094 inline T*
0095 add(symbols<T, CharT, SetT>& table, CharT const* sym, T const& data)
0096 {
0097 CharT const* first = sym;
0098 CharT const* last = sym;
0099 while (*last)
0100 last++;
0101 scanner<CharT const *> scan(first, last);
0102 if (table.find(scan) && scan.at_end())
0103 return 0;
0104 table.add(sym, last, data);
0105 first = sym;
0106 return table.find(scan);
0107 }
0108
0109
0110 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0111
0112 }}
0113
0114 #if defined(BOOST_MSVC)
0115 #pragma warning(pop)
0116 #endif
0117
0118 #endif