Here is snipped for hooking file loading in boost::wave (version 1.53)
class custom_directives_hooks
: public boost::wave::context_policies::default_preprocessing_hooks
{
public:
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
void found_include_directive(std::string const& filename, bool include_next)
{}
#else
template <typename ContextT>
bool found_include_directive(ContextT const& ctx, std::string const& filename, bool include_next)
{
return false; // ok to include this file
}
#endif
template <typename ContextT>
bool locate_include_file(ContextT& ctx, std::string &file_path,
bool is_system, char const *current_name, std::string &dir_path,
std::string &native_name)
{
//write code here to locate file
return true; //or false if file is not found
}
}
void main()
{
//...
//typedef for boost::wave context with hooks for file loading
typedef boost::wave::cpplexer::lex_iterator< boost::wave::cpplexer::lex_token<> >
lex_iterator_type;
typedef boost::wave::context<
std::string::iterator, lex_iterator_type,
boost::wave::iteration_context_policies::load_file_to_string,
custom_directives_hooks>
context_type;
//...
}