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