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