Stream.st
changeset 19604 db92dc60b19d
parent 19571 1bf42824967f
child 19607 34208e6488b8
equal deleted inserted replaced
19603:635197c5e78b 19604:db92dc60b19d
  1031     "read a 4-byte IEEE single precision float number"
  1031     "read a 4-byte IEEE single precision float number"
  1032 
  1032 
  1033     ^ ShortFloat readBinaryIEEESingleFrom:self MSB:msbFirst
  1033     ^ ShortFloat readBinaryIEEESingleFrom:self MSB:msbFirst
  1034 !
  1034 !
  1035 
  1035 
       
  1036 nextInt16LSB
       
  1037     "return a signed short (2 bytes) in LSB-first order from the stream.
       
  1038      The receiver must support reading of binary bytes."
       
  1039 
       
  1040     ^ self nextInt16MSB:false
       
  1041 !
       
  1042 
       
  1043 nextInt16MSB
       
  1044     "return a signed short (2 bytes) in MSB-first order from the stream.
       
  1045      The receiver must support reading of binary bytes."
       
  1046 
       
  1047     ^ self nextInt16MSB:true
       
  1048 !
       
  1049 
  1036 nextInt16MSB:msbFlag
  1050 nextInt16MSB:msbFlag
  1037     "return a signed short (2 bytes) from the stream.
  1051     "return a signed short (2 bytes) from the stream.
  1038      The receiver must support reading of binary bytes.
  1052      The receiver must support reading of binary bytes.
  1039 
  1053 
  1040      The msbFlag argument controls if the integer is to be read with
  1054      The msbFlag argument controls if the integer is to be read with
  1069 !
  1083 !
  1070 
  1084 
  1071 nextInt16Net
  1085 nextInt16Net
  1072     "return a signed short (2 bytes) in network byte order from the stream.
  1086     "return a signed short (2 bytes) in network byte order from the stream.
  1073      The receiver must support reading of binary bytes.
  1087      The receiver must support reading of binary bytes.
  1074      Network byte order is MSB per definition"
  1088      Network byte order is MSB-first per definition"
  1075 
  1089 
  1076     ^ self nextInt16MSB:true
  1090     ^ self nextInt16MSB:true
  1077 
  1091 
  1078     "Created: 10.1.1996 / 19:49:41 / cg"
  1092     "Created: 10.1.1996 / 19:49:41 / cg"
  1079 !
  1093 !
  1104      ((ReadStream on:#[16rFF 16r20 16r30]) nextInt24MSB:false) hexPrintString
  1118      ((ReadStream on:#[16rFF 16r20 16r30]) nextInt24MSB:false) hexPrintString
  1105 
  1119 
  1106      ((ReadStream on:#[16rFF 16r20 16r30]) nextInt24MSB:true) hexPrintString
  1120      ((ReadStream on:#[16rFF 16r20 16r30]) nextInt24MSB:true) hexPrintString
  1107      ((ReadStream on:#[16r10 16r20 16rFF]) nextInt24MSB:false) hexPrintString
  1121      ((ReadStream on:#[16r10 16r20 16rFF]) nextInt24MSB:false) hexPrintString
  1108     "
  1122     "
       
  1123 !
       
  1124 
       
  1125 nextInt32LSB
       
  1126     "return a signed long (4 bytes) in LSB-first order from the stream.
       
  1127      The receiver must support reading of binary bytes."
       
  1128 
       
  1129     ^ self nextInt32MSB:false
       
  1130 !
       
  1131 
       
  1132 nextInt32MSB
       
  1133     "return a signed long (4 bytes) in MSB-first order from the stream.
       
  1134      The receiver must support reading of binary bytes."
       
  1135 
       
  1136     ^ self nextInt32MSB:true
  1109 !
  1137 !
  1110 
  1138 
  1111 nextInt32MSB:msbFlag
  1139 nextInt32MSB:msbFlag
  1112     "return a signed long (4 bytes) from the stream.
  1140     "return a signed long (4 bytes) from the stream.
  1113      The receiver must support reading of binary bytes.
  1141      The receiver must support reading of binary bytes.
  1170     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1198     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1171 !
  1199 !
  1172 
  1200 
  1173 nextInt32Net
  1201 nextInt32Net
  1174     "return a signed long (4 bytes) in network byte order from the stream.
  1202     "return a signed long (4 bytes) in network byte order from the stream.
       
  1203      The receiver must support reading of binary bytes.
       
  1204      Network byte order is MSB-first per definition"
       
  1205 
       
  1206     ^ self nextInt32MSB:true
       
  1207 
       
  1208     "Created: 10.1.1996 / 19:49:28 / cg"
       
  1209 !
       
  1210 
       
  1211 nextInt64LSB
       
  1212     "return a signed longlong (also called hyper) (8 bytes) in LSB-first order from the stream.
  1175      The receiver must support reading of binary bytes."
  1213      The receiver must support reading of binary bytes."
  1176 
  1214 
  1177     ^ self nextInt32MSB:true
  1215     ^ self nextInt64MSB:false
  1178 
  1216 !
  1179     "Created: 10.1.1996 / 19:49:28 / cg"
  1217 
       
  1218 nextInt64MSB
       
  1219     "return a signed longlong (also called hyper) (8 bytes) in MSB-first order from the stream.
       
  1220      The receiver must support reading of binary bytes."
       
  1221 
       
  1222     ^ self nextInt64MSB:true
  1180 !
  1223 !
  1181 
  1224 
  1182 nextInt64MSB:msbFlag
  1225 nextInt64MSB:msbFlag
  1183     "return a signed hyper (8 bytes) from the stream.
  1226     "return a signed longlong (also called hyper) (8 bytes) from the stream.
  1184      The receiver must support reading of binary bytes.
  1227      The receiver must support reading of binary bytes.
  1185 
  1228 
  1186      The msbFlag argument controls if the integer is to be read with
  1229      The msbFlag argument controls if the integer is to be read with
  1187      most-significant-byte-first (true) or least-first (false).
  1230      most-significant-byte-first (true) or least-first (false).
  1188      This interface is provided to allow talking to external programs,
  1231      This interface is provided to allow talking to external programs,
  1231 
  1274 
  1232     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1275     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1233 !
  1276 !
  1234 
  1277 
  1235 nextInt64Net
  1278 nextInt64Net
  1236     "return a signed longlong (8 bytes) in network byte order from the stream.
  1279     "return a signed longlong (also called hyper) (8 bytes) in network byte order from the stream.
  1237      The receiver must support reading of binary bytes."
  1280      The receiver must support reading of binary bytes.
       
  1281      Network byte order is MSB-first per definition"
  1238 
  1282 
  1239     ^ self nextInt64MSB:true
  1283     ^ self nextInt64MSB:true
  1240 !
  1284 !
  1241 
  1285 
  1242 nextNumber:numBytes 
  1286 nextNumber:numBytes 
  1384     "
  1428     "
  1385 
  1429 
  1386     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1430     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1387 !
  1431 !
  1388 
  1432 
       
  1433 nextUnsignedInt16LSB
       
  1434     "return an unsigned short (2 bytes) in LSB-first order from the stream.
       
  1435      The receiver must support reading of binary bytes."
       
  1436 
       
  1437     ^ self nextUnsignedInt16MSB:false
       
  1438 !
       
  1439 
       
  1440 nextUnsignedInt16MSB
       
  1441     "return an unsigned short (2 bytes) in MSB-first order from the stream.
       
  1442      The receiver must support reading of binary bytes."
       
  1443 
       
  1444     ^ self nextUnsignedInt16MSB:true
       
  1445 !
       
  1446 
  1389 nextUnsignedInt16MSB:msbFlag
  1447 nextUnsignedInt16MSB:msbFlag
  1390     "return an unsigned short (2 bytes) from the stream.
  1448     "return an unsigned short (2 bytes) from the stream.
  1391      The receiver must support reading of binary bytes.
  1449      The receiver must support reading of binary bytes.
  1392 
  1450 
  1393      The msbFlag argument controls if the integer is to be read with
  1451      The msbFlag argument controls if the integer is to be read with
  1421 !
  1479 !
  1422 
  1480 
  1423 nextUnsignedInt16Net
  1481 nextUnsignedInt16Net
  1424     "return an unsigned short (2 bytes) in network byte order from the stream.
  1482     "return an unsigned short (2 bytes) in network byte order from the stream.
  1425      The receiver must support reading of binary bytes.
  1483      The receiver must support reading of binary bytes.
  1426      Network byte order is MSB per definition"
  1484      Network byte order is MSB-first per definition"
  1427 
  1485 
  1428     ^ self nextUnsignedInt16MSB:true
  1486     ^ self nextUnsignedInt16MSB:true
  1429 
  1487 
  1430     "Created: 10.1.1996 / 19:50:02 / cg"
  1488     "Created: 10.1.1996 / 19:50:02 / cg"
  1431 !
  1489 !
  1463      ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:true) hexPrintString
  1521      ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:true) hexPrintString
  1464      ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:false) hexPrintString
  1522      ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:false) hexPrintString
  1465     "
  1523     "
  1466 !
  1524 !
  1467 
  1525 
       
  1526 nextUnsignedInt32LSB
       
  1527     "return an unsigned long (4 bytes) in LSB-first order from the stream.
       
  1528      The receiver must support reading of binary bytes."
       
  1529 
       
  1530     ^ self nextUnsignedInt32MSB:false
       
  1531 !
       
  1532 
       
  1533 nextUnsignedInt32MSB
       
  1534     "return an unsigned long (4 bytes) in MSB-first order from the stream.
       
  1535      The receiver must support reading of binary bytes."
       
  1536 
       
  1537     ^ self nextUnsignedInt32MSB:true
       
  1538 !
       
  1539 
  1468 nextUnsignedInt32MSB:msbFlag
  1540 nextUnsignedInt32MSB:msbFlag
  1469     "return an unsigned long (4 bytes) from the stream.
  1541     "return an unsigned long (4 bytes) from the stream.
  1470      The receiver must support reading of binary bytes.
  1542      The receiver must support reading of binary bytes.
  1471 
  1543 
  1472      The msbFlag argument controls if the integer is to be read with
  1544      The msbFlag argument controls if the integer is to be read with
  1500     "Modified: 11.7.1996 / 10:07:13 / cg"
  1572     "Modified: 11.7.1996 / 10:07:13 / cg"
  1501 !
  1573 !
  1502 
  1574 
  1503 nextUnsignedInt32Net
  1575 nextUnsignedInt32Net
  1504     "return an unsigned long (4 bytes) in network byte order from the stream.
  1576     "return an unsigned long (4 bytes) in network byte order from the stream.
  1505      The receiver must support reading of binary bytes."
  1577      The receiver must support reading of binary bytes.
       
  1578      Network byte order is MSB-first per definition"
  1506 
  1579 
  1507     ^ self nextUnsignedInt32MSB:true
  1580     ^ self nextUnsignedInt32MSB:true
  1508 
  1581 
  1509     "Created: 10.1.1996 / 19:49:02 / cg"
  1582     "Created: 10.1.1996 / 19:49:02 / cg"
  1510     "Modified: 10.1.1996 / 19:49:50 / cg"
  1583     "Modified: 10.1.1996 / 19:49:50 / cg"
  1511 !
  1584 !
  1512 
  1585 
       
  1586 nextUnsignedInt64LSB
       
  1587     "return an unsigned longlong (also called hyper) (8 bytes) in LSB-first order from the stream.
       
  1588      The receiver must support reading of binary bytes."
       
  1589 
       
  1590     ^ self nextUnsignedInt64MSB:false
       
  1591 !
       
  1592 
       
  1593 nextUnsignedInt64MSB
       
  1594     "return an unsigned longlong (also called hyper) (8 bytes) in MSB-first order from the stream.
       
  1595      The receiver must support reading of binary bytes."
       
  1596 
       
  1597     ^ self nextUnsignedInt64MSB:true
       
  1598 !
       
  1599 
  1513 nextUnsignedInt64MSB:msbFlag
  1600 nextUnsignedInt64MSB:msbFlag
  1514     "return an unsigned hyper (8 bytes) from the stream.
  1601     "return an unsigned longlong (also called hyper) (8 bytes) from the stream.
  1515      The receiver must support reading of binary bytes.
  1602      The receiver must support reading of binary bytes.
  1516 
  1603 
  1517      The msbFlag argument controls if the integer is to be read with
  1604      The msbFlag argument controls if the integer is to be read with
  1518      most-significant-byte-first (true) or least-first (false).
  1605      most-significant-byte-first (true) or least-first (false).
  1519      This interface is provided to allow talking to external programs,
  1606      This interface is provided to allow talking to external programs,
  1572 
  1659 
  1573     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1660     "Modified: / 14.1.1998 / 15:40:41 / cg"
  1574 !
  1661 !
  1575 
  1662 
  1576 nextUnsignedInt64Net
  1663 nextUnsignedInt64Net
  1577     "return an unsigned longlong (8 bytes) in network byte order from the stream.
  1664     "return an unsigned longlong (also called hyper) (8 bytes) in network byte order from the stream.
  1578      The receiver must support reading of binary bytes."
  1665      The receiver must support reading of binary bytes.
       
  1666      Network byte order is MSB-first per definition"
  1579 
  1667 
  1580     ^ self nextUnsignedInt64MSB:true
  1668     ^ self nextUnsignedInt64MSB:true
  1581 ! !
  1669 ! !
  1582 
  1670 
  1583 !Stream methodsFor:'non homogenous reading - obsolete'!
  1671 !Stream methodsFor:'non homogenous reading - obsolete'!
  2087     "
  2175     "
  2088 
  2176 
  2089     "Modified: / 22-06-2006 / 11:30:26 / fm"
  2177     "Modified: / 22-06-2006 / 11:30:26 / fm"
  2090 !
  2178 !
  2091 
  2179 
       
  2180 nextPutInt16LSB:aNumber
       
  2181     "Write the argument, aNumber as a short (two bytes) in LSB-first order.
       
  2182      Returns the receiver on ok, nil on error.
       
  2183      The receiver must support writing of binary bytes."
       
  2184 
       
  2185     ^ self nextPutInt16:aNumber MSB:false.
       
  2186 !
       
  2187 
       
  2188 nextPutInt16MSB:aNumber
       
  2189     "Write the argument, aNumber as a short (two bytes) in MSB-first order.
       
  2190      Returns the receiver on ok, nil on error.
       
  2191      The receiver must support writing of binary bytes."
       
  2192 
       
  2193     ^ self nextPutInt16:aNumber MSB:true.
       
  2194 !
       
  2195 
  2092 nextPutInt16Net:aNumber
  2196 nextPutInt16Net:aNumber
  2093     "Write the argument, aNumber as a short (two bytes) in the network byte order.
  2197     "Write the argument, aNumber as a short (two bytes) in the network byte order.
  2094      Returns the receiver on ok, nil on error.
  2198      Returns the receiver on ok, nil on error.
  2095      The receiver must support writing of binary bytes.
  2199      The receiver must support writing of binary bytes.
  2096      Network byte order is MSB per definition"
  2200      Network byte order is MSB-first per definition"
  2097 
  2201 
  2098     ^ self nextPutInt16:aNumber MSB:true.
  2202     ^ self nextPutInt16:aNumber MSB:true.
  2099 
  2203 
  2100     "Created: 10.1.1996 / 19:50:33 / cg"
  2204     "Created: 10.1.1996 / 19:50:33 / cg"
  2101 !
  2205 !
  2177 
  2281 
  2178     "Modified: / 01-11-1997 / 18:30:52 / cg"
  2282     "Modified: / 01-11-1997 / 18:30:52 / cg"
  2179     "Modified: / 22-06-2006 / 11:31:43 / fm"
  2283     "Modified: / 22-06-2006 / 11:31:43 / fm"
  2180 !
  2284 !
  2181 
  2285 
       
  2286 nextPutInt32LSB:aNumber
       
  2287     "Write the argument, aNumber as a long (4 bytes) in LSB-first order.
       
  2288      Returns the receiver on ok, nil on error.
       
  2289      The receiver must support writing of binary bytes."
       
  2290 
       
  2291     ^ self nextPutInt32:aNumber MSB:false.
       
  2292 !
       
  2293 
       
  2294 nextPutInt32MSB:aNumber
       
  2295     "Write the argument, aNumber as a long (4 bytes) in MSB-first order.
       
  2296      Returns the receiver on ok, nil on error.
       
  2297      The receiver must support writing of binary bytes."
       
  2298 
       
  2299     ^ self nextPutInt32:aNumber MSB:true.
       
  2300 !
       
  2301 
  2182 nextPutInt32Net:aNumber
  2302 nextPutInt32Net:aNumber
  2183     "Write the argument, aNumber as a long (four bytes) in the network byte order.
  2303     "Write the argument, aNumber as a long (four bytes) in the network byte order.
  2184      Returns the receiver on ok, nil on error.
  2304      Returns the receiver on ok, nil on error.
  2185      The receiver must support writing of binary bytes."
  2305      The receiver must support writing of binary bytes.
       
  2306      Network byte order is MSB-first per definition"
  2186 
  2307 
  2187     ^ self nextPutInt32:aNumber MSB:true
  2308     ^ self nextPutInt32:aNumber MSB:true
  2188 !
  2309 !
  2189 
  2310 
  2190 nextPutInt64:aNumber MSB:msbFlag
  2311 nextPutInt64:aNumber MSB:msbFlag
  2249 
  2370 
  2250     "Modified: / 01-11-1997 / 18:30:52 / cg"
  2371     "Modified: / 01-11-1997 / 18:30:52 / cg"
  2251     "Modified: / 22-06-2006 / 11:31:37 / fm"
  2372     "Modified: / 22-06-2006 / 11:31:37 / fm"
  2252 !
  2373 !
  2253 
  2374 
       
  2375 nextPutInt64LSB:aNumber
       
  2376     "Write the argument, aNumber as a longlong (8 bytes) in LSB-first order.
       
  2377      Returns the receiver on ok, nil on error.
       
  2378      The receiver must support writing of binary bytes."
       
  2379 
       
  2380     ^ self nextPutInt64:aNumber MSB:false.
       
  2381 !
       
  2382 
       
  2383 nextPutInt64MSB:aNumber
       
  2384     "Write the argument, aNumber as a longlong (8 bytes) in MSB-first order.
       
  2385      Returns the receiver on ok, nil on error.
       
  2386      The receiver must support writing of binary bytes."
       
  2387 
       
  2388     ^ self nextPutInt64:aNumber MSB:true.
       
  2389 !
       
  2390 
  2254 nextPutInt64Net:aNumber
  2391 nextPutInt64Net:aNumber
  2255     "Write the argument, aNumber as a longlong (8 bytes) in the network byte order.
  2392     "Write the argument, aNumber as a longlong (8 bytes) in the network byte order.
  2256      Returns the receiver on ok, nil on error.
  2393      Returns the receiver on ok, nil on error.
  2257      The receiver must support writing of binary bytes."
  2394      The receiver must support writing of binary bytes.
       
  2395      Network byte order is MSB-first per definition"
  2258 
  2396 
  2259     ^ self nextPutInt64:aNumber MSB:true
  2397     ^ self nextPutInt64:aNumber MSB:true
  2260 !
  2398 !
  2261 
  2399 
  2262 nextPutUtf16:aCharacter
  2400 nextPutUtf16:aCharacter