1
2
3
4
5
6 using System;
7
8 namespace System.IO
9 {
10 public class StreamWriter : TextWriter
11 {
12 public StreamWriter(const SharedPtr<ByteStream>& stream_) : stream(stream_)
13 {
14 }
15 public void Write(const char* x, long length)
16 {
17 void* buf = x;
18 stream->Write(cast<byte*>(buf), length);
19 }
20 public override void Write(const string& x)
21 {
22 Write(x.Chars(), x.Length());
23 }
24 public override void Write(const wstring& x)
25 {
26 Write(ToUtf8(x));
27 }
28 public override void Write(const ustring& x)
29 {
30 Write(ToUtf8(x));
31 }
32 public override void Write(bool x)
33 {
34 Write(ToString(x));
35 }
36 public override void Write(char x)
37 {
38 Write(ToString(x));
39 }
40 public override void Write(wchar x)
41 {
42 Write(ToString(x));
43 }
44 public override void Write(uchar x)
45 {
46 Write(ToString(x));
47 }
48 public override void Write(sbyte x)
49 {
50 Write(ToString(x));
51 }
52 public override void Write(byte x)
53 {
54 Write(ToString(x));
55 }
56 public override void Write(short x)
57 {
58 Write(ToString(x));
59 }
60 public override void Write(ushort x)
61 {
62 Write(ToString(x));
63 }
64 public override void Write(int x)
65 {
66 Write(ToString(x));
67 }
68 public override void Write(uint x)
69 {
70 Write(ToString(x));
71 }
72 public override void Write(long x)
73 {
74 Write(ToString(x));
75 }
76 public override void Write(ulong x)
77 {
78 Write(ToString(x));
79 }
80 public override void Write(float x)
81 {
82 Write(ToString(x));
83 }
84 public override void Write(double x)
85 {
86 Write(ToString(x));
87 }
88 public override void Write(const Date& date)
89 {
90 Write(date.ToString());
91 }
92 public override void Write(const DateTime& dateTime)
93 {
94 Write(dateTime.ToString());
95 }
96 public override void WriteLine()
97 {
98 Write("\n", 1);
99 }
100 public override void WriteLine(const string& x)
101 {
102 Write(x);
103 WriteLine();
104 }
105 public override void WriteLine(const wstring& x)
106 {
107 Write(x);
108 WriteLine();
109 }
110 public override void WriteLine(const ustring& x)
111 {
112 Write(x);
113 WriteLine();
114 }
115 public override void WriteLine(bool x)
116 {
117 Write(x);
118 WriteLine();
119 }
120 public override void WriteLine(sbyte x)
121 {
122 Write(x);
123 WriteLine();
124 }
125 public override void WriteLine(byte x)
126 {
127 Write(x);
128 WriteLine();
129 }
130 public override void WriteLine(short x)
131 {
132 Write(x);
133 WriteLine();
134 }
135 public override void WriteLine(ushort x)
136 {
137 Write(x);
138 WriteLine();
139 }
140 public override void WriteLine(int x)
141 {
142 Write(x);
143 WriteLine();
144 }
145 public override void WriteLine(uint x)
146 {
147 Write(x);
148 WriteLine();
149 }
150 public override void WriteLine(long x)
151 {
152 Write(x);
153 WriteLine();
154 }
155 public override void WriteLine(ulong x)
156 {
157 Write(x);
158 WriteLine();
159 }
160 public override void WriteLine(float x)
161 {
162 Write(x);
163 WriteLine();
164 }
165 public override void WriteLine(double x)
166 {
167 Write(x);
168 WriteLine();
169 }
170 public override void WriteLine(const Date& date)
171 {
172 Write(date);
173 WriteLine();
174 }
175 public override void WriteLine(const DateTime& dateTime)
176 {
177 Write(dateTime);
178 WriteLine();
179 }
180 public void Flush()
181 {
182 stream->Flush();
183 }
184 public nothrow const SharedPtr<ByteStream>& ContainedStream()
185 {
186 return stream;
187 }
188 private SharedPtr<ByteStream> stream;
189 }
190 }