Ejemplo n.º 1
0
	StringPool::StringPool() {

		CreateMemoryBlock();

		MemoryBlocks.SlideFront();

	}
Ejemplo n.º 2
0
	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_);
	}
Ejemplo n.º 3
0
	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_);
	}
Ejemplo n.º 4
0
	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;
	}
Ejemplo n.º 5
0
	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;
		}
	}
Ejemplo n.º 6
0
	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;
		}
	}