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

📄 collect_hooks_information.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    //  The parameter 'is_functionlike' is set to true, whenever the newly     //  defined macro is defined as a function like macro.    //    //  The parameter 'parameters' holds the parameter tokens for the macro    //  definition. If the macro has no parameters or if it is a object like    //  macro, then this container is empty.    //    //  The parameter 'definition' contains the token sequence given as the    //  replacement sequence (definition part) of the newly defined macro.    //    //  The parameter 'is_predefined' is set to true for all macros predefined     //  during the initialization phase of the library.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Container>    void    defined_macro(Context const& ctx, Token const& macro,         bool is_functionlike, std::vector<Token> const& pars,         Container const& definition, bool is_predefined)    {        // do not trace the definition of the internal helper macros        if (!is_predefined) {            BOOST_WAVETEST_OSSTREAM strm;            strm << "08: " << repr(macro.get_position()) << ": "                  << macro.get_value();            if (is_functionlike) {            // list the parameter names for function style macros                strm << "(";                for (typename std::vector<Token>::size_type i = 0;                      i < pars.size(); ++i)                {                    strm << pars[i].get_value();                    if (i < pars.size()-1)                        strm << ", ";                }                strm << ")";            }            strm << "=" << boost::wave::util::impl::as_string(definition)                 << std::endl;            hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        }    }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'undefined_macro' is called, whenever a macro definition    //  was removed successfully.    //      //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'name' holds the name of the macro, which definition was     //  removed.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context>    void    undefined_macro(Context const& ctx, Token const& macro)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "09: " << repr(macro.get_position()) << ": "              << macro.get_value() << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);    }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'found_directive' is called, whenever a preprocessor     //  directive was encountered, but before the corresponding action is     //  executed.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'directive' is a reference to the token holding the     //  preprocessing directive.    //    //  The return value defines, whether the given expression has to be     //  to be executed in a normal way (return 'false'), or if it has to be      //  skipped altogether (return 'true'), which means it gets replaced in the     //  output by a single newline.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context>    bool    found_directive(Context const& ctx, Token const& directive)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "10: " << repr(directive.get_position()) << ": "             << directive.get_value() << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return false;     // by default we never skip any directives    }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'evaluated_conditional_expression' is called, whenever a     //  conditional preprocessing expression was evaluated (the expression    //  given to a #if, #elif, #ifdef or #ifndef directive)    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'directive' is a reference to the token holding the     //  corresponding preprocessing directive.    //    //  The parameter 'expression' holds the non-expanded token sequence    //  comprising the evaluated expression.    //    //  The parameter expression_value contains the result of the evaluation of    //  the expression in the current preprocessing context.    //    //  The return value defines, whether the given expression has to be     //  evaluated again, allowing to decide which of the conditional branches    //  should be expanded. You need to return 'true' from this hook function     //  to force the expression to be re-evaluated.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Container>    bool    evaluated_conditional_expression(Context const& ctx,         Token const& directive, Container const& expression,         bool expression_value)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "11: " << repr(directive.get_position()) << ": "             << directive.get_value() << " "             << boost::wave::util::impl::as_string(expression)  << ": "             << expression_value << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return false;       // ok to continue, do not re-evaluate expression    }        ///////////////////////////////////////////////////////////////////////////    //    //  The function 'skipped_token' is called, whenever a token is about to be    //  skipped due to a false preprocessor condition (code fragments to be    //  skipped inside the not evaluated conditional #if/#else/#endif branches).    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'token' refers to the token to be skipped.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context>    void    skipped_token(Context const& ctx, Token const& token)    {// this generates a lot of noise//         BOOST_WAVETEST_OSSTREAM strm;//         strm << "12: " << std::endl;//         hooks_trace += BOOST_WAVETEST_GETSTRING(strm);    }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'generated_token' will be called by the library whenever a    //  token is about to be returned from the library.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 't' is the token about to be returned from the library.    //  This function may alter the token, but in this case it must be     //  implemented with a corresponding signature:     //    //      Token const&    //      generated_token(Context const& ctx, Token& t);    //    //  which makes it possible to modify the token in place.    //    //  The default behavior is to return the token passed as the parameter     //  without modification.    //      ///////////////////////////////////////////////////////////////////////////    template <typename Context>    Token const&    generated_token(Context const& ctx, Token const& t)    { // this generates a lot of noise//        BOOST_WAVETEST_OSSTREAM strm;//        strm << "13: " << std::endl;//        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return t;     }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'may_skip_whitespace' will be called by the     //  library, whenever it must be tested whether a specific token refers to     //  whitespace and this whitespace has to be skipped.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The 'token' parameter holds a reference to the current token. The policy     //  is free to change this token if needed.    //    //  The 'skipped_newline' parameter holds a reference to a boolean value     //  which should be set to true by the policy function whenever a newline     //  is going to be skipped.     //    //  If the return value is true, the given token is skipped and the     //  preprocessing continues to the next token. If the return value is     //  false, the given token is returned to the calling application.     //    //  ATTENTION!    //  Caution has to be used, because by returning true the policy function     //  is able to force skipping even significant tokens, not only whitespace.     //    ///////////////////////////////////////////////////////////////////////////    template <typename Context>    bool    may_skip_whitespace(Context const& ctx, Token& token, bool& skipped_newline)    { // this generates a lot of noise//         BOOST_WAVETEST_OSSTREAM strm;//         strm << "14: " << std::endl;//         hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return this->base_type::may_skip_whitespace(ctx, token, skipped_newline);    }#if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'found_warning_directive' will be called by the library    //  whenever a #warning directive is found.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'message' references the argument token sequence of the    //  encountered #warning directive.    //    //  If the return value is false, the library throws a preprocessor     //  exception of the type 'warning_directive', if the return value is true    //  the execution continues as if no #warning directive has been found.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Container>    bool    found_warning_directive(Context const& ctx, Container const& message)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "15: " << boost::wave::util::impl::as_string(message)             << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return false;    }#endif    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'found_error_directive' will be called by the library    //  whenever a #error directive is found.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'message' references the argument token sequence of the    //  encountered #error directive.    //    //  If the return value is false, the library throws a preprocessor     //  exception of the type 'error_directive', if the return value is true    //  the execution continues as if no #error directive has been found.    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Container>    bool    found_error_directive(Context const& ctx, Container const& message)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "16: " << boost::wave::util::impl::as_string(message)             << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return false;    }    ///////////////////////////////////////////////////////////////////////////    //    //  The function 'found_line_directive' will be called by the library    //  whenever a #line directive is found.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'arguments' references the argument token sequence of the    //  encountered #line directive.    //    //  The parameter 'line' contains the recognized line number from the #line    //  directive.    //    //  The parameter 'filename' references the recognized file name from the     //  #line directive (if there was one given).    //    ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Container>    void    found_line_directive(Context const& ctx, Container const& arguments,        unsigned int line, std::string const& filename)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "17: " << boost::wave::util::impl::as_string(arguments)              << " (" << line << ", \"" << filename << "\")" << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);    }        ///////////////////////////////////////////////////////////////////////////    //    //  The function 'throw_exception' will be called by the library whenever a    //  preprocessing exception occurs.    //    //  The parameter 'ctx' is a reference to the context object used for     //  instantiating the preprocessing iterators by the user.    //    //  The parameter 'e' is the exception object containing detailed error     //  information.    //    //  The default behavior is to call the function boost::throw_exception.    //      ///////////////////////////////////////////////////////////////////////////    template <typename Context, typename Exception>    void    throw_exception(Context const& ctx, Exception const& e)    {        BOOST_WAVETEST_OSSTREAM strm;        strm << "18: " << e.what() << std::endl;        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);        return this->base_type::throw_exception(ctx, e);    }private:    std::string& hooks_trace;};#endif

⌨️ 快捷键说明

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