SmartPtrCDynamicByteArray CCafMessagePayload::createBufferFromStr(
		const std::string& payloadStr) {
	CAF_CM_STATIC_FUNC_VALIDATE("CCafMessagePayload", "createBufferFromStr");
	CAF_CM_VALIDATE_STRING(payloadStr);

	SmartPtrCDynamicByteArray rc;
	rc.CreateInstance();
	rc->allocateBytes(static_cast<uint32>(payloadStr.length()));
	rc->memCpy(payloadStr.c_str(), static_cast<uint32>(payloadStr.length()));

	return rc;
}
示例#2
0
void CIntMessage::initializeStr(
	const std::string& payloadStr,
	const SmartPtrCHeaders& newHeaders,
	const SmartPtrCHeaders& origHeaders) {
	CAF_CM_FUNCNAME_VALIDATE("initializeStr");
	CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);

	std::string payloadStrTmp = payloadStr;
	if (payloadStr.empty()) {
		payloadStrTmp = "";
	}

	SmartPtrCDynamicByteArray payload;
	payload.CreateInstance();
	payload->allocateBytes(payloadStrTmp.length());
	payload->memCpy(payloadStrTmp.c_str(), payloadStrTmp.length());

	initialize(payload, newHeaders, origHeaders);
}
/**
 * Converts the BLOCK_SIZE data in a ByteBuffer into a MessagePartsDescriptor
 * <p>
 * The incoming ByteBuffer position will be modified.
 * @param buffer ByteBuffer to convert
 * @return a MessagePartsDescriptor
 */
SmartPtrCMessagePartDescriptor CMessagePartDescriptor::fromByteBuffer(
	SmartPtrCDynamicByteArray& buffer) {
	CAF_CM_STATIC_FUNC("CMessagePartDescriptor", "fromByteBuffer");
	CAF_CM_VALIDATE_SMARTPTR(buffer);

	if (buffer->getByteCountFromCurrentPos() < BLOCK_SIZE) {
		CAF_CM_EXCEPTION_VA2(E_INVALIDARG,
			"Input data block is too small - rem: %d, tot: %d",
			buffer->getByteCountFromCurrentPos(), buffer->getByteCount());
	}

	SmartPtrCDynamicByteArray data;
	data.CreateInstance();
	data->allocateBytes(BLOCK_SIZE);
	data->memCpy(buffer->getPtrAtCurrentPos(), BLOCK_SIZE);

	buffer->incrementCurrentPos(BLOCK_SIZE);
	return fromArray(data);
}