Beispiel #1
0
bool Stamp::write(ConnectionWriter& connection) {
    connection.appendInt(BOTTLE_TAG_LIST); // nested structure
    connection.appendInt(2);               // with two elements
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(sequenceNumber);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(timeStamp);
    connection.convertTextMode();
    return !connection.isError();
}
Beispiel #2
0
bool Value::write(ConnectionWriter& connection) {
    if (!proxy) {
        connection.appendInt(BOTTLE_TAG_LIST);
        connection.appendInt(0);
        return !connection.isError();
    }
    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(1);
    return proxy->write(connection);
}
Beispiel #3
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();
}
Beispiel #4
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~
//   SERIALIZATION methods
//~~~~~~~~~~~~~~~~~~~~~~
bool dynContact::write(ConnectionWriter& connection) const{
    // represent a dynContact as a list of 4 elements that are:
    // - a list of 3 int, i.e. contactId, bodyPart, linkNumber
    // - a list of 3 double, i.e. the CoP
    // - a list of 3 double, i.e. the force
    // - a list of 3 double, i.e. the moment

    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(4);
    // list of 3 int, i.e. contactId, bodyPart, linkNumber
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_INT);
    connection.appendInt(3);
    connection.appendInt(contactId);
    connection.appendInt(bodyPart);    // left_arm, right_arm, ...
    connection.appendInt(linkNumber);
    // list of 3 double, i.e. the CoP
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(CoP[i]);
    // list of 3 double, i.e. the force
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(F[i]);
    // list of 3 double, i.e. the moment
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(Mu[i]);  

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();  
    
    return !connection.isError();
}
Beispiel #5
0
bool StoreBlob::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length());
    writer.appendBlock(x.c_str(),x.length());
    return true;
}
Beispiel #6
0
bool StoreString::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length()+1);
    writer.appendBlock(x.c_str(),x.length()+1); // need \0
    return true;
}
Beispiel #7
0
bool StoreVocab::writeRaw(ConnectionWriter& writer) {
    writer.appendInt(x);
    return true;
}
Beispiel #8
0
bool Storable::write(ConnectionWriter& connection) {
    connection.appendInt(getCode());
    return writeRaw(connection);
}
Beispiel #9
0
 virtual bool write(ConnectionWriter& connection) {
     printf("Writing an integer\n");
     connection.appendInt(val);
     return true;
 }