/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/utility/iomanip

  • Committer: edam
  • Date: 2012-02-28 16:50:26 UTC
  • Revision ID: edam@waxworlds.org-20120228165026-pwnwo300xx2e2kg6
removed ulibc, fixed button, added text rendering

Show diffs side-by-side

added added

removed removed

1
 
/*      Copyright (C) 2005 Garrett A. Kajmowicz
2
 
 
3
 
        This file is part of the uClibc++ Library.
4
 
 
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.
9
 
 
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.
14
 
 
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
18
 
*/
19
 
 
20
 
#include <exception>
21
 
#include <ios>
22
 
 
23
 
#ifndef __STD_IOMANIP
24
 
#define __STD_IOMANIP 1
25
 
 
26
 
#pragma GCC visibility push(default)
27
 
 
28
 
namespace std{
29
 
 
30
 
// These are the helper classes which we are going to be using to
31
 
// hold the required data
32
 
 
33
 
class _UCXXEXPORT __resetiosflags{
34
 
public:
35
 
        ios_base::fmtflags m;
36
 
        _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ }
37
 
};
38
 
 
39
 
class _UCXXEXPORT __setiosflags{
40
 
public:
41
 
        ios_base::fmtflags m;
42
 
        _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ }
43
 
};
44
 
 
45
 
class _UCXXEXPORT __setbase{
46
 
public:
47
 
        int base;
48
 
        _UCXXEXPORT __setbase(int b) : base(b){ }
49
 
};
50
 
 
51
 
class _UCXXEXPORT __setfill{
52
 
public:
53
 
        int character;
54
 
        _UCXXEXPORT __setfill(int c): character(c){  }
55
 
};
56
 
 
57
 
class _UCXXEXPORT __setprecision{
58
 
public:
59
 
        int digits;
60
 
        _UCXXEXPORT __setprecision(int n): digits(n) {  }
61
 
};
62
 
 
63
 
class _UCXXEXPORT __setw{
64
 
public:
65
 
        int width;
66
 
        _UCXXEXPORT __setw(int n): width(n) {  }
67
 
};
68
 
 
69
 
 
70
 
//Actual manipulator functions
71
 
 
72
 
inline __resetiosflags resetiosflags(ios_base::fmtflags mask){
73
 
        return __resetiosflags(mask);
74
 
}
75
 
 
76
 
inline __setiosflags setiosflags(ios_base::fmtflags mask){
77
 
        return __setiosflags(mask);
78
 
}
79
 
 
80
 
inline __setbase setbase(int b){
81
 
        return __setbase(b);
82
 
}
83
 
 
84
 
inline __setfill setfill(int c){
85
 
        return __setfill(c);
86
 
}
87
 
 
88
 
inline __setprecision setprecision(int n){
89
 
        return __setprecision(n);
90
 
}
91
 
 
92
 
inline __setw setw(int n){
93
 
        return __setw(n);
94
 
}
95
 
 
96
 
 
97
 
//How to handle interaction with [i|o]stream classes
98
 
 
99
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
100
 
        operator<<(basic_ostream<Ch, Tr>& os, const __resetiosflags s)
101
 
{
102
 
        os.setf(ios_base::fmtflags(0),s.m);
103
 
        return os;
104
 
}
105
 
 
106
 
template<class Ch, class Tr> _UCXXEXPORT basic_istream<Ch, Tr>&
107
 
        operator>>(basic_istream<Ch, Tr>& is, const __resetiosflags s)
108
 
{
109
 
        is.setf(ios_base::fmtflags(0),s.m);
110
 
        return is;
111
 
}
112
 
 
113
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
114
 
        operator<<(basic_ostream<Ch, Tr>& os, const __setiosflags s)
115
 
{
116
 
        os.setf(s.m);
117
 
        return os;
118
 
}
119
 
 
120
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
121
 
        operator<<(basic_ostream<Ch, Tr>& os, const __setbase s)
122
 
{
123
 
        ios_base::fmtflags f(0);
124
 
        switch(s.base){
125
 
                case 8:
126
 
                        f = ios_base::oct;
127
 
                        break;
128
 
                case 10:
129
 
                        f = ios_base::dec;
130
 
                        break;
131
 
                case 16:
132
 
                        f = ios_base::hex;
133
 
                        break;
134
 
                default:
135
 
                        break;
136
 
 
137
 
        }
138
 
        os.setf(f, ios_base::basefield);
139
 
        return os;
140
 
}
141
 
 
142
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
143
 
        operator<<(basic_ostream<Ch, Tr>& os, const __setfill s)
144
 
{
145
 
        os.fill(s.character);
146
 
        return os;
147
 
}
148
 
 
149
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
150
 
        operator<<(basic_ostream<Ch, Tr>& os, const __setprecision s)
151
 
{
152
 
        os.precision(s.digits);
153
 
        return os;
154
 
}
155
 
 
156
 
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
157
 
        operator<<(basic_ostream<Ch, Tr>& os, const __setw s)
158
 
{
159
 
        os.width(s.width);
160
 
        return os;
161
 
}
162
 
 
163
 
 
164
 
 
165
 
}
166
 
 
167
 
#pragma GCC visibility pop
168
 
 
169
 
#endif
170