1
/* Copyright (C) 2004 Garrett A. Kajmowicz
3
This file is part of the uClibc++ Library.
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#define __UCLIBCXX_COMPILE_IOS__ 1
27
#include <HardwareSerial.h>
35
#ifdef __UCLIBCXX_SUPPORT_CDIR__
36
_UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created
38
//Create buffers first
39
#ifdef __UCLIBCXX_SUPPORT_COUT__
40
_UCXXEXPORT filebuf _cout_filebuf;
42
#ifdef __UCLIBCXX_SUPPORT_CIN__
43
_UCXXEXPORT filebuf _cin_filebuf;
45
#ifdef __UCLIBCXX_SUPPORT_CERR__
46
_UCXXEXPORT filebuf _cerr_filebuf;
48
#ifdef __UCLIBCXX_SUPPORT_CLOG__
49
_UCXXEXPORT filebuf _clog_filebuf;
51
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
52
_UCXXEXPORT wfilebuf _wcout_filebuf;
54
#ifdef __UCLIBCXX_SUPPORT_WCIN__
55
_UCXXEXPORT wfilebuf _wcin_filebuf;
57
#ifdef __UCLIBCXX_SUPPORT_WCERR__
58
_UCXXEXPORT wfilebuf _wcerr_filebuf;
60
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
61
_UCXXEXPORT wfilebuf _wclog_filebuf;
67
#ifdef __UCLIBCXX_SUPPORT_COUT__
68
_UCXXEXPORT ostream cout(&_cout_filebuf);
70
#ifdef __UCLIBCXX_SUPPORT_CIN__
71
_UCXXEXPORT istream cin(&_cin_filebuf);
73
#ifdef __UCLIBCXX_SUPPORT_CERR__
74
_UCXXEXPORT ostream cerr(&_cerr_filebuf);
76
#ifdef __UCLIBCXX_SUPPORT_CLOG__
77
_UCXXEXPORT ostream clog(&_clog_filebuf);
79
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
80
_UCXXEXPORT wostream wcout(&_wcout_filebuf);
82
#ifdef __UCLIBCXX_SUPPORT_WCIN__
83
_UCXXEXPORT wistream wcin(&_wcin_filebuf);
85
#ifdef __UCLIBCXX_SUPPORT_WCERR__
86
_UCXXEXPORT wostream wcerr(&_wcerr_filebuf);
88
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
89
_UCXXEXPORT wostream wclog(&_wclog_filebuf);
93
#ifdef __UCLIBCXX_SUPPORT_COUT__
94
_UCXXEXPORT ohserialstream cout(Serial);
96
#ifdef __UCLIBCXX_SUPPORT_CIN__
97
_UCXXEXPORT ihserialstream cin(Serial);
99
#ifdef __UCLIBCXX_SUPPORT_CERR__
100
_UCXXEXPORT ohserialstream cerr(Serial);
102
#ifdef __UCLIBCXX_SUPPORT_CLOG__
103
_UCXXEXPORT ohserialstream clog(Serial);
106
_UCXXEXPORT ios_base::Init::Init(){
107
if(init_cnt == 0){ //Need to construct cout et al
111
#ifdef __UCLIBCXX_SUPPORT_COUT__
112
_cout_filebuf.fp = stdout;
113
_cout_filebuf.openedFor = ios_base::out;
115
#ifdef __UCLIBCXX_SUPPORT_CERR__
116
_cerr_filebuf.fp = stderr;
117
_cerr_filebuf.openedFor = ios_base::out;
118
cerr.mformat |= ios_base::unitbuf;
120
#ifdef __UCLIBCXX_SUPPORT_CLOG__
121
_clog_filebuf.fp = stderr;
122
_clog_filebuf.openedFor = ios_base::out;
124
#ifdef __UCLIBCXX_SUPPORT_CIN__
125
_cin_filebuf.fp = stdin;
126
_cin_filebuf.openedFor = ios_base::in;
128
#ifdef __UCLIBCXX_SUPPORT_COUT__
133
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
134
_wcout_filebuf.fp = stdout;
135
_wcout_filebuf.openedFor = ios_base::out;
137
#ifdef __UCLIBCXX_SUPPORT_WCERR__
138
_wcerr_filebuf.fp = stderr;
139
_wcerr_filebuf.openedFor = ios_base::out;
140
wcerr.mformat |= ios_base::unitbuf;
142
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
143
_wclog_filebuf.fp = stderr;
144
_wclog_filebuf.openedFor = ios_base::out;
146
#ifdef __UCLIBCXX_SUPPORT_WCIN__
147
_wcin_filebuf.fp = stdin;
148
_wcin_filebuf.openedFor = ios_base::in;
150
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
154
#endif // not Arduino
161
_UCXXEXPORT ios_base::Init::~Init(){
170
#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__
172
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::clear(iostate state);
173
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::setstate(iostate state);
178
_UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){
179
fmtflags temp = mformat;
184
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){
185
return flags(flags() | fmtfl);
188
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){
189
return flags( (flags()& ~mask) | (fmtfl & mask));
192
_UCXXEXPORT streamsize ios_base::precision(streamsize prec){
193
streamsize temp = mprecision;
197
_UCXXEXPORT streamsize ios_base::width(streamsize wide){
198
streamsize temp = mwidth;
203
_UCXXEXPORT locale ios_base::imbue(const locale& loc){
204
locale retval = mLocale;