MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / get

Method get

src/ifcparse/FileReader.cpp:199–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197 }
198
199 char get(size_t pos) const override {
200 /*
201 auto self = const_cast<PushedSequentialImpl*>(this);
202 // We do not do this automatically because all variable width tokens:
203 // ENUM/STRING/BINARY/KEYWORD are stored as file offsets until a full
204 // entity instance is finalized.
205 if (this->shared_from_this().use_count() == 2) {
206 // only drop pages when there is only one active client.
207 // NB this->shared_from_this() increases count by 1
208 self->drop_consumed_up_to(pos);
209 }
210 */
211
212 const size_t avail_end = size();
213 if (pos >= avail_end) throw std::out_of_range("pushed backend: position not committed yet");
214
215 pos -= discarded_page_bytes_;
216
217 size_t page_start = 0;
218 for (const auto& pg : pages_) {
219 if (pos < page_start + pg.data.size()) {
220 const size_t off = pos - page_start;
221 return pg.data[off];
222 } else {
223 page_start += pg.data.size();
224 }
225 }
226
227 throw std::out_of_range("pushed backend: internal inconsistency");
228 }
229
230 void pushNextPage(const std::string& data) override {
231 FileReader::Page p; p.data.assign(data.data(), data.data() + data.size());

Callers

nothing calls this directly

Calls 2

sizeFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected