コード例 #1
0
void MessageTransfer::processProperties(qpid::amqp::MapHandler& handler) const
{
    const qpid::framing::MessageProperties* mp = getProperties<qpid::framing::MessageProperties>();
    if (mp && mp->hasApplicationHeaders()) {
        const FieldTable ft = mp->getApplicationHeaders();
        for (FieldTable::const_iterator i = ft.begin(); i != ft.end(); ++i) {
            qpid::types::Variant v;
            qpid::amqp_0_10::translate(i->second, v);
            qpid::amqp::CharSequence key = {i->first.data(), i->first.size()};
            switch (v.getType()) {
            case qpid::types::VAR_VOID:
                handler.handleVoid(key); break;
            case qpid::types::VAR_BOOL:
                handler.handleBool(key, v); break;
            case qpid::types::VAR_UINT8:
                handler.handleUint8(key, v); break;
            case qpid::types::VAR_UINT16:
                handler.handleUint8(key, v); break;
            case qpid::types::VAR_UINT32:
                handler.handleUint32(key, v); break;
            case qpid::types::VAR_UINT64:
                handler.handleUint64(key, v); break;
            case qpid::types::VAR_INT8:
                handler.handleInt8(key, v); break;
            case qpid::types::VAR_INT16:
                handler.handleInt16(key, v); break;
            case qpid::types::VAR_INT32:
                handler.handleInt32(key, v); break;
            case qpid::types::VAR_INT64:
                handler.handleInt64(key, v); break;
            case qpid::types::VAR_FLOAT:
                handler.handleFloat(key, v); break;
            case qpid::types::VAR_DOUBLE:
                handler.handleDouble(key, v); break;
            case qpid::types::VAR_STRING: {
                std::string s(v);
                qpid::amqp::CharSequence value = {s.data(), s.size()};
                qpid::amqp::CharSequence encoding = {0, 0};
                handler.handleString(key, value, encoding);
                break;
            }
            case qpid::types::VAR_MAP:
            case qpid::types::VAR_LIST:
            case qpid::types::VAR_UUID:
                 QPID_LOG(debug, "Unhandled key!" << v);
                 break;
            }
        }
    }
}
コード例 #2
0
ファイル: ValueImpl.cpp プロジェクト: cajus/qpid-cpp-debian
void ValueImpl::initMap(const FieldTable& ft)
{
    for (FieldTable::ValueMap::const_iterator iter = ft.begin();
         iter != ft.end(); iter++) {
        const string&     name(iter->first);
        const FieldValue& fvalue(*iter->second);
        uint8_t amqType = fvalue.getType();

        if (amqType == 0x32) {
            Value* subval(new Value(TYPE_UINT64));
            subval->setUint64(fvalue.get<int64_t>());
            insert(name.c_str(), subval);
        } else if ((amqType & 0xCF) == 0x02) {
            Value* subval(new Value(TYPE_UINT32));
            switch (amqType) {
            case 0x02 : subval->setUint(fvalue.get<int>()); break;
            case 0x12 : subval->setUint(fvalue.get<int>()); break;
            case 0x22 : subval->setUint(fvalue.get<int>()); break;
            }
            insert(name.c_str(), subval);
        } else if (amqType == 0x31) {   // int64
            Value* subval(new Value(TYPE_INT64));
            subval->setInt64(fvalue.get<int64_t>());
            insert(name.c_str(), subval);
        } else if ((amqType & 0xCF) == 0x01) {  // 0x01:int8, 0x11:int16, 0x21:int21
            Value* subval(new Value(TYPE_INT32));
            subval->setInt((int32_t)fvalue.get<int>());
            insert(name.c_str(), subval);
        } else if (amqType == 0x85 || amqType == 0x95) {
            Value* subval(new Value(TYPE_LSTR));
            subval->setString(fvalue.get<string>().c_str());
            insert(name.c_str(), subval);
        } else if (amqType == 0x23 || amqType == 0x33) {
            Value* subval(new Value(TYPE_DOUBLE));
            subval->setDouble(fvalue.get<double>());
            insert(name.c_str(), subval);
        } else if (amqType == 0xa8) {
            FieldTable subFt;
            bool valid = qpid::framing::getEncodedValue<FieldTable>(iter->second, subFt);
            if (valid) {
                Value* subval(new Value(TYPE_MAP));
                subval->impl->initMap(subFt);
                insert(name.c_str(), subval);
            }
        } else if (amqType == 0xa9) {
            List subList;
            bool valid = qpid::framing::getEncodedValue<List>(iter->second, subList);
            if (valid) {
                Value* subval(new Value(TYPE_LIST));
                subval->impl->initList(subList);
                insert(name.c_str(), subval);
            }
        } else if (amqType == 0x08) {
            Value* subval(new Value(TYPE_BOOL));
            subval->setBool(fvalue.get<int>() ? true : false);
            insert(name.c_str(), subval);
        } else {
            QPID_LOG(error, "Unable to decode unsupported AMQP typecode=" << amqType << " map index=" << name);
        }
    }
}