Example #1
0
	AutoBlob Blob::Concat(std::vector<AutoBlob>& blobs)
	{
		if (blobs.size() == 0) {
			this->duplicate();
			return this;
		}
		
		int size = this->Length();
		for (size_t i = 0; i < blobs.size(); i++)
		{
			size += blobs.at(i)->Length();
		}

		char* buffer = new char[size+1];
		buffer[size] = '\0';

		char* current = buffer;
		memcpy(current, this->Get(), this->Length());
		current += this->Length();
		
		for (size_t i = 0; i < blobs.size(); i++)
		{
			AutoBlob blob = blobs.at(i);
			if (blob->Length() > 0)
			{
				memcpy(current, blob->Get(), blob->Length());
				current += blob->Length();
			}
		}
		
		return new Blob(buffer, size, false);
	}
	void NativePipe::RawWrite(AutoBlob blob)
	{
		try
		{
			this->RawWrite((char*) blob->Get(), blob->Length());
		}
		catch (Poco::Exception& e)
		{
			logger->Error("Exception while try to write to pipe Pipe: %s",
				e.displayText().c_str());
		}
	}