⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpp_include_paths.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/*=============================================================================    Boost.Wave: A Standard compliant C++ preprocessor library    http://www.boost.org/    Copyright (c) 2001-2008 Hartmut Kaiser. Distributed under the Boost    Software License, Version 1.0. (See accompanying file    LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)=============================================================================*/#if !defined(CPP_INCLUDE_PATHS_HPP_AF620DA4_B3D2_4221_AD91_8A1ABFFB6944_INCLUDED)#define CPP_INCLUDE_PATHS_HPP_AF620DA4_B3D2_4221_AD91_8A1ABFFB6944_INCLUDED#include <string>#include <list>#include <utility>#include <boost/wave/wave_config.hpp>#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0#include <boost/multi_index_container.hpp>#include <boost/multi_index/member.hpp>#include <boost/multi_index/ordered_index.hpp>#endif#if BOOST_WAVE_SERIALIZATION != 0#include <boost/serialization/serialization.hpp>#include <boost/serialization/utility.hpp>#include <boost/serialization/collections_save_imp.hpp>#include <boost/serialization/collections_load_imp.hpp>#include <boost/serialization/split_free.hpp>#endif#include <boost/filesystem/path.hpp>#include <boost/filesystem/operations.hpp>// this must occur after all of the includes and before any code appears#ifdef BOOST_HAS_ABI_HEADERS#include BOOST_ABI_PREFIX#endif///////////////////////////////////////////////////////////////////////////////namespace boost { namespace wave { namespace util {#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0/////////////////////////////////////////////////////////////////////////////////  Tags for accessing both sides of a bidirectional mapstruct from {};struct to {};/////////////////////////////////////////////////////////////////////////////////  The class template bidirectional_map wraps the specification//  of a bidirectional map based on multi_index_container.template<typename FromType, typename ToType>struct bidirectional_map{    typedef std::pair<FromType, ToType> value_type;#if defined(BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS) ||\    defined(BOOST_MSVC)&&(BOOST_MSVC<1300) ||\    defined(BOOST_INTEL_CXX_VERSION)&&defined(_MSC_VER)&&\           (BOOST_INTEL_CXX_VERSION<=700)    BOOST_STATIC_CONSTANT(unsigned, from_offset = offsetof(value_type, first));    BOOST_STATIC_CONSTANT(unsigned, to_offset   = offsetof(value_type, second));    typedef boost::multi_index::multi_index_container<        value_type,        boost::multi_index::indexed_by<            boost::multi_index::ordered_unique<                boost::multi_index::tag<from>,                 boost::multi_index::member_offset<value_type, FromType, from_offset>             >,            boost::multi_index::ordered_non_unique<                boost::multi_index::tag<to>,                 boost::multi_index::member_offset<value_type, ToType, to_offset>             >        >    > type;#else  typedef boost::multi_index::multi_index_container<      value_type,      boost::multi_index::indexed_by<          boost::multi_index::ordered_unique<              boost::multi_index::tag<from>,              boost::multi_index::member<value_type, FromType, &value_type::first>           >,          boost::multi_index::ordered_non_unique<              boost::multi_index::tag<to>,                boost::multi_index::member<value_type, ToType, &value_type::second>           >      >  > type;#endif};#endif // BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0#if BOOST_WAVE_SERIALIZATION != 0struct load_filepos{    static unsigned int get_line() { return 0; }    static unsigned int get_column() { return 0; }    static std::string get_file() { return "<loading-state>"; }};#endif///////////////////////////////////////////////////////////////////////////////////  include_paths - controlling the include path search order////  General notes:////      Any directories specified with the 'add_include_path()' function before //      the function 'set_sys_include_delimiter()' is called are searched only //      for the case of '#include "file"' directives, they are not searched for //      '#include <file>' directives. If additional directories are specified //      with the 'add_include_path()' function after a call to the function //      'set_sys_include_delimiter()', these directories are searched for all //      '#include' directives. ////      In addition, a call to the function 'set_sys_include_delimiter()' //      inhibits the use of the current directory as the first search directory //      for '#include "file"' directives. Therefore, the current directory is //      searched only if it is requested explicitly with a call to the function//      'add_include_path(".")'. ////      Calling both functions, the 'set_sys_include_delimiter()' and //      'add_include_path(".")' allows you to control precisely which //      directories are searched before the current one and which are searched //      after./////////////////////////////////////////////////////////////////////////////////class include_paths{private:    typedef std::list<std::pair<boost::filesystem::path, std::string> >         include_list_type;    typedef include_list_type::value_type include_value_type;    #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0    typedef bidirectional_map<std::string, std::string>::type         pragma_once_set_type;#endifpublic:    include_paths()    :   was_sys_include_path(false),        current_dir(boost::filesystem::initial_path()),        current_rel_dir(boost::filesystem::initial_path())    {}        bool add_include_path(char const *path_, bool is_system = false)    {        return add_include_path(path_, (is_system || was_sys_include_path) ?             system_include_paths : user_include_paths);    }    void set_sys_include_delimiter() { was_sys_include_path = true; }    bool find_include_file (std::string &s, std::string &dir, bool is_system,         char const *current_file) const;    void set_current_directory(char const *path_);    boost::filesystem::path get_current_directory() const         { return current_dir; }protected:    bool find_include_file (std::string &s, std::string &dir,         include_list_type const &pathes, char const *) const;    bool add_include_path(char const *path_, include_list_type &pathes_);private:    include_list_type user_include_paths;    include_list_type system_include_paths;    bool was_sys_include_path;          // saw a set_sys_include_delimiter()    boost::filesystem::path current_dir;    boost::filesystem::path current_rel_dir;#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0public:    bool has_pragma_once(std::string const &filename)    {        using namespace boost::multi_index;        return get<from>(pragma_once_files).find(filename) != pragma_once_files.end();    }    bool add_pragma_once_header(std::string const &filename,         std::string const& guard_name)    {        typedef pragma_once_set_type::value_type value_type;        return pragma_once_files.insert(value_type(filename, guard_name)).second;    }    bool remove_pragma_once_header(std::string const& guard_name)    {        typedef pragma_once_set_type::index_iterator<to>::type to_iterator;        typedef std::pair<to_iterator, to_iterator> range_type;                range_type r = pragma_once_files.get<to>().equal_range(guard_name);        if (r.first != r.second) {            using namespace boost::multi_index;            get<to>(pragma_once_files).erase(r.first, r.second);            return true;        }        return false;    }private:    pragma_once_set_type pragma_once_files;#endif#if BOOST_WAVE_SERIALIZATION != 0public:    BOOST_STATIC_CONSTANT(unsigned int, version = 0x10);    BOOST_STATIC_CONSTANT(unsigned int, version_mask = 0x0f);private:    friend class boost::serialization::access;    template<typename Archive>    void save(Archive & ar, const unsigned int version) const    {        using namespace boost::serialization;#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0        ar & make_nvp("pragma_once_files", pragma_once_files);#endif        ar & make_nvp("user_include_paths", user_include_paths);        ar & make_nvp("system_include_paths", system_include_paths);        ar & make_nvp("was_sys_include_path", was_sys_include_path);    }    template<typename Archive>    void load(Archive & ar, const unsigned int loaded_version)    {        using namespace boost::serialization;        if (version != (loaded_version & ~version_mask)) {            BOOST_WAVE_THROW(preprocess_exception, incompatible_config,                 "cpp_include_path state version", load_filepos());            return;        }#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0        ar & make_nvp("pragma_once_files", pragma_once_files);#endif        // verify that the old include paths match the current ones        include_list_type user_paths, system_paths;        ar & make_nvp("user_include_paths", user_paths);        ar & make_nvp("system_include_paths", system_paths);        if (user_paths != user_include_paths)        {            BOOST_WAVE_THROW(preprocess_exception, incompatible_config,                 "user include paths", load_filepos());            return;        }        if (system_paths != system_include_paths)        {            BOOST_WAVE_THROW(preprocess_exception, incompatible_config,                 "system include paths", load_filepos());            return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -