OFFIS DCMTK  Version 3.6.0
ofstream.h
1 /*
2  *
3  * Copyright (C) 2002-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: ofstd
15  *
16  * Author: Andreas Barth
17  *
18  * Purpose: C++ header to handle standard and old stream libraries.
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:50 $
22  * CVS/RCS Revision: $Revision: 1.11 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef OFSTREAM_H
31 #define OFSTREAM_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #ifdef USE_STD_CXX_INCLUDES
36 
37 #include <iostream>
38 #ifdef HAVE_IOS
39 #include <ios>
40 #endif
41 #include <fstream>
42 #include <iomanip>
43 // For standard STREAMS library: preference for standard stringstream
44 #if defined(HAVE_SSTREAM)
45 #include <sstream>
46 #define USE_STRINGSTREAM
47 #elif defined(HAVE_STRSTREAM)
48 #include <strstream>
49 #else
50 #error DCMTK needs stringstream or strstream type
51 #endif
52 
53 /* DCMTK by default does not anymore pollute the default namespace by
54  * importing namespace std. Earlier releases did this to simplify compatibility
55  * with older compilers where STL classes were not consistently defined
56  * in namespace std. We now have configure macros which should care for this.
57  * If user code still relies on namespace std to be included, compile with
58  * macro USING_STD_NAMESPACE defined.
59  */
60 #ifdef USING_STD_NAMESPACE
61 namespace std { }
62 using namespace std;
63 #endif
64 
65 #else /* USE_STD_CXX_INCLUDES */
66 
67 #include <iostream.h>
68 #include <fstream.h>
69 // For old STREAMS library: preference for strstream
70 #if defined(HAVE_STRSTREA_H) || defined(HAVE_STRSTREAM_H)
71 #ifdef HAVE_STRSTREA_H
72 #include <strstrea.h>
73 #else
74 #include <strstream.h>
75 #endif
76 #elif defined(HAVE_SSTREAM_H)
77 #include <sstream.h>
78 #define USE_STRINGSTREAM
79 #else
80 #error DCMTK needs stringstream or strstream type
81 #endif
82 #include <iomanip.h>
83 
84 #endif
85 
86 #ifdef USE_STRINGSTREAM
87 
88 // define STD_NAMESPACE to std:: if the standard namespace exists
89 #ifndef STD_NAMESPACE
90 #ifdef HAVE_STD_NAMESPACE
91 #define STD_NAMESPACE std::
92 #else
93 #define STD_NAMESPACE
94 #endif
95 #endif
96 
97 #define OFendl STD_NAMESPACE endl
98 
99 typedef STD_NAMESPACE stringstream OFStringStream;
100 typedef STD_NAMESPACE ostringstream OFOStringStream;
101 typedef STD_NAMESPACE istringstream OFIStringStream;
102 
103 #define OFStringStream_ends ""
104 #define OFSTRINGSTREAM_GETOFSTRING(oss, string) \
105  OFString string((oss).str().c_str());
106 // The following two macros define a block structure. Please note that variables
107 // declared between xxx_GETSTR and xxx_FREESTR are only valid within this scope.
108 #define OFSTRINGSTREAM_GETSTR(oss, chptr) \
109 { \
110  STD_NAMESPACE string chptr##__ = (oss).str(); \
111  const char *chptr = chptr##__.c_str();
112 #define OFSTRINGSTREAM_FREESTR(chptr) \
113 }
114 
115 #else /* USE_STRINGSTREAM */
116 
117 typedef strstream OFStringStream;
118 typedef ostrstream OFOStringStream;
119 typedef istrstream OFIStringStream;
120 
121 #define OFStringStream_ends ends
122 #define OFSTRINGSTREAM_GETOFSTRING(oss, string) \
123  char * string##__ = (oss).str(); \
124  OFString string(string##__); \
125  delete[] string##__;
126 // The following two macros define a block structure. Please note that variables
127 // declared between xxx_GETSTR and xxx_FREESTR are only valid within this scope.
128 #define OFSTRINGSTREAM_GETSTR(oss, chptr) \
129 { \
130  const char *chptr = (oss).str();
131 #define OFSTRINGSTREAM_FREESTR(chptr) \
132  delete[] (char *)chptr; \
133 }
134 
135 #endif /* USE_STRINGSTREAM */
136 
137 #endif /* USE_STD_CXX_INCLUDES */
138 
139 
140 /*
141  * CVS/RCS Log:
142  * $Log: ofstream.h,v $
143  * Revision 1.11 2010-10-14 13:15:50 joergr
144  * Updated copyright header. Added reference to COPYRIGHT file.
145  *
146  * Revision 1.10 2007/02/19 15:16:16 meichel
147  * Namespace std is not imported into the default namespace anymore,
148  * unless DCMTK is compiled with macro USING_STD_NAMESPACE defined.
149  *
150  * Revision 1.9 2006/08/15 15:52:23 meichel
151  * Updated all code in module dcmdata to correctly compile when
152  * all standard C++ classes remain in namespace std.
153  *
154  * Revision 1.8 2006/08/14 16:42:02 meichel
155  * Defined two new macros: STD_NAMESPACE is defined to std:: if the standard
156  * namespace exists and empty otherwise. OFendl is defined as std::endl if
157  * the standard namespace exists and as endl otherwise.
158  *
159  * Revision 1.7 2005/12/08 16:06:06 meichel
160  * Changed include path schema for all DCMTK header files
161  *
162  * Revision 1.6 2004/05/07 10:46:32 meichel
163  * Removed unneeded semicolon, reported by gcc 3.4
164  *
165  * Revision 1.5 2004/01/16 10:30:12 joergr
166  * Removed acknowledgements with e-mail addresses from CVS log.
167  *
168  * Revision 1.4 2003/12/05 10:37:41 joergr
169  * Removed leading underscore characters from preprocessor symbols (reserved
170  * symbols). Updated copyright date where appropriate.
171  *
172  * Revision 1.3 2002/12/11 15:54:48 meichel
173  * Added empty namespace std declaration, needed on MSVC.
174  *
175  * Revision 1.2 2002/05/02 14:05:50 joergr
176  * Added support for standard and non-standard string streams (which one is
177  * supported is detected automatically via the configure mechanism).
178  *
179  * Revision 1.1 2002/04/16 13:36:03 joergr
180  * Added configurable support for C++ ANSI standard includes (e.g. streams).
181  *
182  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2