File: testwave_app.hpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (136 lines) | stat: -rw-r--r-- 5,326 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*=============================================================================
    Boost.Wave: A Standard compliant C++ preprocessor library
    http://www.boost.org/

    Copyright (c) 2001-2013 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(BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP)
#define BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP

#include <string>
#include <vector>

// include boost
#include <boost/config.hpp>

#include "cmd_line_utils.hpp"

///////////////////////////////////////////////////////////////////////////////
class testwave_app
{
public:
    testwave_app(boost::program_options::variables_map const& vm);

    //  Test the given file (i.e. preprocess the file and compare the result
    //  against the embedded 'R' comments, if an error occurs compare the error
    //  message against the given 'E' comments).
    bool test_a_file(std::string filename);

    //  print the current version of this program
    int print_version();

    //  print the copyright statement
    int print_copyright();

    // access the common options used for the command line and the config
    // options inside the test files
    boost::program_options::options_description const& common_options() const
    {
        return desc_options;
    }

    void set_debuglevel(int debuglevel_)
    {
        debuglevel = debuglevel_;
    }
    int get_debuglevel() const
    {
        return debuglevel;
    }

protected:
    //  Read the given file into a string
    bool read_file(std::string const& filename, std::string& instr);

    //  Extract special information from comments marked with the given letter
    bool extract_special_information(std::string const& filename,
        std::string const& instr, char flag, std::string& content);

    //  Extract the expected output and expected hooks information from the
    //  given input data.
    //  The expected output has to be provided inside of special comments which
    //  start with a capital 'R' ('H' for the hooks information). All such
    //  comments are concatenated and returned through the parameter 'expected'
    //  ('expectedhooks' for hooks information).
    bool extract_expected_output(std::string const& filename,
        std::string const& instr, std::string& expected,
        std::string& expectedhooks);

    //  Extracts the required preprocessing options from the given input data
    //  and initializes the given Wave context object accordingly.
    //  We allow the same (applicable) options to be used as are valid for the
    //  wave driver executable.
    template <typename Context>
    bool extract_options(std::string const& filename,
        std::string const& instr, Context& ctx, bool single_line,
        boost::program_options::variables_map& vm);

    //  transfers the options collected in the vm parameter into the given
    //  context
    template <typename Context>
    bool initialise_options(Context& ctx,
        boost::program_options::variables_map const& vm, bool single_line);

    //  Preprocess the given input data and return the generated output through
    //  the parameter 'result'.
    std::tuple<bool, bool>   // pass/fail, suppressed by cfg macro (or not)
    preprocess_file(std::string filename, std::string const& instr,
        std::string& result, std::string& error, std::string& hooks,
        std::string const& expected_cfg_macro, bool single_line = false);

    //  Add special predefined macros to the context object
    template <typename Context>
    bool add_predefined_macros(Context& ctx);

    //  This function compares the real result and the expected one but first
    //  replaces all occurrences in the expected result of
    //      $E: to the result of preprocessing the given expression
    //      $F: to the passed full filepath
    //      $P: to the full path
    //      $R: to the relative path
    //      $V: to the current Boost version number
    bool got_expected_result(std::string const& filename,
        std::string const& result, std::string& expected);

    //  construct a SIZEOF macro definition string and predefine this macro
    template <typename Context>
    bool add_sizeof_definition(Context& ctx, char const *name, int value);

    //  construct a MIN macro definition string and predefine this macro
    template <typename T, typename Context>
    bool add_min_definition(Context& ctx, char const *name);

    //  construct a MAX macro definition string and predefine this macro
    template <typename T, typename Context>
    bool add_max_definition(Context& ctx, char const *name);

    //  Predefine __TESTWAVE_HAS_STRICT_LEXER__
    template <typename Context>
    bool add_strict_lexer_definition(Context& ctx);

#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS
    //  Predefine __TESTWAVE_SUPPORT_MS_EXTENSIONS__
    template <typename Context>
    bool add_support_ms_extensions_definition(Context& ctx);
#endif

private:
    int debuglevel;
    boost::program_options::options_description desc_options;
    boost::program_options::variables_map const& global_vm;
};

#endif // !defined(BOOST_WAVE_LIBS_WAVE_TEST_TESTWAVE_APP_HPP)