当前位置: 首页>>代码示例>>C++>>正文


C++ Parcel::writeInplace方法代码示例

本文整理汇总了C++中Parcel::writeInplace方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::writeInplace方法的具体用法?C++ Parcel::writeInplace怎么用?C++ Parcel::writeInplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parcel的用法示例。


在下文中一共展示了Parcel::writeInplace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memcpy

bool
NfcMessageHandler::WriteNDEFMessage(Parcel& aParcel, const CommandOptions& aOptions)
{
  int recordCount = aOptions.mRecords.Length();
  aParcel.writeInt32(recordCount);
  for (int i = 0; i < recordCount; i++) {
    const NDEFRecordStruct& record = aOptions.mRecords[i];
    aParcel.writeInt32(static_cast<int32_t>(record.mTnf));

    void* data;

    aParcel.writeInt32(record.mType.Length());
    data = aParcel.writeInplace(record.mType.Length());
    memcpy(data, record.mType.Elements(), record.mType.Length());

    aParcel.writeInt32(record.mId.Length());
    data = aParcel.writeInplace(record.mId.Length());
    memcpy(data, record.mId.Elements(), record.mId.Length());

    aParcel.writeInt32(record.mPayload.Length());
    data = aParcel.writeInplace(record.mPayload.Length());
    memcpy(data, record.mPayload.Elements(), record.mPayload.Length());
  }

  return true;
}
开发者ID:LaiPhil,项目名称:gecko-dev,代码行数:26,代码来源:NfcMessageHandler.cpp

示例2: android_os_Parcel_writeNative

static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jlong nativePtr, jobject data,
                                          jint offset, jint length)
{
    Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
    if (parcel == NULL) {
        return;
    }

    const status_t err = parcel->writeInt32(length);
    if (err != NO_ERROR) {
        signalExceptionForError(env, clazz, err);
        return;
    }

    void* dest = parcel->writeInplace(length);
    if (dest == NULL) {
        signalExceptionForError(env, clazz, NO_MEMORY);
        return;
    }

    jbyte* ar = (jbyte*)env->GetPrimitiveArrayCritical((jarray)data, 0);
    if (ar) {
        memcpy(dest, ar + offset, length);
        env->ReleasePrimitiveArrayCritical((jarray)data, ar, 0);
    }
}
开发者ID:7tiny,项目名称:platform_frameworks_base,代码行数:26,代码来源:android_os_Parcel.cpp

示例3: incomingThread

int PhoneMachine::incomingThread()
{
	char boardname[PROPERTY_VALUE_MAX];
	if (property_get("ro.product.board", boardname, "") > 0) {
		SLOGV("%s: -------------Board %s -----------------\n", __FUNCTION__, boardname);
		// QCOM Version 4.1.2 onwards, supports multiple clients and needs a SUB1/2 string to
		// identify client
		// For this example code we will just use "SUB1" for client 0
		if ( !strcasecmp(boardname, "msm8960")) {
			char *sub = "SUB1";
			int ret = ::send(mRILfd, sub, sizeof(sub), 0);
			if (ret != (int) sizeof(sub)) {
	    		perror("Socket write error when sending parcel"); 
	    		return ret;
			}
			SLOGV("%s: sent SUB1\n", __FUNCTION__);
		}
	}
	else SLOGE("%s: could not get device name\n", __FUNCTION__);

    while (1) {
	uint32_t header;
	int ret = read(mRILfd, &header, sizeof(header));

	if (ret != sizeof(header)) {
	    SLOGW("Read %d bytes instead of %d\n", ret, sizeof(header));
	    perror("PhoneMachine::incomingThread read on header");
	    return ret;
	}
	int data_size = ntohl(header);
	Parcel data;
	ret = read(mRILfd, data.writeInplace(data_size), data_size);
	if (ret != data_size) {
	    perror("PhoneMachine::incomingThread read on payload");
	    return ret;
	}
	if (mDebug & DEBUG_INCOMING) {
	    SLOGV("<<<<<<< INCOMING <<<<<<<<<<\n");
	    const uint8_t *ptr = data.data();
	    for (int i = 0 ; i < data_size ; i++ ) {
		SLOGV("%02x ", *ptr++);
		if ((i+1) % 8 == 0 || (i+1 >= data_size))
		    SLOGV("\n");
	    }
	    SLOGV("<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	}
	data.setDataPosition(0);
	int type = data.readInt32();
//	SLOGV("New message received: %d bytes type=%s\n", data_size, 
//	       (type ==RESPONSE_SOLICITED ? "solicited" : "unsolicited"));
	if (type == RESPONSE_SOLICITED) 
	    receiveSolicited(data);
	else
	    receiveUnsolicited(data);
    }
    return NO_ERROR;
}
开发者ID:cambridgehackers,项目名称:klaatu-services,代码行数:57,代码来源:PhoneStateMachine.cpp

示例4: android_os_Parcel_unmarshall

static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr,
                                         jbyteArray data, jint offset, jint length)
{
    Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
    if (parcel == NULL || length < 0) {
       return;
    }

    jbyte* array = (jbyte*)env->GetPrimitiveArrayCritical(data, 0);
    if (array)
    {
        parcel->setDataSize(length);
        parcel->setDataPosition(0);

        void* raw = parcel->writeInplace(length);
        memcpy(raw, (array + offset), length);

        env->ReleasePrimitiveArrayCritical(data, array, 0);
    }
}
开发者ID:7tiny,项目名称:platform_frameworks_base,代码行数:20,代码来源:android_os_Parcel.cpp

示例5: write

status_t layer_state_t::write(Parcel& output) const
{
    output.writeStrongBinder(surface);
    output.writeUint32(what);
    output.writeFloat(x);
    output.writeFloat(y);
    output.writeUint32(z);
    output.writeUint32(w);
    output.writeUint32(h);
    output.writeUint32(layerStack);
    output.writeFloat(alpha);
    output.writeUint32(flags);
    output.writeUint32(mask);
    *reinterpret_cast<layer_state_t::matrix22_t *>(
            output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
    output.write(crop);
    output.write(finalCrop);
    output.writeStrongBinder(handle);
    output.writeUint64(frameNumber);
    output.writeInt32(overrideScalingMode);
    output.write(transparentRegion);
    return NO_ERROR;
}
开发者ID:android-source,项目名称:platform_frameworks_native,代码行数:23,代码来源:LayerState.cpp


注:本文中的Parcel::writeInplace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。