void Encoder::writeValue()

in src/qpid/amqp/Encoder.cpp [414:485]


void Encoder::writeValue(const qpid::types::Variant& value, const Descriptor* d)
{
    if (d) {
        writeDescriptor(*d);    // Write this descriptor before any in the value.
        d = 0;
    }
    // Write any descriptors attached to the value.
    const Variant::List& descriptors = value.getDescriptors();
    for (Variant::List::const_iterator i = descriptors.begin(); i != descriptors.end(); ++i) {
        if (i->getType() == types::VAR_STRING)
            writeDescriptor(Descriptor(CharSequence::create(i->asString())));
        else
            writeDescriptor(Descriptor(i->asUint64()));
    }
    switch (value.getType()) {
      case qpid::types::VAR_VOID:
        writeNull(d);
        break;
      case qpid::types::VAR_BOOL:
        writeBoolean(value.asBool(), d);
        break;
      case qpid::types::VAR_UINT8:
        writeUByte(value.asUint8(), d);
        break;
      case qpid::types::VAR_UINT16:
        writeUShort(value.asUint16(), d);
        break;
      case qpid::types::VAR_UINT32:
        writeUInt(value.asUint32(), d);
        break;
      case qpid::types::VAR_UINT64:
        writeULong(value.asUint64(), d);
        break;
      case qpid::types::VAR_INT8:
        writeByte(value.asInt8(), d);
        break;
      case qpid::types::VAR_INT16:
        writeShort(value.asInt16(), d);
        break;
      case qpid::types::VAR_INT32:
        writeInt(value.asInt32(), d);
        break;
      case qpid::types::VAR_INT64:
        writeLong(value.asInt64(), d);
        break;
      case qpid::types::VAR_FLOAT:
        writeFloat(value.asFloat(), d);
        break;
      case qpid::types::VAR_DOUBLE:
        writeDouble(value.asDouble(), d);
        break;
      case qpid::types::VAR_STRING:
        if (value.getEncoding() == UTF8) {
            writeString(value.getString(), d);
        } else if (value.getEncoding() == ASCII) {
            writeSymbol(value.getString(), d);
        } else {
            writeBinary(value.getString(), d);
        }
        break;
      case qpid::types::VAR_MAP:
        writeMap(value.asMap(), d);
        break;
      case qpid::types::VAR_LIST:
        writeList(value.asList(), d);
        break;
      case qpid::types::VAR_UUID:
        writeUuid(value.asUuid(), d);
        break;
    }

}