source: trunk/ab5.0/ablib/src/Classes/System/IO/BinaryWriter.ab@ 581

Last change on this file since 581 was 581, checked in by イグトランス (egtra), 16 years ago

Unicodeコンパイルで問題になる部分を修正

File size: 5.6 KB
Line 
1
2NameSpace System
3NameSpace IO
4
5Class BinaryWriter
6 Implements System.IDisposable
7
8Public 'constructor
9 /*
10 ストリームへの書き込みを行う BinaryWriter クラスの新しいインスタンスを初期化します。
11 */
12 Sub BinaryWriter()
13 This.OutStream=Nothing
14 End Sub
15
16 /*
17 ストリームへの書き込みを行う BinaryWriter クラスの新しいインスタンスを初期化します。
18 */
19 Sub BinaryWriter(output As System.IO.Stream)
20 This.OutStream=output
21 End Sub
22
23 /*
24 ストリームへの書き込みを行う BinaryWriter クラスの新しいインスタンスを初期化します。
25 */
26 Sub BinaryWriter(output As System.IO.Stream, encoding As System.Text.Encoding)
27 This.OutStream=output
28 This.Enc = encoding
29 End Sub
30
31 Sub ~BinaryWriter()
32 This.Dispose()
33 End Sub
34
35Public 'field
36 /*
37 バッキング ストアを持たない BinaryWriter を指定します。
38 */
39/* Null As BinaryWriter*/
40
41Protected 'field
42 /*
43 基になるストリームを保持します。
44 */
45 OutStream As System.IO.Stream
46
47Public 'property
48 /*
49 BinaryWriter の基になるストリームを取得します。
50 */
51 Function BaseStream() As Stream
52 Return OutStream
53 End Function
54
55Public 'method
56 /*
57 現在の BinaryWriter と基になるストリームを閉じます。
58 */
59 Sub Close()
60 This.Dispose(True)
61 End Sub
62
63 /*
64 現在のライタのすべてのバッファをクリアし、バッファ内のデータを基になるデバイスに書き込みます。
65 */
66 Sub Flush()
67 End Sub
68
69 /*
70 現在のストリーム内の位置を設定します。
71 */
72 Function Seek(offset As Long, origin As SeekOrigin) As Int64
73 This.OutStream.Seek(offset, origin)
74 End Function
75
76
77 /*
78 現在のストリームに1バイトBoolean値を書き込みます。値0はFalseを表し、値1はTrueを表します。
79 */
80 Sub Write(value As Boolean)
81 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Boolean))
82 End Sub
83
84 /*
85 現在のストリームに符号なしバイトを書き込み、ストリームの位置を1バイトだけ進めます。
86 */
87 Sub WriteByte(value As Byte)
88 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Byte))
89 End Sub
90
91 /*
92 基になるストリームにバイト配列を書き込みます。
93 */
94/* Sub Write(value As Array<Byte>)
95 TODO
96 End Sub*/
97
98 /*
99 現在のストリームにUnicode 文字を書き込み、使用した Encoding とストリームに書き込んだ特定の文字に従ってストリームの現在位置を進めます。
100 */
101 Sub Write(value As Char)
102 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Char))
103 End Sub
104
105 /*
106 現在のストリームに文字配列を書き込み、使用した Encoding とストリームに書き込んだ特定の文字に従ってストリームの現在位置を進めます。
107 */
108/* Sub Write(value As Array<Char>)
109 TODO
110 End Sub*/
111
112 /*
113 現在のストリームに10進数値を書き込み、ストリームの位置を16バイトだけ進めます。
114 */
115/* Sub Write(value As Decimal)
116 TODO
117 End Sub*/
118
119 /*
120 現在のストリームに8バイト浮動小数点値を書き込み、ストリームの位置を 8バイトだけ進めます。
121 */
122 Sub Write(value As Double)
123 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Double))
124 End Sub
125
126 /*
127 現在のストリームに2バイト符号付き整数を書き込み、ストリームの位置を 2バイトだけ進めます。
128 */
129 Sub Write(value As Integer)
130 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Integer))
131 End Sub
132
133 /*
134 現在のストリームに4バイト符号付き整数を書き込み、ストリームの位置を 4バイトだけ進めます。
135 */
136 Sub Write(value As Long)
137 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Long))
138 End Sub
139
140 /*
141 現在のストリームに8バイト符号付き整数を書き込み、ストリームの位置を 8バイトだけ進めます。
142 */
143 Sub Write(value As Int64)
144 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Int64))
145 End Sub
146
147 /*
148 現在のストリームに符号付きバイトを書き込み、ストリームの位置を1バイトだけ進めます。
149 */
150 Sub WriteSByte(value As SByte)
151 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(SByte))
152 End Sub
153
154 /*
155 現在のストリームに4バイト浮動小数点値を書き込み、ストリームの位置を 4バイトだけ進めます。
156 */
157 Sub Write(value As Single)
158 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Single))
159 End Sub
160
161 /*
162 文字長プリフィックスを持つ文字列を、BinaryWriter の現在のエンコーディングでこのストリームに書き込み、使用したエンコーディングとストリームに書き込んだ特定の文字に従ってストリームの現在位置を進めます。
163 */
164 Sub Write(value As String)
165 This.OutStream.Write( ToTCStr(value) As *Byte, 0, value.Length()*SizeOf(TCHAR))
166 End Sub
167#ifndef UNICODE
168 /*
169 現在のストリームに2バイト符号なし整数を書き込み、ストリームの位置を 2バイトだけ進めます。
170 */
171 Sub Write(value As Word)
172 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(Word))
173 End Sub
174#endif
175 /*
176 現在のストリームに4バイト符号なし整数を書き込み、ストリームの位置を 4バイトだけ進めます。
177 */
178 Sub Write(value As DWord)
179 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(DWord))
180 End Sub
181
182 /*
183 現在のストリームに8バイト符号なし整数を書き込み、ストリームの位置を 8バイトだけ進めます。
184 */
185 Sub Write(value As QWord)
186 This.OutStream.Write( VarPtr(value) As *Byte, 0, SizeOf(QWord))
187 End Sub
188
189 /*
190 現在のストリームにバイト配列の特定の領域を書き込みます。
191 */
192 Sub Write(buffer As *Byte, index As Long, count As Long)
193 This.OutStream.Write( VarPtr(buffer[index]) As *Byte, 0, count)
194 End Sub
195
196 /*
197 現在のストリームに文字配列の特定の領域を書き込み、使用した Encoding とストリームに書き込んだ特定の文字に従ってストリームの現在位置を進めます。
198 */
199/* Sub Write(chars As *Char, index As Long, count As Long)
200 End Sub*/
201
202 /*
203 32 ビット整数を圧縮形式で書き込みます。
204 */
205/* Sub Write7BitEncodedInt()
206 End Sub*/
207
208 /*
209 BinaryWriter によって使用されているアンマネージ リソースを解放し、オプションでマネージ リソースも解放します。
210 */
211
212Protected
213 Virtual Sub Dispose(disposing As Boolean)
214 This.OutStream.Close()
215 End Sub
216
217Private
218 Enc As System.Text.Encoding
219End Class
220
221End Namespace
222End Namespace
Note: See TracBrowser for help on using the repository browser.