symbol_table.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. http://www.boost.org/
  4. Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
  5. Software License, Version 1.0. (See accompanying file
  6. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #if !defined(BOOST_SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED)
  9. #define BOOST_SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED
  10. #include <map>
  11. #include <boost/wave/wave_config.hpp>
  12. #include <boost/intrusive_ptr.hpp>
  13. #if BOOST_WAVE_SERIALIZATION != 0
  14. #include <boost/serialization/serialization.hpp>
  15. #include <boost/serialization/map.hpp>
  16. #include <boost/shared_ptr.hpp>
  17. #else
  18. #include <boost/intrusive_ptr.hpp>
  19. #endif
  20. #include <boost/iterator/transform_iterator.hpp>
  21. // this must occur after all of the includes and before any code appears
  22. #ifdef BOOST_HAS_ABI_HEADERS
  23. #include BOOST_ABI_PREFIX
  24. #endif
  25. ///////////////////////////////////////////////////////////////////////////////
  26. namespace boost {
  27. namespace wave {
  28. namespace util {
  29. ///////////////////////////////////////////////////////////////////////////////
  30. //
  31. // The symbol_table class is used for the storage of defined macros.
  32. //
  33. ///////////////////////////////////////////////////////////////////////////////
  34. template <typename StringT, typename MacroDefT>
  35. struct symbol_table
  36. #if BOOST_WAVE_SERIALIZATION != 0
  37. : public std::map<StringT, boost::shared_ptr<MacroDefT> >
  38. #else
  39. : public std::map<StringT, boost::intrusive_ptr<MacroDefT> >
  40. #endif
  41. {
  42. #if BOOST_WAVE_SERIALIZATION != 0
  43. typedef std::map<StringT, boost::shared_ptr<MacroDefT> > base_type;
  44. #else
  45. typedef std::map<StringT, boost::intrusive_ptr<MacroDefT> > base_type;
  46. #endif
  47. typedef typename base_type::iterator iterator_type;
  48. typedef typename base_type::const_iterator const_iterator_type;
  49. symbol_table(long uid_ = 0)
  50. {}
  51. #if BOOST_WAVE_SERIALIZATION != 0
  52. private:
  53. friend class boost::serialization::access;
  54. template<typename Archive>
  55. void serialize(Archive &ar, const unsigned int version)
  56. {
  57. using namespace boost::serialization;
  58. ar & make_nvp("symbol_table",
  59. boost::serialization::base_object<base_type>(*this));
  60. }
  61. #endif
  62. private:
  63. ///////////////////////////////////////////////////////////////////////////
  64. //
  65. // This is a special iterator allowing to iterate the names of all defined
  66. // macros.
  67. //
  68. ///////////////////////////////////////////////////////////////////////////
  69. template <typename StringT1>
  70. struct get_first
  71. {
  72. typedef StringT1 const& result_type;
  73. template <typename First, typename Second>
  74. StringT1 const& operator() (std::pair<First, Second> const& p) const
  75. {
  76. return p.first;
  77. }
  78. };
  79. typedef get_first<StringT> unary_functor;
  80. public:
  81. typedef transform_iterator<unary_functor, iterator_type>
  82. name_iterator;
  83. typedef transform_iterator<unary_functor, const_iterator_type>
  84. const_name_iterator;
  85. template <typename Iterator>
  86. static
  87. transform_iterator<unary_functor, Iterator> make_iterator(Iterator it)
  88. {
  89. return boost::make_transform_iterator<unary_functor>(it);
  90. }
  91. };
  92. ///////////////////////////////////////////////////////////////////////////////
  93. } // namespace util
  94. } // namespace wave
  95. } // namespace boost
  96. // the suffix header occurs after all of the code
  97. #ifdef BOOST_HAS_ABI_HEADERS
  98. #include BOOST_ABI_SUFFIX
  99. #endif
  100. #endif // !defined(BOOST_SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED)