- Timestamp:
- Nov 17, 2007, 10:01:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/ActiveBasic/Strings/SPrintF.ab
r383 r384 926 926 927 927 /*! 928 @brief SPrintfから呼ばれる浮動小数点数用書式文字列化関数 928 929 @author Egtra 929 930 @date 2007/10/28 … … 943 944 944 945 /*! 946 @brief SPrintfから呼ばれる整数用書式文字列化関数 945 947 @author Egtra 946 948 @date 2007/10/28 … … 1054 1056 Function ReadInt(ByRef fmt As *StrChar, params As *Object, ByRef paramsCount As SIZE_T, ByRef ret As Long) As Boolean 1055 1057 If fmt[0] = &h2a Then '* 1056 fmt ++ 'p1058 fmt = VarPtr(fmt[1]) 'po 1057 1059 ret = params[paramsCount] As System.Int32 1058 1060 paramsCount++ … … 1100 1102 Exit Do 1101 1103 End Select 1102 fmt ++ 'p1104 fmt = VarPtr(fmt[1]) 'po 1103 1105 Loop 1104 1106 ReadFlags = True … … 1143 1145 1144 1146 If fmt[0] = &h2e Then '. 1145 fmt ++1147 fmt = VarPtr(fmt[1]) 'po 1146 1148 Dim t As Long 1147 1149 ReadPrecision = 0 … … 1155 1157 End If 1156 1158 End Function 1159 1160 #ifdef _WIN64 1161 Const PtrLength = 1 1162 #else 1163 Const PtrLength = 0 1164 #endif 1157 1165 1158 1166 /*! … … 1170 1178 Case &h68 'h 1171 1179 lengthSpec-- 1172 Case &h6a 'j (u)intmax_t 1180 Case &h6a 'j (u)intmax_t = QWord, Int64 1173 1181 lengthSpec = 1 1174 #ifdef _WIN641175 1182 Case &h74 't ptrdiff_t 1176 lengthSpec = 1 1177 Case &h7a 'z (s)size_t, 1178 lengthSpec = 1 1179 #else 1180 Case &h74 't ptrdiff_t 1181 lengthSpec = 0 1182 Case &h7a 'z (s)size_t, 1183 lengthSpec = 0 1184 #endif 1183 lengthSpec = PtrLength 1184 Case &h7a 'z (s)size_t 1185 lengthSpec = PtrLength 1186 Case &h70 'p VoidPtr 本来は変換指定子だが、ここで先読み 1187 lengthSpec = PtrLength 1188 Exit Sub 'fmtを進められると困るので、ここで脱出 1185 1189 Case Else 1186 1190 Exit Sub 1187 1191 End Select 1188 fmt ++ 'p1192 fmt = VarPtr(fmt[1]) 'po 1189 1193 Loop 1190 1194 End Sub 1191 1195 1192 1196 /*! 1193 @author Egtra 1194 @date 2007/10/27 1197 @biref Cのsprintfのような書式文字列出力関数 1198 @author Egtra 1199 @date 2007/10/27 1200 @param[in] format 書式文字列。詳細は開発Wiki参照。 1201 @param[in, out] params 変換対象の配列。n = 0のときにはNULLも可。 1202 @param[in] n paramsの個数。 1203 @return 書式化された文字列。 1195 1204 @todo %nへの対応 1196 1205 */ … … 1201 1210 Dim s = New System.Text.StringBuilder 1202 1211 Do 1203 Dim last = format.Length - ( fmt - StrPtr(format)) As Long 'p1212 Dim last = format.Length - (((fmt - StrPtr(format)) \ SizeOf (StrChar)) As LONG_PTR) As Long 'po 1204 1213 Dim pos = ActiveBasic.Strings.ChrFind(fmt, last, &h25 As StrChar) '&h25 = % 1205 1214 If pos = -1 Then … … 1209 1218 '%以前の部分 1210 1219 s.Append(fmt, 0, pos) 1211 fmt += pos + 1 'p1220 fmt = VarPtr(fmt[pos + 1]) 'po 1212 1221 'フラグの読取 1213 1222 Dim flags = None As FormatFlags … … 1239 1248 Case &h58 'X 1240 1249 FormatInteger(s, TraitsIntegerX, params[i], False, typeWidth, precision, fieldWidth, flags Or Cap) 1250 '現状ではVoidPtrを引数にする手段は無いはず 1251 ' Case &h58 'p 1252 ' FormatInteger(s, TraitsIntegerX, params[i], False, typeWidth, precision, fieldWidth, flags Or Cap) 1241 1253 Case &h65 'e 1242 1254 FormatFloat(s, AddressOf(FormatFloatE), params[i], precision, fieldWidth, flags) … … 1266 1278 Exit Do 1267 1279 End Select 1268 fmt ++ 'p1280 fmt = VarPtr(fmt[1]) 'po 1269 1281 i++ 1270 1282 Loop
Note:
See TracChangeset
for help on using the changeset viewer.