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


C++ ConnectionReader::expectBlock方法代码示例

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


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

示例1: readFromConnection

/**
* This helper function groups code to avoid duplication. It is not a member function of Image because 
* there are problems with ImageNetworkHeader, anyhow the function is state-less and uses only parameters.
*/
inline bool readFromConnection(Image &dest, ImageNetworkHeader &header, ConnectionReader& connection)
{
    dest.resize(header.width, header.height);
    unsigned char *mem = dest.getRawImage();
    int allocatedBytes = dest.getRawImageSize();
    yAssert(mem != NULL);
    //this check is redundant with assertion, I would remove it
    if (dest.getRawImageSize() != header.imgSize) {
        printf("There is a problem reading an image\n");
        printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
            (int)header.width, (int)header.height,
            (int)header.id,
            (int)header.quantum, (int)header.imgSize);
        printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
            dest.width(), dest.height(), dest.getPixelCode(), dest.getQuantum(), allocatedBytes);
    }
    yAssert(allocatedBytes == header.imgSize);
    bool ok = connection.expectBlock((char *)mem, allocatedBytes);
    return (!connection.isError() && ok);
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:24,代码来源:Image.cpp

示例2: readRaw

bool StoreDouble::readRaw(ConnectionReader& reader) {
    NetFloat64 flt = 0;
    reader.expectBlock((const char*)&flt,sizeof(flt));
    x = flt;
    return true;
}
开发者ID:holgerfriedrich,项目名称:yarp,代码行数:6,代码来源:BottleImpl.cpp

示例3: read

bool BottleImpl::read(ConnectionReader& reader) {
    bool result = false;

    if (reader.isTextMode()) {
        String str = reader.expectText().c_str();
        if (reader.isError()) return false;
        bool done = (str.length()<=0);
        while (!done) {
            if (str[str.length()-1]=='\\') {
                str = str.substr(0,str.length()-1);
                str += reader.expectText().c_str();
                if (reader.isError()) return false;
            } else {
                if (isComplete(str.c_str())) {
                    done = true;
                } else {
                    str += "\n";
                    str += reader.expectText().c_str();
                    if (reader.isError()) return false;
                }
            }
        }
        fromString(str);
        result = true;
    } else {
#if USE_YARP1_PREFIX
        if (!nested) {
            int len = reader.expectInt();
            if (reader.isError()) return false;
            //String name = reader.expectString(len);
            String buf(YARP_STRINIT(len));
            reader.expectBlock((const char *)buf.c_str(),len);
            if (reader.isError()) return false;
            String name = buf.c_str();
        }
#endif
        if (!nested) {
            // no byte length any more to facilitate nesting
            //reader.expectInt(); // the bottle byte ct; ignored
            
            clear();
            specialize(0);
            
            int code = reader.expectInt();
            if (reader.isError()) return false;
            YMSG(("READ got top level code %d\n", code));
            code = code & UNIT_MASK;
            if (code!=0) {
                specialize(code);
            }
        }
        
        result = true;
        clear();
        dirty = true; // for clarity
        
        int len = 0;
        int i = 0;
        len = reader.expectInt();
        if (reader.isError()) return false;
        YMSG(("READ got length %d\n", len));
        for (i=0; i<len; i++) {
            bool ok = fromBytes(reader);
            if (!ok) return false;
        }
    }
    return result;
}
开发者ID:holgerfriedrich,项目名称:yarp,代码行数:68,代码来源:BottleImpl.cpp


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