Read the next field from the file. If required, this function will obtain additional data from the file and/or decompress additional data from the compressed data buffer.
134 uint8_t * head = this->stream.next_out - (
sizeof(this->buffer[1]) - this->stream.avail_out);
137 if (this->stream.avail_out ==
sizeof(this->buffer[1])) {
139 if (this->stream.avail_in == 0) {
141 if ((this->stream.avail_in = ::
read(this->descriptor, this->buffer[0],
sizeof(this->buffer[0]))) < 0) {
142 THROW(IOException,
"failed to read from file '%s'", this->filename.c_str());
143 }
else if (this->stream.avail_in == 0) {
146 this->stream.next_in = this->buffer[0];
150 this->stream.avail_out =
sizeof(this->buffer[1]);
151 this->stream.next_out = this->buffer[1];
153 switch (::inflate(&(this->stream), Z_SYNC_FLUSH)) {
155 THROW(IOException,
"zlib decompression state was destroyed");
158 THROW(IOException,
"zlib decompression failed due to missing dictionary");
161 THROW(IOException,
"zlib decompression failed due to bad data in stream");
164 THROW(IOException,
"zlib decompression failed due to a memory error");
166 head = this->stream.next_out - (
sizeof(this->buffer[1]) - this->stream.avail_out);
170 for (uint8_t * i = head; i != this->stream.next_out; i++) {
171 if ((*i) == this->seperator) {
172 data.push_back(prepend.append(std::string(reinterpret_cast<char *>(head), i - head)));
173 this->stream.avail_out += (i - head + 1);
176 }
else if (*(i) == this->delimiter) {
177 data.push_back(prepend.append(std::string(reinterpret_cast<char *>(head), i - head)));
178 this->stream.avail_out += (i - head + 1);
183 this->stream.avail_out =
sizeof(this->buffer[1]);
186 return this->
read(data, std::string(reinterpret_cast<char *>(head), this->stream.next_out - head));
void read(std::vector< std::vector< std::string >> &data) THROWS(IOException)