]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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///////////////////////////////////////////////////////////////////////////////
23namespace boost { namespace spirit {
24
25BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
26
27///////////////////////////////////////////////////////////////////////////////
28//
29// symbols class implementation
30//
31///////////////////////////////////////////////////////////////////////////////
32template <typename T, typename CharT, typename SetT>
33inline symbols<T, CharT, SetT>::symbols()
34: SetT()
35, add(*this)
36{
37}
38
39//////////////////////////////////
40template <typename T, typename CharT, typename SetT>
41symbols<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//////////////////////////////////
54template <typename T, typename CharT, typename SetT>
55inline symbols<T, CharT, SetT>::~symbols()
56{}
57
58//////////////////////////////////
59template <typename T, typename CharT, typename SetT>
60inline symbols<T, CharT, SetT>&
61symbols<T, CharT, SetT>::operator=(symbols const& other)
62{
63 SetT::operator=(other);
64 return *this;
65}
66
67//////////////////////////////////
68template <typename T, typename CharT, typename SetT>
69inline symbol_inserter<T, SetT> const&
70symbols<T, CharT, SetT>::operator=(CharT const* str)
71{
72 return add, str;
73}
74
75///////////////////////////////////////////////////////////////////////////////
76//
77// Symbol table utilities
78//
79///////////////////////////////////////////////////////////////////////////////
80template <typename T, typename CharT, typename SetT>
81inline T*
82find(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//////////////////////////////////
93template <typename T, typename CharT, typename SetT>
94inline T*
95add(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///////////////////////////////////////////////////////////////////////////////
110BOOST_SPIRIT_CLASSIC_NAMESPACE_END
111
112}} // namespace boost::spirit
113
114#if defined(BOOST_MSVC)
115#pragma warning(pop)
116#endif
117
118#endif