You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Jonathan Robie <jw...@mindspring.com> on 2009/03/31 22:36:18 UTC

Type woes - C++ broker

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