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


C++ ConvertPtr::fromShortArray方法代码示例

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


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

示例1: testConvertScalarArray

static void testConvertScalarArray(FILE *fd) {
    PVScalarArrayPtr pvBytePtr = pvDataCreate->createPVScalarArray(pvByte);
    PVScalarArrayPtr pvUBytePtr = pvDataCreate->createPVScalarArray(pvUByte);
    PVScalarArrayPtr pvShortPtr = pvDataCreate->createPVScalarArray(pvShort);
    PVScalarArrayPtr pvUShortPtr = pvDataCreate->createPVScalarArray(pvUShort);
    PVScalarArrayPtr pvIntPtr = pvDataCreate->createPVScalarArray(pvInt);
    PVScalarArrayPtr pvUIntPtr = pvDataCreate->createPVScalarArray(pvUInt);
    PVScalarArrayPtr pvLongPtr = pvDataCreate->createPVScalarArray(pvLong);
    PVScalarArrayPtr pvULongPtr = pvDataCreate->createPVScalarArray(pvULong);
    PVScalarArrayPtr pvFloatPtr = pvDataCreate->createPVScalarArray(pvFloat);
    PVScalarArrayPtr pvDoublePtr = pvDataCreate->createPVScalarArray(pvDouble);

    fprintf(fd,"testConvertScalarArray\n");
    if(debug) fprintf(fd,"\nfromByte\n");
    size_t length = 4;
    int8 barray[length];
    int8 bval = 127;
    barray[0] = bval;
    for(size_t i=1; i<length; i++) barray[i] = barray[i-1] + 1;
    convert->fromByteArray(pvBytePtr,0,length,barray,0);
    builder.clear(); pvBytePtr->toString(&builder);
    if(debug) fprintf(fd,"byte %s\n",builder.c_str());
    convert->fromByteArray(pvUBytePtr,0,length,barray,0);
    builder.clear(); pvUBytePtr->toString(&builder);
    if(debug) fprintf(fd,"ubyte %s\n",builder.c_str());
    convert->fromByteArray(pvShortPtr,0,length,barray,0);
    builder.clear(); pvShortPtr->toString(&builder);
    if(debug) fprintf(fd,"short %s\n",builder.c_str());
    convert->fromByteArray(pvUShortPtr,0,length,barray,0);
    builder.clear(); pvUShortPtr->toString(&builder);
    if(debug) fprintf(fd,"ushort %s\n",builder.c_str());
    convert->fromByteArray(pvIntPtr,0,length,barray,0);
    builder.clear(); pvIntPtr->toString(&builder);
    if(debug) fprintf(fd,"int %s\n",builder.c_str());
    convert->fromByteArray(pvUIntPtr,0,length,barray,0);
    builder.clear(); pvUIntPtr->toString(&builder);
    if(debug) fprintf(fd,"uint %s\n",builder.c_str());
    convert->fromByteArray(pvLongPtr,0,length,barray,0);
    builder.clear(); pvLongPtr->toString(&builder);
    if(debug) fprintf(fd,"long %s\n",builder.c_str());
    convert->fromByteArray(pvULongPtr,0,length,barray,0);
    builder.clear(); pvULongPtr->toString(&builder);
    if(debug) fprintf(fd,"ulong %s\n",builder.c_str());
    convert->fromByteArray(pvFloatPtr,0,length,barray,0);
    builder.clear(); pvFloatPtr->toString(&builder);
    if(debug) fprintf(fd,"float %s\n",builder.c_str());
    convert->fromByteArray(pvDoublePtr,0,length,barray,0);
    builder.clear(); pvDoublePtr->toString(&builder);
    if(debug) fprintf(fd,"double %s\n",builder.c_str());
    convert->copyScalarArray(pvUBytePtr,0, pvFloatPtr,0,length);
    builder.clear(); pvFloatPtr->toString(&builder);
    if(debug) fprintf(fd,"float from unsigned %s\n",builder.c_str());
    convert->copyScalarArray(pvUBytePtr,0, pvDoublePtr,0,length);
    builder.clear(); pvDoublePtr->toString(&builder);
    if(debug) fprintf(fd,"double from unsigned %s\n",builder.c_str());
    fprintf(fd,"fromByte PASSED\n");

    if(debug) fprintf(fd,"\nfromShort\n");
    int16 sarray[length];
    int16 sval = 0x7fff;
    sarray[0] = sval;
    for(size_t i=1; i<length; i++) sarray[i] = sarray[i-1] + 1;
    convert->fromShortArray(pvBytePtr,0,length,sarray,0);
    builder.clear(); pvBytePtr->toString(&builder);
    if(debug) fprintf(fd,"byte %s\n",builder.c_str());
    convert->fromShortArray(pvUBytePtr,0,length,sarray,0);
    builder.clear(); pvUBytePtr->toString(&builder);
    if(debug) fprintf(fd,"ubyte %s\n",builder.c_str());
    convert->fromShortArray(pvShortPtr,0,length,sarray,0);
    builder.clear(); pvShortPtr->toString(&builder);
    if(debug) fprintf(fd,"short %s\n",builder.c_str());
    convert->fromShortArray(pvUShortPtr,0,length,sarray,0);
    builder.clear(); pvUShortPtr->toString(&builder);
    if(debug) fprintf(fd,"ushort %s\n",builder.c_str());
    convert->fromShortArray(pvIntPtr,0,length,sarray,0);
    builder.clear(); pvIntPtr->toString(&builder);
    if(debug) fprintf(fd,"int %s\n",builder.c_str());
    convert->fromShortArray(pvUIntPtr,0,length,sarray,0);
    builder.clear(); pvUIntPtr->toString(&builder);
    if(debug) fprintf(fd,"uint %s\n",builder.c_str());
    convert->fromShortArray(pvLongPtr,0,length,sarray,0);
    builder.clear(); pvLongPtr->toString(&builder);
    if(debug) fprintf(fd,"long %s\n",builder.c_str());
    convert->fromShortArray(pvULongPtr,0,length,sarray,0);
    builder.clear(); pvULongPtr->toString(&builder);
    if(debug) fprintf(fd,"ulong %s\n",builder.c_str());
    convert->fromShortArray(pvFloatPtr,0,length,sarray,0);
    builder.clear(); pvFloatPtr->toString(&builder);
    if(debug) fprintf(fd,"float %s\n",builder.c_str());
    convert->fromShortArray(pvDoublePtr,0,length,sarray,0);
    builder.clear(); pvDoublePtr->toString(&builder);
    if(debug) fprintf(fd,"double %s\n",builder.c_str());
    convert->copyScalarArray(pvUShortPtr,0, pvFloatPtr,0,length);
    builder.clear(); pvFloatPtr->toString(&builder);
    if(debug) fprintf(fd,"float from unsigned %s\n",builder.c_str());
    convert->copyScalarArray(pvUShortPtr,0, pvDoublePtr,0,length);
    builder.clear(); pvDoublePtr->toString(&builder);
    if(debug) fprintf(fd,"double from unsigned %s\n",builder.c_str());
    fprintf(fd,"fromShort PASSED\n");

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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