1532 " |
1532 " |
1533 |
1533 |
1534 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1534 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1535 ! |
1535 ! |
1536 |
1536 |
|
1537 nextLong |
|
1538 "Read four bytes (msb-first) and return the value as a 32-bit signed Integer. |
|
1539 The returned value may be a LargeInteger. |
|
1540 (msb-first for compatibility with other smalltalks)" |
|
1541 |
|
1542 ^ self nextInt32MSB:true |
|
1543 ! |
|
1544 |
1537 nextLongMSB:msbFlag |
1545 nextLongMSB:msbFlag |
1538 "return a signed long (4 bytes) from the stream. |
1546 "return a signed long (4 bytes) from the stream. |
1539 The receiver must support reading of binary bytes. |
1547 The receiver must support reading of binary bytes. |
1540 |
1548 |
1541 The msbFlag argument controls if the integer is to be read with |
1549 The msbFlag argument controls if the integer is to be read with |
1619 where its known that the byte order is some definite one. |
1627 where its known that the byte order is some definite one. |
1620 If you dont care (i.e. talk to other smalltalks) or you can control the |
1628 If you dont care (i.e. talk to other smalltalks) or you can control the |
1621 order, please use the corresponding xxxNet methods, which use a standard |
1629 order, please use the corresponding xxxNet methods, which use a standard |
1622 network byte order." |
1630 network byte order." |
1623 |
1631 |
1624 |b1 b2 b3 b4 val| |
1632 ^ self nextUnsignedInt32MSB:msbFlag |
1625 |
|
1626 b1 := self nextByte. |
|
1627 b2 := self nextByte. |
|
1628 b3 := self nextByte. |
|
1629 b4 := self nextByte. |
|
1630 |
|
1631 msbFlag ifTrue:[ |
|
1632 val := b1. |
|
1633 val := (val bitShift:8) bitOr:b2. |
|
1634 val := (val bitShift:8) bitOr:b3. |
|
1635 val := (val * 256) + b4. |
|
1636 ^ val |
|
1637 ]. |
|
1638 val := b4. |
|
1639 val := (val bitShift:8) bitOr:b3. |
|
1640 val := (val bitShift:8) bitOr:b2. |
|
1641 val := (val * 256) + b1. |
|
1642 ^ val |
|
1643 |
1633 |
1644 "Modified: 11.7.1996 / 10:07:13 / cg" |
1634 "Modified: 11.7.1996 / 10:07:13 / cg" |
1645 ! |
1635 ! |
1646 |
1636 |
1647 nextUnsignedLongNet |
1637 nextUnsignedLongNet |
1648 "return an unsigned long (4 bytes) in network byte order from the stream. |
1638 "return an unsigned long (4 bytes) in network byte order from the stream. |
1649 The receiver must support reading of binary bytes." |
1639 The receiver must support reading of binary bytes." |
1650 |
1640 |
1651 ^ self nextUnsignedLongMSB:true |
1641 ^ self nextUnsignedInt32MSB:true |
1652 |
1642 |
1653 "Created: 10.1.1996 / 19:49:02 / cg" |
1643 "Created: 10.1.1996 / 19:49:02 / cg" |
1654 "Modified: 10.1.1996 / 19:49:50 / cg" |
1644 "Modified: 10.1.1996 / 19:49:50 / cg" |
1655 ! |
1645 ! |
1656 |
1646 |
1664 where its known that the byte order is some definite one. |
1654 where its known that the byte order is some definite one. |
1665 If you dont care (i.e. talk to other smalltalks) or you can control the |
1655 If you dont care (i.e. talk to other smalltalks) or you can control the |
1666 order, please use the corresponding xxxNet methods, which use a standard |
1656 order, please use the corresponding xxxNet methods, which use a standard |
1667 network byte order." |
1657 network byte order." |
1668 |
1658 |
1669 |b1 b2| |
1659 ^ self nextUnsignedInt16MSB:msbFlag |
1670 |
|
1671 b1 := self nextByte. |
|
1672 b2 := self nextByte. |
|
1673 |
|
1674 msbFlag ifTrue:[ |
|
1675 ^ (b1 bitShift:8) bitOr:b2 |
|
1676 ]. |
|
1677 ^ (b2 bitShift:8) bitOr:b1 |
|
1678 |
1660 |
1679 "Modified: 11.7.1996 / 10:07:20 / cg" |
1661 "Modified: 11.7.1996 / 10:07:20 / cg" |
1680 ! |
1662 ! |
1681 |
1663 |
1682 nextUnsignedShortNet |
1664 nextUnsignedShortNet |
1683 "return an unsigned short (2 bytes) in network byte order from the stream. |
1665 "return an unsigned short (2 bytes) in network byte order from the stream. |
1684 The receiver must support reading of binary bytes. |
1666 The receiver must support reading of binary bytes. |
1685 Network byte order is MSB per definition" |
1667 Network byte order is MSB per definition" |
1686 |
1668 |
1687 ^ self nextUnsignedShortMSB:true |
1669 ^ self nextUnsignedInt16MSB:true |
1688 |
1670 |
1689 "Created: 10.1.1996 / 19:50:02 / cg" |
1671 "Created: 10.1.1996 / 19:50:02 / cg" |
1690 ! ! |
1672 ! ! |
1691 |
1673 |
1692 !Stream methodsFor:'non homogenous writing'! |
1674 !Stream methodsFor:'non homogenous writing'! |