qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Robie <jwro...@mindspring.com>
Subject Type woes - C++ broker
Date Tue, 31 Mar 2009 20:36:18 GMT
I'm trying to bind XQuery variables to message headers, using the 
correct type for each header.

I don't see how to get any arbitrary typed value from a header in our 
current API. It's easy to get integer values or string values:

boost::shared_ptr<FieldValue> value
value->get<int>()
value->get<string>()

Is there a good general way to get a typed value from a FieldValue?

Check the code snippet below my signature to understand what I'm trying 
to do.

Jonathan

void bindVariable(boost::shared_ptr<DynamicContext> context, std::string 
name, boost::shared_ptr<FieldValue> value)
{
    QPID_LOG(trace, "XmlExchange, binding external variable: " << name 
<< " = " << value << " (" << value->getType() << ")");

    Item::Ptr item;

    switch (value->getType()) {

        case TYPE_CODE_INT8:
        case TYPE_CODE_INT16:
        case TYPE_CODE_INT32:
        case TYPE_CODE_INT64:
            item = 
context->getItemFactory()->createInteger(value->get<int>(), context.get());
        break;

/*
  Need to do this for all simple types allowed for headers
*/

    default:
        QPID_LOG(trace, "XmlExchange, no support for headers of this 
type: " << value->getType());
        return;
    }

    context->setExternalVariable(X(name.c_str()), item);
    return;
}




---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Mime
View raw message