|
||||
File indexing completed on 2025-01-30 10:02:17
0001 /*============================================================================= 0002 Boost.Wave: A Standard compliant C++ preprocessor library 0003 0004 http://www.boost.org/ 0005 0006 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost 0007 Software License, Version 1.0. (See accompanying file 0008 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0009 =============================================================================*/ 0010 0011 #if !defined(BOOST_TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED) 0012 #define BOOST_TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED 0013 0014 #include <vector> 0015 0016 #include <boost/wave/wave_config.hpp> 0017 #include <boost/wave/token_ids.hpp> 0018 0019 // this must occur after all of the includes and before any code appears 0020 #ifdef BOOST_HAS_ABI_HEADERS 0021 #include BOOST_ABI_PREFIX 0022 #endif 0023 0024 /////////////////////////////////////////////////////////////////////////////// 0025 namespace boost { 0026 namespace wave { 0027 namespace cpplexer { 0028 0029 /////////////////////////////////////////////////////////////////////////////// 0030 // 0031 // The token_cache template is used to cache the tokens corresponding to the 0032 // keywords, operators and other constant language elements. 0033 // 0034 // This avoids repeated construction of these tokens, which is especially 0035 // effective when used in conjunction with a copy on write string 0036 // implementation (COW string). 0037 // 0038 /////////////////////////////////////////////////////////////////////////////// 0039 template <typename StringT> 0040 class token_cache 0041 { 0042 public: 0043 token_cache() 0044 : cache(T_LAST_TOKEN - T_FIRST_TOKEN) 0045 { 0046 typename std::vector<StringT>::iterator it = cache.begin(); 0047 for (unsigned int i = T_FIRST_TOKEN; i < T_LAST_TOKEN; ++i, ++it) 0048 { 0049 *it = StringT(boost::wave::get_token_value(token_id(i))); 0050 } 0051 } 0052 0053 StringT const &get_token_value(token_id id) const 0054 { 0055 return cache[BASEID_FROM_TOKEN(id) - T_FIRST_TOKEN]; 0056 } 0057 0058 private: 0059 std::vector<StringT> cache; 0060 }; 0061 0062 /////////////////////////////////////////////////////////////////////////////// 0063 } // namespace cpplexer 0064 } // namespace wave 0065 } // namespace boost 0066 0067 // the suffix header occurs after all of the code 0068 #ifdef BOOST_HAS_ABI_HEADERS 0069 #include BOOST_ABI_SUFFIX 0070 #endif 0071 0072 #endif // !defined(BOOST_TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |