StringPool::StringPool() { CreateMemoryBlock(); MemoryBlocks.SlideFront(); }
const void * RecordArray::ItemData(unsigned int index) const { unsigned int chunkIndex = index / chunkCapacity_; if (chunks_[chunkIndex] == 0) { chunks_[chunkIndex] = CreateMemoryBlock(); } return chunks_[chunkIndex]->ItemData(index % chunkCapacity_); }
void * RecordArray::ItemData(unsigned int index) { // TODO: ASSERT(index < size_) unsigned int chunkIndex = index / chunkCapacity_; if (chunks_[chunkIndex] == 0) { chunks_[chunkIndex] = CreateMemoryBlock(); } return chunks_[chunkIndex]->ItemData(index % chunkCapacity_); }
void StringPool::InsertString(Crude::String TargetString) { unsigned int MemoryUsed = MemoryBlocks.Get()->MemoryUsed; if ((MemoryUsed + TargetString.Length()) >= MEMORYBLOCK_SIZE) { CreateMemoryBlock(); MemoryBlocks.Slide(); } cstrncpy(TargetString.Data(), MemoryBlocks.Get()->Memory + (MemoryUsed), TargetString.Length() + 1); MemoryBlocks.Get()->MemoryUsed += TargetString.Length() + 1; }
void RecordArray::Read(XTL::InputStream & stream) { unsigned int leftItems = size_; std::deque<MemoryBlock *>::iterator end = chunks_.end(); for (std::deque<MemoryBlock *>::iterator itr = chunks_.begin(); itr != end; ++itr) { if (*itr == 0) { *itr = CreateMemoryBlock(); } unsigned int itemsToRead = Min(leftItems, chunkCapacity_); (*itr)->Read(stream, itemsToRead); leftItems -= itemsToRead; } }
void RecordArray::Write(XTL::OutputStream & stream) const { unsigned int leftItems = size_; std::deque<MemoryBlock *>::iterator end = chunks_.end(); for (std::deque<MemoryBlock *>::iterator itr = chunks_.begin(); itr != end; ++itr) { if (*itr == 0) { // TODO: create empty Record and write it chunkCapacity_ times. *itr = CreateMemoryBlock(); } unsigned int itemsToWrite = Min(leftItems, chunkCapacity_); (*itr)->Write(stream, itemsToWrite); leftItems -= itemsToWrite; } }