MCPcopy Create free account
hub / github.com/apache/qpid-proton / parse

Function parse

cpp/src/connect_config.cpp:151–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149} // namespace
150
151std::string parse(Value root, connection_options& opts) {
152 std::ostringstream addr;
153
154 validate(objectValue, root, "configuration");
155
156 string scheme = get_string(root, "scheme", "amqps");
157 if (scheme != "amqp" && scheme != "amqps") {
158 throw err(msg() << "'scheme' must be \"amqp\" or \"amqps\"");
159 }
160
161 string host = get_string(root, "host", "localhost");
162 opts.virtual_host(host.c_str());
163 addr << host << ":";
164
165 Value port = root.get("port", scheme);
166 switch (port.type()) {
167 case stringValue:
168 addr << port.asString(); break;
169 case intValue:
170 case uintValue:
171 addr << port.asUInt(); break;
172 default:
173 throw err(msg() << "'port' expected string or uint, found " << port.type());
174 }
175
176 Value user = get(stringValue, root, "user");
177 if (!user.isNull()) opts.user(user.asString());
178 Value password = get(stringValue, root, "password");
179 if (!password.isNull()) opts.password(password.asString());
180
181 parse_sasl(root, opts);
182 parse_tls(scheme, root, opts);
183
184 return addr.str();
185}
186
187bool config_file(std::ifstream& f, std::string& name) {
188 const char *env_path = getenv(ENV_VAR.c_str());

Callers 4

apply_configFunction · 0.70
parse_defaultFunction · 0.70
configureFunction · 0.70
parseMethod · 0.50

Calls 15

validateFunction · 0.85
get_stringFunction · 0.85
errFunction · 0.85
msgClass · 0.85
parse_saslFunction · 0.85
parse_tlsFunction · 0.85
c_strMethod · 0.80
getFunction · 0.70
virtual_hostMethod · 0.45
getMethod · 0.45
typeMethod · 0.45
userMethod · 0.45

Tested by 1

configureFunction · 0.56