1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGIOSTREAM_H_
40 #define _OSGIOSTREAM_H_
42 #include "OSGConfig.h"
43 #include "OSGBaseDef.h"
50 #define OSG_STREAM_API __cdecl
52 #define OSG_STREAM_API
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 SetIndent(unsigned int uiIndent
) : _uiIndent(uiIndent
) {}
64 unsigned int _uiIndent
;
73 typedef void (*_IncIndent_
)(_IncIndent
);
74 typedef void (*_DecIndent_
)(_DecIndent
);
75 typedef void (*_BeginElem_
)(_BeginElem
);
76 typedef void (*_EndElem_
)(_EndElem
);
77 typedef void (*_EndElemNL_
)(_EndElemNL
);
80 /*! \name Stream Controls
84 /*! \ingroup GrpBaseBaseStreamIO */
85 OSG_BASE_DLLMAPPING
void IncIndent(_IncIndent
);
86 /*! \ingroup GrpBaseBaseStreamIO */
87 OSG_BASE_DLLMAPPING
void DecIndent(_DecIndent
);
88 /*! \ingroup GrpBaseBaseStreamIO */
89 OSG_BASE_DLLMAPPING
void BeginElem(_BeginElem
);
90 /*! \ingroup GrpBaseBaseStreamIO */
91 OSG_BASE_DLLMAPPING
void EndElem (_EndElem
);
92 /*! \ingroup GrpBaseBaseStreamIO */
93 OSG_BASE_DLLMAPPING
void EndElemNL(_EndElemNL
);
97 /*! \ingroup GrpBaseBase
98 \ingroup GrpBaseBaseStreamIO
99 \ingroup GrpLibOSGBase
103 class OSG_BASE_DLLMAPPING OutStream
105 /*========================== PUBLIC =================================*/
109 /*---------------------------------------------------------------------*/
110 /*! \name Constructor */
113 OutStream(std::ostream
&baseStream
);
116 /*---------------------------------------------------------------------*/
117 /*! \name Destructor */
120 virtual ~OutStream(void);
123 /*---------------------------------------------------------------------*/
124 /*! \name formated output */
127 OutStream
&operator<<( long __n
);
128 OutStream
&operator<<( unsigned long __n
);
130 OutStream
&operator<<( bool __n
);
131 OutStream
&operator<<( char __c
);
133 OutStream
&operator<<( short __n
);
134 OutStream
&operator<<( unsigned short __n
);
136 OutStream
&operator<<( int __n
);
137 OutStream
&operator<<( unsigned int __n
);
139 OutStream
&operator<<( long long __n
);
140 OutStream
&operator<<( unsigned long long __n
);
142 OutStream
&operator<<( double __f
);
143 OutStream
&operator<<( float __f
);
145 OutStream
&operator<<( long double __f
);
147 OutStream
&operator<<(const Fixed32
&val
);
149 OutStream
&operator<<(const void *__p
);
151 OutStream
&operator<<(const char *__p
);
152 OutStream
&operator<<(const std::string
&__s
);
155 /*---------------------------------------------------------------------*/
156 /*! \name formated output */
160 OutStream
&operator<<(std::_Setbase __f
);
163 OutStream
&operator<<(std::_Smanip
<Arg
> &__f
);
166 OutStream
&operator<<(std::ostream
& (OSG_STREAM_API
*__pf
)(std::ostream
&));
169 /*---------------------------------------------------------------------*/
170 /*! \name formated output */
173 virtual OutStream
&operator<<( SetIndent
);
174 virtual OutStream
&operator<<(_IncIndent_
);
175 virtual OutStream
&operator<<(_DecIndent_
);
177 virtual OutStream
&operator<<(_BeginElem_
);
178 virtual OutStream
&operator<<(_EndElem_
);
179 virtual OutStream
&operator<<(_EndElemNL_
);
182 /*========================== PROTECTRED =============================*/
186 std::ostream
*_pBaseStream
;
188 /*========================== PRIVATE ================================*/
192 OutStream(const OutStream
&source
);
193 void operator =(const OutStream
&source
);
196 /*! \ingroup GrpBaseBase
197 \ingroup GrpBaseBaseStreamIO
198 \ingroup GrpLibOSGBase
202 template<class ParentT
>
203 class FileStreamMixin
: public ParentT
205 /*========================== PUBLIC =================================*/
209 typedef ParentT Inherited
;
211 /*---------------------------------------------------------------------*/
212 /*! \name Constructor */
215 FileStreamMixin(const char *szFileName
);
218 /*---------------------------------------------------------------------*/
219 /*! \name Destructor */
222 virtual ~FileStreamMixin(void);
225 /*---------------------------------------------------------------------*/
226 /*! \name formated output */
231 operator bool (void);
234 /*========================== PROTECTRED =============================*/
238 std::ofstream _oFileStream
;
240 /*========================== PRIVATE ================================*/
245 /*! \ingroup GrpBaseBase
246 \ingroup GrpBaseBaseStreamIO
247 \ingroup GrpLibOSGBase
251 template<class ParentT
>
252 class IndentOutStreamMixin
: public ParentT
254 /*========================== PUBLIC =================================*/
258 typedef ParentT Inherited
;
260 /*---------------------------------------------------------------------*/
261 /*! \name Constructor */
264 IndentOutStreamMixin(std::ostream
&baseStream
);
267 /*---------------------------------------------------------------------*/
268 /*! \name Destructor */
271 virtual ~IndentOutStreamMixin(void);
274 /*---------------------------------------------------------------------*/
275 /*! \name formated output */
278 virtual IndentOutStreamMixin
&operator<<(SetIndent setIndent
);
280 virtual IndentOutStreamMixin
&operator<<(_IncIndent_
);
281 virtual IndentOutStreamMixin
&operator<<(_DecIndent_
);
282 virtual IndentOutStreamMixin
&operator<<(_BeginElem_
);
283 virtual IndentOutStreamMixin
&operator<<(_EndElem_
);
284 virtual IndentOutStreamMixin
&operator<<(_EndElemNL_
);
287 /*---------------------------------------------------------------------*/
288 /*! \name formated output */
292 /*========================== PROTECTRED =============================*/
296 /*========================== PRIVATE ================================*/
298 std::string _szIndent
;
299 unsigned int _uiIndentStep
;
305 /*! \ingroup GrpBaseBase
306 \ingroup GrpBaseBaseStreamIO
307 \ingroup GrpLibOSGBase
311 class OSG_BASE_DLLMAPPING InStream
313 /*========================== PUBLIC =================================*/
317 /*---------------------------------------------------------------------*/
318 /*! \name Constructor */
321 InStream(std::istream
&baseStream
);
324 /*---------------------------------------------------------------------*/
325 /*! \name Destructor */
328 virtual ~InStream(void);
331 /*========================== PROTECTRED =============================*/
335 std::istream
*_pBaseStream
;
337 /*========================== PRIVATE ================================*/
341 InStream(const InStream
&source
);
342 void operator =(const InStream
&source
);
349 /*! \ingroup GrpBaseBaseStreamIO */
350 typedef FileStreamMixin
<OutStream
> FileOutStream
;
351 /*! \ingroup GrpBaseBaseStreamIO */
352 typedef FileStreamMixin
<IndentOutStreamMixin
<OutStream
> > IndentFileOutStream
;
359 #include "OSGIOStream.inl"
361 #endif // _OSG_IOSTREAM_H_