MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / lookupWithPort

Method lookupWithPort

source/core/StarHostAddress.cpp:219–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219Either<String, HostAddressWithPort> HostAddressWithPort::lookupWithPort(String const& address) {
220 String host = address;
221 String port = host.rextract(":");
222 if (host.beginsWith("[") && host.endsWith("]"))
223 host = host.substr(1, host.size() - 2);
224
225 auto portNum = maybeLexicalCast<uint16_t>(port);
226 if (!portNum)
227 return makeLeft(strf("Could not parse port portion of HostAddressWithPort '{}'", port));
228
229 auto hostAddress = HostAddress::lookup(host);
230 if (hostAddress.isLeft())
231 return makeLeft(std::move(hostAddress.left()));
232
233 return makeRight(HostAddressWithPort(std::move(hostAddress.right()), *portNum));
234}
235
236HostAddressWithPort::HostAddressWithPort() : m_port(0) {}
237

Callers

nothing calls this directly

Calls 12

makeLeftFunction · 0.85
strfFunction · 0.85
makeRightFunction · 0.85
HostAddressWithPortClass · 0.85
rextractMethod · 0.80
isLeftMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
beginsWithMethod · 0.45
endsWithMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected