Beispiel #1
0
size_t MessageEncoder::getEncodedSizeForValue(const qpid::types::Variant& value)
{
    size_t total = 0;
    switch (value.getType()) {
      case qpid::types::VAR_MAP:
        total += getEncodedSize(value.asMap(), true);
        break;
      case qpid::types::VAR_LIST:
        total += getEncodedSize(value.asList(), true);
        break;

      case qpid::types::VAR_VOID:
      case qpid::types::VAR_BOOL:
        total += 1;
        break;

      case qpid::types::VAR_UINT8:
      case qpid::types::VAR_INT8:
        total += 2;
        break;

      case qpid::types::VAR_UINT16:
      case qpid::types::VAR_INT16:
        total += 3;
        break;

      case qpid::types::VAR_UINT32:
      case qpid::types::VAR_INT32:
      case qpid::types::VAR_FLOAT:
        total += 5;
        break;

      case qpid::types::VAR_UINT64:
      case qpid::types::VAR_INT64:
      case qpid::types::VAR_DOUBLE:
        total += 9;
        break;

      case qpid::types::VAR_UUID:
        total += 17;
        break;

      case qpid::types::VAR_STRING:
        total += 1/*code*/ + encodedSize(value.getString());
        break;
    }
    return total;
}
void ConnectionOptions::set(const std::string& name, const qpid::types::Variant& value)
{
    if (name == "reconnect") {
        reconnect = value;
    } else if (name == "reconnect-timeout" || name == "reconnect_timeout") {
        timeout = timeValue(value);
    } else if (name == "reconnect-limit" || name == "reconnect_limit") {
        limit = value;
    } else if (name == "reconnect-interval" || name == "reconnect_interval") {
        maxReconnectInterval = minReconnectInterval = timeValue(value);
    } else if (name == "reconnect-interval-min" || name == "reconnect_interval_min") {
        minReconnectInterval = timeValue(value);
    } else if (name == "reconnect-interval-max" || name == "reconnect_interval_max") {
        maxReconnectInterval = timeValue(value);
    } else if (name == "reconnect-urls-replace" || name == "reconnect_urls_replace") {
        replaceUrls = value.asBool();
    } else if (name == "reconnect-urls" || name == "reconnect_urls") {
        if (replaceUrls) urls.clear();
        if (value.getType() == qpid::types::VAR_LIST) {
            merge(value.asList(), urls);
        } else {
            merge(value.asString(), urls);
        }
    } else if (name == "username") {
        username = value.asString();
    } else if (name == "password") {
        password = value.asString();
    } else if (name == "sasl-mechanism" || name == "sasl_mechanism" ||
               name == "sasl-mechanisms" || name == "sasl_mechanisms") {
        mechanism = value.asString();
    } else if (name == "sasl-service" || name == "sasl_service") {
        service = value.asString();
    } else if (name == "sasl-min-ssf" || name == "sasl_min_ssf") {
        minSsf = value;
    } else if (name == "sasl-max-ssf" || name == "sasl_max_ssf") {
        maxSsf = value;
    } else if (name == "heartbeat") {
        heartbeat = value;
    } else if (name == "tcp-nodelay" || name == "tcp_nodelay") {
        tcpNoDelay = value;
    } else if (name == "locale") {
        locale = value.asString();
    } else if (name == "max-channels" || name == "max_channels") {
        maxChannels = value;
    } else if (name == "max-frame-size" || name == "max_frame_size") {
        maxFrameSize = value;
    } else if (name == "bounds") {
        bounds = value;
    } else if (name == "transport") {
        protocol = value.asString();
    } else if (name == "ssl-cert-name" || name == "ssl_cert_name") {
        sslCertName = value.asString();
    } else if (name == "ssl-ignore-hostname-verification-failure" || name == "ssl_ignore_hostname_verification_failure") {
        sslIgnoreHostnameVerificationFailure = value;
    } else if (name == "x-reconnect-on-limit-exceeded" || name == "x_reconnect_on_limit_exceeded") {
        reconnectOnLimitExceeded = value;
    } else if (name == "container-id" || name == "container_id") {
        identifier = value.asString();
    } else if (name == "nest-annotations" || name == "nest_annotations") {
        nestAnnotations = value;
    } else if (name == "set-to-on-send" || name == "set_to_on_send") {
        setToOnSend = value;
    } else if (name == "properties" || name == "client-properties" || name == "client_properties") {
        properties = value.asMap();
    } else {
        throw qpid::messaging::MessagingException(QPID_MSG("Invalid option: " << name << " not recognised"));
    }
}
Beispiel #3
0
bool PnData::read(pn_type_t type, qpid::types::Variant& value)
{
    switch (type) {
      case PN_NULL:
        if (value.getType() != qpid::types::VAR_VOID) value = qpid::types::Variant();
        return true;
      case PN_BOOL:
        value = pn_data_get_bool(data);
        return true;
      case PN_UBYTE:
        value = pn_data_get_ubyte(data);
        return true;
      case PN_BYTE:
        value = pn_data_get_byte(data);
        return true;
      case PN_USHORT:
        value = pn_data_get_ushort(data);
        return true;
      case PN_SHORT:
        value = pn_data_get_short(data);
        return true;
      case PN_UINT:
        value = pn_data_get_uint(data);
        return true;
      case PN_INT:
        value = pn_data_get_int(data);
        return true;
      case PN_CHAR:
        value = pn_data_get_char(data);
        return true;
      case PN_ULONG:
        value = pn_data_get_ulong(data);
        return true;
      case PN_LONG:
        value = pn_data_get_long(data);
        return true;
      case PN_TIMESTAMP:
        value = pn_data_get_timestamp(data);
        return true;
      case PN_FLOAT:
        value = pn_data_get_float(data);
        return true;
      case PN_DOUBLE:
        value = pn_data_get_double(data);
        return true;
      case PN_UUID:
        value = qpid::types::Uuid(pn_data_get_uuid(data).bytes);
        return true;
      case PN_BINARY:
        value = str(pn_data_get_binary(data));
        value.setEncoding(qpid::types::encodings::BINARY);
        return true;
      case PN_STRING:
        value = str(pn_data_get_string(data));
        value.setEncoding(qpid::types::encodings::UTF8);
        return true;
      case PN_SYMBOL:
        value = str(pn_data_get_string(data));
        value.setEncoding(qpid::types::encodings::ASCII);
        return true;
      case PN_LIST:
        value = qpid::types::Variant::List();
        readList(value.asList());
        return true;
        break;
      case PN_MAP:
        value = qpid::types::Variant::Map();
        readMap(value.asMap());
        return true;
      case PN_ARRAY:
        value = qpid::types::Variant::List();
        readArray(value.asList());
        return true;
      case PN_DESCRIBED:
      case PN_DECIMAL32:
      case PN_DECIMAL64:
      case PN_DECIMAL128:
      default:
        return false;
    }

}