2 // Automated Testing Framework (atf)
4 // Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
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_
38 #include <atf-c++/io.hpp>
39 #include <atf-c++/tests.hpp>
44 // ------------------------------------------------------------------------
45 // The "format_error" class.
46 // ------------------------------------------------------------------------
49 //! \brief A class to signal format errors in external data formats.
51 //! This error class is used to signal format errors while parsing some
52 //! externalized representation of a data structure.
54 class format_error
: public std::runtime_error
{
56 format_error(const std::string
&);
59 // ------------------------------------------------------------------------
60 // The "atf_atffile_reader" class.
61 // ------------------------------------------------------------------------
63 class atf_atffile_reader
{
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);
73 atf_atffile_reader(std::istream
&);
74 virtual ~atf_atffile_reader(void);
79 // ------------------------------------------------------------------------
80 // The "atf_config_reader" class.
81 // ------------------------------------------------------------------------
83 class atf_config_reader
{
87 virtual void got_var(const std::string
&, const std::string
&);
88 virtual void got_eof(void);
91 atf_config_reader(std::istream
&);
92 virtual ~atf_config_reader(void);
97 // ------------------------------------------------------------------------
98 // The "atf_tcs_reader" class.
99 // ------------------------------------------------------------------------
101 class atf_tcs_reader
{
104 void read_out_err(void*,
105 atf::io::unbuffered_istream
&,
106 atf::io::unbuffered_istream
&);
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);
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
{
129 std::ostream
& m_cout
;
130 std::ostream
& m_cerr
;
132 size_t m_ntcs
, m_curtc
;
133 std::string m_tcname
;
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
{
149 void read_info(void*);
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);
166 atf_tps_reader(std::istream
&);
167 virtual ~atf_tps_reader(void);
172 // ------------------------------------------------------------------------
173 // The "atf_tps_writer" class.
174 // ------------------------------------------------------------------------
176 class atf_tps_writer
{
179 std::string m_tpname
, m_tcname
;
182 atf_tps_writer(std::ostream
&);
184 void info(const std::string
&, const std::string
&);
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
199 #endif // !defined(_ATF_CXX_FORMATS_HPP_)