예제 #1
0
bool PortCommand::write(ConnectionWriter& writer) {
    //ACE_DEBUG((LM_DEBUG,"PortCommand::writeBlock"));
    //ACE_OS::printf("Writing port command, text mode %d\n", writer.isTextMode());
    if (!writer.isTextMode()) {
        int len = 0;
        if (ch=='\0') {
            len = (int)str.length()+1;
        }
        yAssert(header.length()==8);
        char *base = header.get();
        Bytes b(base,4);
        NetType::netInt(len,b);
        base[4] = '~';
        base[5] = ch;
        base[6] = 0;
        base[7] = 1;
        writer.appendBlock(header.bytes().get(),header.bytes().length());
        if (ch=='\0') {
            writer.appendBlock(str.c_str(),str.length()+1);
        }
    } else {
        if (ch!='\0') {
            char buf[] = "X";
            buf[0] = ch;
            writer.appendString(ConstString(buf).c_str(),'\n');
        } else {
            writer.appendString(str.c_str(),'\n');
        }
    }
    return !writer.isError();
}
예제 #2
0
    virtual bool write(ConnectionWriter& connection)
    {
        connection.appendBlock((char*)&datum, sizeof(double));
        connection.appendBlock((char*)&payloadSize, sizeof(int));

        if (payloadSize>0)
            connection.appendBlock((char *)payload, payloadSize);

        return !connection.isError();
    }
예제 #3
0
bool BufferedConnectionWriter::write(ConnectionWriter& connection) const
{
    stopWrite();
    size_t i;
    for (i = 0; i < header_used; i++) {
        yarp::os::ManagedBytes& b = *(header[i]);
        connection.appendBlock(b.get(), b.used());
    }
    for (i = 0; i < lst_used; i++) {
        yarp::os::ManagedBytes& b = *(lst[i]);
        connection.appendBlock(b.get(), b.used());
    }
    return !connection.isError();
}
예제 #4
0
bool yarp::os::SizedWriter::write(ConnectionWriter& connection) const
{
    for (size_t i = 0; i < length(); i++) {
        connection.appendBlock((char*)data(i), length(i));
    }
    return true;
}
예제 #5
0
bool BottleImpl::write(ConnectionWriter& writer) {
    // could simplify this if knew lengths of blocks up front
    if (writer.isTextMode()) {
        //writer.appendLine(toString());
        writer.appendString(toString().c_str(),'\n');
    } else {
#ifdef USE_YARP1_PREFIX
        if (!nested) {
            String name = "YARP2";
            writer.appendInt(name.length()+1);
            writer.appendString(name.c_str(),'\0');
        }
#endif
        synch();
        /*
          if (!nested) {
          // No byte count any more, to facilitate nesting
          //YMSG(("bottle byte count %d\n",byteCount()));
          //writer.appendInt(byteCount()+sizeof(NetInt32));
          
          writer.appendInt(StoreList::code + speciality);
          }
        */
        //writer.appendBlockCopy(Bytes((char*)getBytes(),byteCount()));
        writer.appendBlock((char*)getBytes(),byteCount());
    }
    return !writer.isError();
}
예제 #6
0
bool StoreBlob::writeRaw(ConnectionWriter& writer) const
{
    writer.appendInt32(static_cast<std::int32_t>(x.length()));
    writer.appendBlock(x.c_str(), x.length());
    return true;
}
예제 #7
0
bool StoreBlob::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length());
    writer.appendBlock(x.c_str(),x.length());
    return true;
}
예제 #8
0
bool StoreString::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length()+1);
    writer.appendBlock(x.c_str(),x.length()+1); // need \0
    return true;
}
예제 #9
0
bool StoreDouble::writeRaw(ConnectionWriter& writer) {
    //writer.appendBlockCopy(Bytes((char*)&x,sizeof(x)));
    NetFloat64 flt = x;
    writer.appendBlock((char*)&flt,sizeof(flt));
    return true;
}