You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/11/02 20:46:48 UTC
[28/50] qpid-proton git commit: PROTON-1937: Use value.type() to
check for value presence or absence
PROTON-1937: Use value.type() to check for value presence or absence
This closes #158
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/436275a3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/436275a3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/436275a3
Branch: refs/heads/go1
Commit: 436275a37349b7c909dc397ae3aff704e49b7ba0
Parents: e7930c0
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon Sep 24 16:06:29 2018 -0400
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon Sep 24 16:06:29 2018 -0400
----------------------------------------------------------------------
cpp/src/connect_config.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/436275a3/cpp/src/connect_config.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/connect_config.cpp b/cpp/src/connect_config.cpp
index 3ec16fb..d85eb04 100644
--- a/cpp/src/connect_config.cpp
+++ b/cpp/src/connect_config.cpp
@@ -70,7 +70,7 @@ Value validate(ValueType t, const Value& v, const string& name) {
}
Value get(ValueType t, const Value& obj, const char *key, const Value& dflt=Value()) {
- Value v = obj ? obj.get(key, dflt) : dflt;
+ Value v = (obj.type() != nullValue) ? obj.get(key, dflt) : dflt;
return validate(t, v, key);
}
@@ -93,7 +93,7 @@ bool exists(const string& name) { return std::ifstream(name.c_str()).good(); }
void parse_sasl(Value root, connection_options& opts) {
Value sasl = root.get("sasl", Value());
opts.sasl_enabled(get_bool(sasl, "enable", true));
- if (sasl) {
+ if (sasl.type() != nullValue) {
validate(objectValue, sasl, "sasl");
opts.sasl_allow_insecure_mechs(get_bool(sasl, "allow_insecure", false));
Value mechs = sasl.get("mechanisms", Value());
@@ -124,7 +124,7 @@ void parse_sasl(Value root, connection_options& opts) {
void parse_tls(const string& scheme, Value root, connection_options& opts) {
Value tls = root.get("tls", Value());
- if (tls) {
+ if (tls.type() != nullValue) {
validate(objectValue, tls, "tls");
if (scheme != "amqps") {
raise(msg() << "'tls' object is not allowed unless scheme is \"amqps\"");
@@ -133,9 +133,9 @@ void parse_tls(const string& scheme, Value root, connection_options& opts) {
bool verify = get_bool(tls, "verify", true);
Value cert = get(stringValue, tls, "cert");
ssl::verify_mode mode = verify ? ssl::VERIFY_PEER_NAME : ssl::ANONYMOUS_PEER;
- if (cert) {
+ if (cert.type() != nullValue) {
Value key = get(stringValue, tls, "key");
- ssl_certificate cert2 = key ?
+ ssl_certificate cert2 = (key.type() != nullValue) ?
ssl_certificate(cert.asString(), key.asString()) :
ssl_certificate(cert.asString());
opts.ssl_client_options(ssl_client_options(cert2, ca, mode));
@@ -165,9 +165,9 @@ std::string parse(std::istream& is, connection_options& opts) {
}
Value user = root.get("user", Value());
- if (user) opts.user(validate(stringValue, user, "user").asString());
+ if (user.type() != nullValue) opts.user(validate(stringValue, user, "user").asString());
Value password = root.get("password", Value());
- if (password) opts.password(validate(stringValue, password, "password").asString());
+ if (password.type() != nullValue) opts.password(validate(stringValue, password, "password").asString());
parse_sasl(root, opts);
parse_tls(scheme, root, opts);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org