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


C++ Bottle::fromBinary方法代码示例

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


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

示例1: applyConvertTextMode

bool BufferedConnectionWriter::applyConvertTextMode()
{
    if (convertTextModePending) {
        convertTextModePending = false;

        Bottle b;
        StringOutputStream sos;
        for (size_t i = 0; i < lst_used; i++) {
            yarp::os::ManagedBytes& m = *(lst[i]);
            sos.write(m.usedBytes());
        }
        const std::string& str = sos.str();
        b.fromBinary(str.c_str(), (int)str.length());
        std::string replacement = b.toString() + "\n";
        for (auto& i : lst) {
            delete i;
        }
        lst_used = 0;
        target = &lst;
        lst.clear();
        stopPool();
        Bytes data((char*)replacement.c_str(), replacement.length());
        appendBlockCopy(data);
    }
    return true;
}
开发者ID:ale-git,项目名称:yarp,代码行数:26,代码来源:BufferedConnectionWriter.cpp

示例2: checkFormat

    void checkFormat() {
        report(0,"check matrix format conforms to network standard...");

        Matrix m;
        size_t rr = 10;
        size_t cc = 5;
        makeTestMatrix(m,rr,cc);

        BufferedConnectionWriter writer;
        m.write(writer);
        std::string s = writer.toString();
        Bottle bot;
        bot.fromBinary(s.c_str(),s.length());
        checkEqual((size_t) bot.get(0).asInt32(),rr,"row count matches");
        checkEqual((size_t) bot.get(1).asInt32(),cc,"column count matches");
        Bottle *lst = bot.get(2).asList();
        checkTrue(lst!=nullptr,"have data");
        if (!lst) return;
        checkEqual(lst->size(),(rr*cc),"data length matches");
        if (lst->size()!=(rr*cc)) return;
        bool ok = true;
        for (int i=0; i<(int)(rr*cc); i++) {
            double v = lst->get(i).asFloat64();
            if (fabs(v-i)>0.01) {
                ok = false;
                checkEqualish(v,i,"cell matches");
                break;
            }
        }
        checkTrue(ok,"data matches");
    }
开发者ID:claudiofantacci,项目名称:yarp,代码行数:31,代码来源:MatrixTest.cpp

示例3: checkStandard

 void checkStandard() {
     PortablePair<Bottle,Bottle> pp;
     pp.head.fromString("1 2 3");
     pp.body.fromString("yes no");
     BufferedConnectionWriter writer;
     pp.write(writer);
     std::string s = writer.toString();
     Bottle bot;
     bot.fromBinary(s.c_str(),s.length());
     checkEqual(bot.size(),(size_t) 2,"it is a pair");
     checkEqual(bot.get(0).asList()->size(),(size_t) 3,"head len is right");
     checkEqual(bot.get(1).asList()->size(),(size_t) 2,"body len is right");
 }
开发者ID:robotology,项目名称:yarp,代码行数:13,代码来源:PortablePairTest.cpp

示例4: create

 bool create(void* buf, size_t buflen, int op) {
     if (op==YDR_FREE) return true;
     save = (op==YDR_ENCODE);
     if (!save) {
         printf("reading binary\n");
         b.fromBinary((const char *)buf,buflen);
         printf("read binary\n");
     } else {
         b.clear();
     }
     obuf = buf;
     obuflen = buflen;
     return true;
 }
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:14,代码来源:ydr.cpp

示例5: testStandard

 void testStandard() {
     report(0,"checking standard compliance of description...");
     ImageOf<PixelRgb> img;
     img.resize(8,4);
     img.zero();
     BufferedConnectionWriter writer;
     img.write(writer);
     ConstString s = writer.toString();
     Bottle bot;
     bot.fromBinary(s.c_str(),s.length());
     checkEqual(bot.size(),4,"plausible bottle out");
     checkEqual(bot.get(0).toString().c_str(),"mat","good tag");
     YARP_DEBUG(Logger::get(),"an example image:");
     YARP_DEBUG(Logger::get(),bot.toString().c_str());
 }
开发者ID:apaikan,项目名称:yarp,代码行数:15,代码来源:ImageTest.cpp


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