1 /*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
5 Copyright (c) 2001-2013 Hartmut Kaiser. Distributed under the Boost
6 Software License, Version 1.0. (See accompanying file
7 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
10 #if !defined(BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP)
11 #define BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP
17 #include <boost/config.hpp>
19 #include "cmd_line_utils.hpp"
21 ///////////////////////////////////////////////////////////////////////////////
25 testwave_app(boost::program_options::variables_map const& vm);
27 // Test the given file (i.e. preprocess the file and compare the result
28 // against the embedded 'R' comments, if an error occurs compare the error
29 // message against the given 'E' comments).
30 bool test_a_file(std::string filename);
32 // print the current version of this program
35 // print the copyright statement
36 int print_copyright();
38 // access the common options used for the command line and the config
39 // options inside the test files
40 boost::program_options::options_description const& common_options() const
45 void set_debuglevel(int debuglevel_)
47 debuglevel = debuglevel_;
49 int get_debuglevel() const
55 // Read the given file into a string
56 bool read_file(std::string const& filename, std::string& instr);
58 // Extract special information from comments marked with the given letter
59 bool extract_special_information(std::string const& filename,
60 std::string const& instr, char flag, std::string& content);
62 // Extract the expected output and expected hooks information from the
64 // The expected output has to be provided inside of special comments which
65 // start with a capital 'R' ('H' for the hooks information). All such
66 // comments are concatenated and returned through the parameter 'expected'
67 // ('expectedhooks' for hooks information).
68 bool extract_expected_output(std::string const& filename,
69 std::string const& instr, std::string& expected,
70 std::string& expectedhooks);
72 // Extracts the required preprocessing options from the given input data
73 // and initializes the given Wave context object accordingly.
74 // We allow the same (applicable) options to be used as are valid for the
75 // wave driver executable.
76 template <typename Context>
77 bool extract_options(std::string const& filename,
78 std::string const& instr, Context& ctx, bool single_line,
79 boost::program_options::variables_map& vm);
81 // transfers the options collected in the vm parameter into the given
83 template <typename Context>
84 bool initialise_options(Context& ctx,
85 boost::program_options::variables_map const& vm, bool single_line);
87 // Preprocess the given input data and return the generated output through
88 // the parameter 'result'.
89 bool preprocess_file(std::string filename, std::string const& instr,
90 std::string& result, std::string& error, std::string& hooks,
91 std::string const& expected_cfg_macro, bool single_line = false);
93 // Add special predefined macros to the context object
94 template <typename Context>
95 bool add_predefined_macros(Context& ctx);
97 // This function compares the real result and the expected one but first
98 // replaces all occurrences in the expected result of
99 // $E: to the result of preprocessing the given expression
100 // $F: to the passed full filepath
101 // $P: to the full path
102 // $R: to the relative path
103 // $V: to the current Boost version number
104 bool got_expected_result(std::string const& filename,
105 std::string const& result, std::string& expected);
107 // construct a SIZEOF macro definition string and predefine this macro
108 template <typename Context>
109 bool add_sizeof_definition(Context& ctx, char const *name, int value);
111 // construct a MIN macro definition string and predefine this macro
112 template <typename T, typename Context>
113 bool add_min_definition(Context& ctx, char const *name);
115 // construct a MAX macro definition string and predefine this macro
116 template <typename T, typename Context>
117 bool add_max_definition(Context& ctx, char const *name);
119 // Predefine __TESTWAVE_HAS_STRICT_LEXER__
120 template <typename Context>
121 bool add_strict_lexer_definition(Context& ctx);
123 #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS
124 // Predefine __TESTWAVE_SUPPORT_MS_EXTENSIONS__
125 template <typename Context>
126 bool add_support_ms_extensions_definition(Context& ctx);
131 boost::program_options::options_description desc_options;
132 boost::program_options::variables_map const& global_vm;
135 #endif // !defined(BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP)