1/*
2---------------------------------------------------------------------------
3Open Asset Import Library (assimp)
4---------------------------------------------------------------------------
5
6Copyright (c) 2006-2017, assimp team
7
8
9All rights reserved.
10
11Redistribution and use of this software in source and binary forms,
12with or without modification, are permitted provided that the following
13conditions are met:
14
15* Redistributions of source code must retain the above
16copyright notice, this list of conditions and the
17following disclaimer.
18
19* Redistributions in binary form must reproduce the above
20copyright notice, this list of conditions and the
21following disclaimer in the documentation and/or other
22materials provided with the distribution.
23
24* Neither the name of the assimp team, nor the names of its
25contributors may be used to endorse or promote products
26derived from this software without specific prior
27written permission of the assimp team.
28
29THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40---------------------------------------------------------------------------
41*/
42
43/** @file StdOStreamLogStream.h
44* @brief Implementation of StdOStreamLogStream
45*/
46
47#ifndef AI_STROSTREAMLOGSTREAM_H_INC
48#define AI_STROSTREAMLOGSTREAM_H_INC
49
50#include <assimp/LogStream.hpp>
51#include <ostream>
52
53namespace Assimp {
54
55// ---------------------------------------------------------------------------
56/** @class StdOStreamLogStream
57 * @brief Logs into a std::ostream
58 */
59class StdOStreamLogStream : public LogStream {
60public:
61 /** @brief Construction from an existing std::ostream
62 * @param _ostream Output stream to be used
63 */
64 explicit StdOStreamLogStream(std::ostream& _ostream);
65
66 /** @brief Destructor */
67 ~StdOStreamLogStream();
68
69 /** @brief Writer */
70 void write(const char* message);
71
72private:
73 std::ostream& mOstream;
74};
75
76// ---------------------------------------------------------------------------
77// Default constructor
78inline StdOStreamLogStream::StdOStreamLogStream(std::ostream& _ostream)
79: mOstream (_ostream){
80 // empty
81}
82
83// ---------------------------------------------------------------------------
84// Default constructor
85inline StdOStreamLogStream::~StdOStreamLogStream() {
86 // empty
87}
88
89// ---------------------------------------------------------------------------
90// Write method
91inline void StdOStreamLogStream::write(const char* message) {
92 mOstream << message;
93 mOstream.flush();
94}
95
96// ---------------------------------------------------------------------------
97
98} // Namespace Assimp
99
100#endif // guard
101