Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / atf / dist / atf-c++ / formats.hpp
bloba4d6c4e5908088ce3660ac1cfc837be344504939
1 //
2 // Automated Testing Framework (atf)
3 //
4 // Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #if !defined(_ATF_CXX_FORMATS_HPP_)
31 #define _ATF_CXX_FORMATS_HPP_
33 #include <istream>
34 #include <ostream>
35 #include <stdexcept>
36 #include <string>
38 #include <atf-c++/io.hpp>
39 #include <atf-c++/tests.hpp>
41 namespace atf {
42 namespace formats {
44 // ------------------------------------------------------------------------
45 // The "format_error" class.
46 // ------------------------------------------------------------------------
48 //!
49 //! \brief A class to signal format errors in external data formats.
50 //!
51 //! This error class is used to signal format errors while parsing some
52 //! externalized representation of a data structure.
53 //!
54 class format_error : public std::runtime_error {
55 public:
56 format_error(const std::string&);
59 // ------------------------------------------------------------------------
60 // The "atf_atffile_reader" class.
61 // ------------------------------------------------------------------------
63 class atf_atffile_reader {
64 std::istream& m_is;
66 protected:
67 virtual void got_conf(const std::string&, const std::string &);
68 virtual void got_prop(const std::string&, const std::string &);
69 virtual void got_tp(const std::string&, bool);
70 virtual void got_eof(void);
72 public:
73 atf_atffile_reader(std::istream&);
74 virtual ~atf_atffile_reader(void);
76 void read(void);
79 // ------------------------------------------------------------------------
80 // The "atf_config_reader" class.
81 // ------------------------------------------------------------------------
83 class atf_config_reader {
84 std::istream& m_is;
86 protected:
87 virtual void got_var(const std::string&, const std::string &);
88 virtual void got_eof(void);
90 public:
91 atf_config_reader(std::istream&);
92 virtual ~atf_config_reader(void);
94 void read(void);
97 // ------------------------------------------------------------------------
98 // The "atf_tcs_reader" class.
99 // ------------------------------------------------------------------------
101 class atf_tcs_reader {
102 std::istream& m_is;
104 void read_out_err(void*,
105 atf::io::unbuffered_istream&,
106 atf::io::unbuffered_istream&);
108 protected:
109 virtual void got_ntcs(size_t);
110 virtual void got_tc_start(const std::string&);
111 virtual void got_tc_end(const atf::tests::tcr&);
112 virtual void got_stdout_line(const std::string&);
113 virtual void got_stderr_line(const std::string&);
114 virtual void got_eof(void);
116 public:
117 atf_tcs_reader(std::istream&);
118 virtual ~atf_tcs_reader(void);
120 void read(atf::io::unbuffered_istream&, atf::io::unbuffered_istream&);
123 // ------------------------------------------------------------------------
124 // The "atf_tcs_writer" class.
125 // ------------------------------------------------------------------------
127 class atf_tcs_writer {
128 std::ostream& m_os;
129 std::ostream& m_cout;
130 std::ostream& m_cerr;
132 size_t m_ntcs, m_curtc;
133 std::string m_tcname;
135 public:
136 atf_tcs_writer(std::ostream&, std::ostream&, std::ostream&, size_t);
138 void start_tc(const std::string&);
139 void end_tc(const atf::tests::tcr&);
142 // ------------------------------------------------------------------------
143 // The "atf_tps_reader" class.
144 // ------------------------------------------------------------------------
146 class atf_tps_reader {
147 std::istream& m_is;
149 void read_info(void*);
150 void read_tp(void*);
151 void read_tc(void*);
153 protected:
154 virtual void got_info(const std::string&, const std::string&);
155 virtual void got_ntps(size_t);
156 virtual void got_tp_start(const std::string&, size_t);
157 virtual void got_tp_end(const std::string&);
159 virtual void got_tc_start(const std::string&);
160 virtual void got_tc_stdout_line(const std::string&);
161 virtual void got_tc_stderr_line(const std::string&);
162 virtual void got_tc_end(const atf::tests::tcr&);
163 virtual void got_eof(void);
165 public:
166 atf_tps_reader(std::istream&);
167 virtual ~atf_tps_reader(void);
169 void read(void);
172 // ------------------------------------------------------------------------
173 // The "atf_tps_writer" class.
174 // ------------------------------------------------------------------------
176 class atf_tps_writer {
177 std::ostream& m_os;
179 std::string m_tpname, m_tcname;
181 public:
182 atf_tps_writer(std::ostream&);
184 void info(const std::string&, const std::string&);
185 void ntps(size_t);
187 void start_tp(const std::string&, size_t);
188 void end_tp(const std::string&);
190 void start_tc(const std::string&);
191 void stdout_tc(const std::string&);
192 void stderr_tc(const std::string&);
193 void end_tc(const atf::tests::tcr&);
196 } // namespace formats
197 } // namespace atf
199 #endif // !defined(_ATF_CXX_FORMATS_HPP_)