Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/i386/modules/uClibcxx/ios.cpp

1/*Copyright (C) 2004 Garrett A. Kajmowicz
2
3This file is part of the uClibc++ Library.
4
5This library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Lesser General Public
7License as published by the Free Software Foundation; either
8version 2.1 of the License, or (at your option) any later version.
9
10This library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public
16License along with this library; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20#define __UCLIBCXX_COMPILE_IOS__ 1
21
22#include <ios>
23#include <ostream>
24#include <istream>
25#include <cstdio>
26#include <fstream>
27
28namespace std{
29
30
31#ifdef __UCLIBCXX_SUPPORT_CDIR__
32_UCXXLOCAL int ios_base::Init::init_cnt = 0;//Needed to ensure the static value is created
33
34//Create buffers first
35#if __UCLIBCXX_SUPPORT_COUT__
36_UCXXEXPORT filebuf _cout_filebuf;
37#endif
38#if __UCLIBCXX_SUPPORT_CIN__
39_UCXXEXPORT filebuf _cin_filebuf;
40#endif
41#if __UCLIBCXX_SUPPORT_CERR__
42_UCXXEXPORT filebuf _cerr_filebuf;
43#endif
44#if __UCLIBCXX_SUPPORT_CLOG__
45_UCXXEXPORT filebuf _clog_filebuf;
46#endif
47#ifdef __UCLIBCXX_SUPPORT_WCOUT__
48_UCXXEXPORT wfilebuf _wcout_filebuf;
49#endif
50#ifdef __UCLIBCXX_SUPPORT_WCIN__
51_UCXXEXPORT wfilebuf _wcin_filebuf;
52#endif
53#ifdef __UCLIBCXX_SUPPORT_WCERR__
54_UCXXEXPORT wfilebuf _wcerr_filebuf;
55#endif
56#ifdef __UCLIBCXX_SUPPORT_WCLOG__
57_UCXXEXPORT wfilebuf _wclog_filebuf;
58#endif
59
60//Then create streams
61#if __UCLIBCXX_SUPPORT_COUT__
62_UCXXEXPORT ostream cout(&_cout_filebuf);
63#endif
64#if __UCLIBCXX_SUPPORT_CIN__
65_UCXXEXPORT istream cin(&_cin_filebuf);
66#endif
67#if __UCLIBCXX_SUPPORT_CERR__
68_UCXXEXPORT ostream cerr(&_cerr_filebuf);
69#endif
70#if __UCLIBCXX_SUPPORT_CLOG__
71_UCXXEXPORT ostream clog(&_clog_filebuf);
72#endif
73#ifdef __UCLIBCXX_SUPPORT_WCOUT__
74_UCXXEXPORT wostream wcout(&_wcout_filebuf);
75#endif
76#ifdef __UCLIBCXX_SUPPORT_WCIN__
77_UCXXEXPORT wistream wcin(&_wcin_filebuf);
78#endif
79#ifdef __UCLIBCXX_SUPPORT_WCERR__
80_UCXXEXPORT wostream wcerr(&_wcerr_filebuf);
81#endif
82#ifdef __UCLIBCXX_SUPPORT_WCLOG__
83_UCXXEXPORT wostream wclog(&_wclog_filebuf);
84#endif
85
86
87_UCXXEXPORT ios_base::Init::Init(){
88if(init_cnt == 0){//Need to construct cout et al
89#if __UCLIBCXX_SUPPORT_COUT__
90_cout_filebuf.fp = stdout;
91_cout_filebuf.openedFor = ios_base::out;
92#endif
93#if __UCLIBCXX_SUPPORT_CERR__
94_cerr_filebuf.fp = stderr;
95_cerr_filebuf.openedFor = ios_base::out;
96cerr.mformat |= ios_base::unitbuf;
97#endif
98#if __UCLIBCXX_SUPPORT_CLOG__
99_clog_filebuf.fp = stderr;
100_clog_filebuf.openedFor = ios_base::out;
101#endif
102#if __UCLIBCXX_SUPPORT_CIN__
103_cin_filebuf.fp = stdin;
104_cin_filebuf.openedFor = ios_base::in;
105
106#if __UCLIBCXX_SUPPORT_COUT__
107cin.tie(&cout);
108#endif
109
110#endif
111#ifdef __UCLIBCXX_SUPPORT_WCOUT__
112_wcout_filebuf.fp = stdout;
113_wcout_filebuf.openedFor = ios_base::out;
114#endif
115#ifdef __UCLIBCXX_SUPPORT_WCERR__
116_wcerr_filebuf.fp = stderr;
117_wcerr_filebuf.openedFor = ios_base::out;
118wcerr.mformat |= ios_base::unitbuf;
119#endif
120#ifdef __UCLIBCXX_SUPPORT_WCLOG__
121_wclog_filebuf.fp = stderr;
122_wclog_filebuf.openedFor = ios_base::out;
123#endif
124#ifdef __UCLIBCXX_SUPPORT_WCIN__
125_wcin_filebuf.fp = stdin;
126_wcin_filebuf.openedFor = ios_base::in;
127
128#ifdef __UCLIBCXX_SUPPORT_WCOUT__
129wcin.tie(&wcout);
130#endif
131
132#endif
133}
134init_cnt++;
135}
136
137_UCXXEXPORT ios_base::Init::~Init(){
138--init_cnt;
139if(init_cnt==0){
140
141}
142}
143#endif
144
145
146#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__
147
148template _UCXXEXPORT void basic_ios<char, char_traits<char> >::clear(iostate state);
149template _UCXXEXPORT void basic_ios<char, char_traits<char> >::setstate(iostate state);
150
151#endif
152
153
154_UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){
155fmtflags temp = mformat;
156mformat = fmtfl;
157return temp;
158}
159
160_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){
161return flags(flags() | fmtfl);
162}
163
164_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){
165return flags( (flags()& ~mask) | (fmtfl & mask));
166}
167
168_UCXXEXPORT streamsize ios_base::precision(streamsize prec){
169streamsize temp = mprecision;
170mprecision = prec;
171return temp;
172}
173
174_UCXXEXPORT streamsize ios_base::width(streamsize wide){
175streamsize temp = mwidth;
176mwidth = wide;
177return temp;
178}
179
180_UCXXEXPORT locale ios_base::imbue(const locale& loc){
181locale retval = mLocale;
182mLocale = loc;
183return retval;
184}
185
186}
187
188
189
190

Archive Download this file

Revision: 2238