]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/symbols/impl/symbols.ipp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / symbols / impl / symbols.ipp
1 /*=============================================================================
2 Copyright (c) 2001-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 #ifndef BOOST_SPIRIT_SYMBOLS_IPP
10 #define BOOST_SPIRIT_SYMBOLS_IPP
11
12 ///////////////////////////////////////////////////////////////////////////////
13 #include <boost/spirit/home/classic/symbols/impl/tst.ipp>
14 #include <boost/detail/workaround.hpp>
15
16 // MSVC: void warning about the use of 'this' pointer in constructors
17 #if defined(BOOST_MSVC)
18 #pragma warning(push)
19 #pragma warning(disable : 4355)
20 #endif
21
22 ///////////////////////////////////////////////////////////////////////////////
23 namespace boost { namespace spirit {
24
25 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
26
27 ///////////////////////////////////////////////////////////////////////////////
28 //
29 // symbols class implementation
30 //
31 ///////////////////////////////////////////////////////////////////////////////
32 template <typename T, typename CharT, typename SetT>
33 inline symbols<T, CharT, SetT>::symbols()
34 : SetT()
35 , add(*this)
36 {
37 }
38
39 //////////////////////////////////
40 template <typename T, typename CharT, typename SetT>
41 symbols<T, CharT, SetT>::symbols(symbols const& other)
42 : SetT(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> >()
48 #endif
49 , add(*this)
50 {
51 }
52
53 //////////////////////////////////
54 template <typename T, typename CharT, typename SetT>
55 inline symbols<T, CharT, SetT>::~symbols()
56 {}
57
58 //////////////////////////////////
59 template <typename T, typename CharT, typename SetT>
60 inline symbols<T, CharT, SetT>&
61 symbols<T, CharT, SetT>::operator=(symbols const& other)
62 {
63 SetT::operator=(other);
64 return *this;
65 }
66
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)
71 {
72 return add, str;
73 }
74
75 ///////////////////////////////////////////////////////////////////////////////
76 //
77 // Symbol table utilities
78 //
79 ///////////////////////////////////////////////////////////////////////////////
80 template <typename T, typename CharT, typename SetT>
81 inline T*
82 find(symbols<T, CharT, SetT> const& table, CharT const* sym)
83 {
84 CharT const* last = sym;
85 while (*last)
86 last++;
87 scanner<CharT const *> scan(sym, last);
88 T* result = table.find(scan);
89 return scan.at_end()? result: 0;
90 }
91
92 //////////////////////////////////
93 template <typename T, typename CharT, typename SetT>
94 inline T*
95 add(symbols<T, CharT, SetT>& table, CharT const* sym, T const& data)
96 {
97 CharT const* first = sym;
98 CharT const* last = sym;
99 while (*last)
100 last++;
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);
105 first = sym;
106 return table.find(scan); // refind the inserted symbol
107 }
108
109 ///////////////////////////////////////////////////////////////////////////////
110 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
111
112 }} // namespace boost::spirit
113
114 #if defined(BOOST_MSVC)
115 #pragma warning(pop)
116 #endif
117
118 #endif