Changeset 355 for trunk/Include/Classes
- Timestamp:
- Oct 13, 2007, 2:11:22 PM (17 years ago)
- Location:
- trunk/Include/Classes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/ActiveBasic/Strings/SPrintF.ab
r335 r355 119 119 End If 120 120 121 Dim e As Long, signAs Boolean122 Dim s = FloatToChars(x, e, sign)123 124 If signThen121 Dim e As Long, negative As Boolean 122 Dim s = FloatToChars(x, e, negative) 123 124 If negative Then 125 125 .Append("-") 126 126 Else … … 151 151 End If 152 152 153 Dim buf[1023] As TCHAR 154 wsprintf(buf, "%03d", e)' "%+03d", e) wsprintfは+フラグが使えない! 155 Dim ts = New String(buf, 3) 156 .Append(ts) 157 '.Append(FormatLongD(e, 3, 0, Sign) 158 159 If .Length < field Then 160 Dim embeddedSize = .Length - field 161 If flags And Left Then 162 .Append(&h20, embeddedSize) 163 Else 164 Dim insPos As Long 165 If flags And Blank Then 166 insPos++ 167 End If 168 .Insert(insPos, String$(embeddedSize, " ")) 169 End If 170 End If 153 .Append(FormatIntegerD(e, 2, 0, Sign Or Zero)) 154 155 AdjustFieldWidth(sb, field, negative, flags) 171 156 End With 172 157 FormatFloatE = sb.ToString() … … 174 159 175 160 '! DWordの最大値4294967295の文字数 - 1。FormatIntegerU内で使用。 176 Const MaxSize = 9161 Const MaxSizeU = 9 177 162 178 163 /*! … … 187 172 */ 188 173 Function FormatIntegerU(x As DWord, d As DWord, field As DWord, flags As FormatFlags) As String 189 'zero, left 190 174 FormatIntegerU = FormatInteger(x, d, field, flags, 0) 175 End Function 176 177 '! Longの最大値2147483647, -2147483648の符号部を除く文字数 - 1。FormatIntegerU内で使用。 178 Const MaxSizeD = 9 179 180 /*! 181 @brief 符号有り整数をprintfの%u相当の変換で文字列化する関数。 182 @author Egtra 183 @date 2007/10/13 184 @param[in] x 文字列化する整数値。 185 @param[in] d 精度、最小限表示される桁数。DWORD_MAXのとき、指定なしとして、既定値1となる。 186 @param[in] field フィールド幅。 187 @param[in] flags 書式フラグ。 188 @return xの文字列表現 189 */ 190 Function FormatIntegerD(x As Long, d As DWord, field As DWord, flags As FormatFlags) As String 191 Dim dwX As DWord 192 193 Dim signChar As StrChar 194 If x < 0 Then 195 dwX = (-x) As DWord 196 signChar = Asc("-") 197 Else 198 dwX = x As DWord 199 If flags And Sign Then 200 signChar = Asc("+") 201 ElseIf flags And Blank Then 202 signChar = Asc(" ") 203 End If 204 End If 205 206 FormatIntegerD = FormatInteger(dwX, d, field, flags, signChar) 207 End Function 208 209 /*! 210 @brief 整数をprintfの%d, %u相当の変換で文字列化する関数。 211 @author Egtra 212 @date 2007/09/18 213 @param[in] x 文字列化する整数値。 214 @param[in] d 精度、最小限表示される桁数。DWORD_MAXのとき、指定なしとして、既定値1となる。 215 @param[in] field フィールド幅。 216 @param[in] flags 書式フラグ。 217 @param[in] signChar 符号部分の文字。\0なら存在しないとして扱われる。 218 @return xの文字列表現 219 */ 220 Function FormatInteger(x As DWord, d As DWord, field As DWord, flags As FormatFlags, signChar As StrChar) As String 191 221 '左揃えのときまたは精度が指定されているとき、ゼロフラグは無視される。 192 222 If (flags And Left) Or (d <> DWORD_MAX) Then … … 200 230 Dim sb = New System.Text.StringBuilder 201 231 With sb 202 Dim buf[MaxSize] As StrChar 203 Dim i = MaxSize 232 If signChar <> 0 Then 233 .Append(signChar) 234 End If 235 236 Dim buf[MaxSizeU] As StrChar 237 Dim i = MaxSizeU 204 238 While x <> 0 205 239 buf[i] = (x As Int64 Mod 10 + &h30) As StrChar 'Int64への型変換は#117対策 … … 208 242 Wend 209 243 210 Dim len = (MaxSize - i) As Long244 Dim len = (MaxSizeU - i) As Long 211 245 If len < d Then 212 246 .Append(&h30 As StrChar, d - len) … … 215 249 .Append(buf, i + 1, len) 216 250 217 If field > len Then 218 Dim embeddedSize = field - len 251 AdjustFieldWidth(sb, field, signChar <> 0, flags And (Not (Sign Or Blank))) 252 End With 253 FormatInteger = sb.ToString() 254 End Function 255 256 '! QWordの最大値18446744073709551615の文字数 - 1。FormatIntegerLU内で使用。 257 Const MaxSizeLU = 19 258 259 /*! 260 @brief 文字列をフィールド幅まで満たされるように空白などを挿入する。 261 @param [in,out] sb 対象文字列 262 @param [in] field フィールド幅 263 @param [in] hasSign 符号を持っている(負の値か)か否か 264 @param [in] flags フラグ 265 */ 266 Sub AdjustFieldWidth(sb As System.Text.StringBuilder, field As DWord, hasSign As Boolean, flags As FormatFlags) 267 With sb 268 If .Length < field Then 269 Dim embeddedSize = field - .Length 219 270 If flags And Left Then 220 271 .Append(&h20, embeddedSize) 221 272 Else 222 .Insert(0, String$(embeddedSize, " ")) 273 Dim insPos As Long 274 If (flags And Zero) <> 0 Then 275 If ((flags And Blank) Or (flags And Sign) Or hasSign) Then 276 insPos++ 277 End If 278 .Insert(insPos, String$(embeddedSize, "0")) 279 Else 280 .Insert(insPos, String$(embeddedSize, " ")) 281 End If 223 282 End If 224 283 End If 284 225 285 End With 226 FormatIntegerU = sb.ToString() 227 End Function 286 End Sub 228 287 229 288 End Namespace 'Detail -
trunk/Include/Classes/ActiveBasic/Strings/Strings.ab
r272 r355 193 193 194 194 Namespace Detail 195 Function Split(s As String, c As StrChar) As /*System.*/ArrayList '暫定196 Split = New /*System.*/ArrayList195 Function Split(s As String, c As StrChar) As System.Collections.ArrayList 196 Split = New System.Collections.ArrayList 197 197 198 198 Dim last = 0 As Long -
trunk/Include/Classes/System/Collections/ArrayList.ab
r309 r355 2 2 3 3 #require <Classes/System/Collections/misc.ab> 4 5 Namespace System 6 Namespace Collections 4 7 5 8 Class ArrayList … … 351 354 End Class 352 355 353 /* 354 Class ArrayList_Element 355 Public 356 Sub ArrayList_Element() 357 Init(0) 358 End Sub 359 Sub ArrayList_Element(c As Long) 360 Init(c) 361 End Sub 362 363 Sub ~ArrayList_Element() 364 free(Elm) 365 End Sub 366 367 Sub Init(c As Long) 368 If c > 0 Then 369 Elm = malloc(SizeOf (*Object) * c) 370 If Elm = 0 Then 371 ' OutOfMemoryException 372 Debug 373 End If 374 Else 375 Elm = 0 376 End If 377 Size = 0 378 Capacity = c 379 End Sub 380 381 Sub Swap(ByRef x As ArrayList_Element) 382 Dim tmpElm = x.Elm 383 x.Elm = This.Elm 384 This.Elm = tmpElm 385 386 Dim tmpSize = x.Size 387 x.Size = This.Size 388 This.Size = x.Size 389 390 Dim tmpCap = x.Capacity 391 x.Capacity = This.Capacity 392 This.Capacity = tmpCap 393 End Sub 394 395 Elm As **Object 396 Size As Long 397 Capacity As Long 398 End Class 399 */ 356 End Namespace 'Collections 357 End Namespace 'System -
trunk/Include/Classes/System/Collections/misc.ab
r195 r355 3 3 #ifndef __SYSTEM_COLLECTIONS_MISC_AB__ 4 4 #define __SYSTEM_COLLECTIONS_MISC_AB__ 5 6 Namespace System 7 Namespace Collections 5 8 6 9 Interface ICollection … … 114 117 End Class 115 118 119 End Namespace 'Collections 120 End Namespace 'System 121 116 122 #endif '__SYSTEM_COLLECTIONS_MISC_AB__ -
trunk/Include/Classes/index.ab
r353 r355 2 2 #require "./ActiveBasic/Core/TypeInfo.ab" 3 3 #require "./ActiveBasic/Math/Math.ab" 4 #require "./ActiveBasic/Strings/SPrintF.ab"4 '#require "./ActiveBasic/Strings/SPrintF.ab" 5 5 #require "./ActiveBasic/Strings/Strings.ab" 6 6 #require "./ActiveBasic/Windows/CriticalSection.ab"
Note:
See TracChangeset
for help on using the changeset viewer.