ObjFW  Check-in [c82e7f02f0]

Overview
Comment:Add -[readInt8] and -[readBigEndianInt{16,32,64}] to OFStream.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c82e7f02f08979e56a5fa7df346b3610f019a78ba756092f034e205a95ecc828
User & Date: js on 2010-04-08 23:37:43
Other Links: manifest | tags
Context
2010-04-08
23:48
Add -[writeInt8:] and -[writeBigEndianInt{16,32,64}:] to OFStream. check-in: 978e88a43c user: js tags: trunk
23:37
Add -[readInt8] and -[readBigEndianInt{16,32,64}] to OFStream. check-in: c82e7f02f0 user: js tags: trunk
23:26
Add -[readDataArrayWithItemSize:andNItems:] to OFStream. check-in: 3006cccbb9 user: js tags: trunk
Changes

Modified src/OFStream.h from [11233aa834] to [b0e6f5f9a4].

82
83
84
85
86
87
88





























89
90
91
92
93
94
95
 *
 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	       The buffer MUST be EXACTLY this big!
 */
- (void)readExactlyNBytes: (size_t)size
	       intoBuffer: (char*)buf;





























/**
 * Reads nitems items with the specified item size from the stream and returns
 * them in an OFDataArray.
 *
 * \param itemsize The size of each item
 * \param nitems The number of iteams to read
 * \return An OFDataArray with at nitems items.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 *
 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	       The buffer MUST be EXACTLY this big!
 */
- (void)readExactlyNBytes: (size_t)size
	       intoBuffer: (char*)buf;

/**
 * Reads an uint8_t from the stream.
 *
 * \return An uint8_t from the stream
 */
- (uint8_t)readInt8;

/**
 * Reads an uint16_t from the stream which is encoded in big endian.
 *
 * \return An uint16_t from the stream in native endianess
 */
- (uint16_t)readBigEndianInt16;

/**
 * Reads an uint32_t from the stream which is encoded in big endian.
 *
 * \return An uint32_t from the stream in the native endianess
 */
- (uint32_t)readBigEndianInt32;

/**
 * Reads an uint64_t from the stream which is encoded in big endian.
 *
 * \return An uint64_t from the stream in the native endianess
 */
- (uint64_t)readBigEndianInt64;

/**
 * Reads nitems items with the specified item size from the stream and returns
 * them in an OFDataArray.
 *
 * \param itemsize The size of each item
 * \param nitems The number of iteams to read
 * \return An OFDataArray with at nitems items.

Modified src/OFStream.m from [41f6ac1ebe] to [fa0d06eb4d].

97
98
99
100
101
102
103








































104
105
106
107
108
109
110
{
	size_t len = 0;

	while (len < size)
		len += [self readNBytes: size - len
			     intoBuffer: buf + len];
}









































- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemsize
				andNItems: (size_t)nitems
{
	OFDataArray *da;
	char *tmp;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
	size_t len = 0;

	while (len < size)
		len += [self readNBytes: size - len
			     intoBuffer: buf + len];
}

- (uint8_t)readInt8
{
	uint8_t ret;

	[self readExactlyNBytes: 1
		     intoBuffer: (char*)&ret];

	return ret;
}

- (uint16_t)readBigEndianInt16
{
	uint16_t ret;

	[self readExactlyNBytes: 2
		     intoBuffer: (char*)&ret];

	return OF_BSWAP16_IF_LE(ret);
}

- (uint32_t)readBigEndianInt32
{
	uint32_t ret;

	[self readExactlyNBytes: 4
		     intoBuffer: (char*)&ret];

	return OF_BSWAP32_IF_LE(ret);
}

- (uint64_t)readBigEndianInt64
{
	uint64_t ret;

	[self readExactlyNBytes: 8
		     intoBuffer: (char*)&ret];

	return OF_BSWAP64_IF_LE(ret);
}

- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemsize
				andNItems: (size_t)nitems
{
	OFDataArray *da;
	char *tmp;