本文整理汇总了C++中DataType::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ DataType::exists方法的具体用法?C++ DataType::exists怎么用?C++ DataType::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTransportFromConfig
void OSSSIP::initTransportFromConfig(const boost::filesystem::path& cfgFile)
{
ClassType config;
config.load(OSS::boost_path(cfgFile));
DataType root = config.self();
DataType listeners = root["listeners"];
DataType interfaces = listeners["interfaces"];
int ifaceCount = interfaces.getElementCount();
bool hasFoundDefault = false;
for (int i = 0; i < ifaceCount; i++)
{
DataType iface = interfaces[i];
std::string ip = iface["ip-address"];
std::string external;
if (iface.exists("external-address"))
{
external = (const char*)iface["external-address"];
}
bool tlsEnabled = iface.exists("tls-enabled") && (bool)iface["tls-enabled"];
bool tcpEnabled = iface.exists("tcp-enabled") && (bool)iface["tcp-enabled"];
bool wsEnabled = iface.exists("ws-enabled") && (bool)iface["ws-enabled"];
bool udpEnabled = true;
if (iface.exists("udp-enabled"))
udpEnabled = (bool)iface["udp-enabled"];
int sipPort = iface.exists("sip-port") ? (int)iface["sip-port"] : 5060;
int tlsPort = iface.exists("tls-port") ? (int)iface["tls-port"] : 5061;
if (!hasFoundDefault)
{
if (iface.exists("default"))
{
hasFoundDefault = ((bool)iface["default"]);
bool transportEnabled = udpEnabled || tcpEnabled || wsEnabled || tlsEnabled;
if (hasFoundDefault && transportEnabled)
{
OSS::IPAddress listener;
listener = ip;
listener.externalAddress() = external;
listener.setPort(sipPort);
_fsmDispatch.transport().defaultListenerAddress() = listener;
}
}
}
if (udpEnabled)
{
OSS::IPAddress listener;
listener = ip;
listener.externalAddress() = external;
listener.setPort(sipPort);
_udpListeners.push_back(listener);
}
if (tcpEnabled)
{
OSS::IPAddress listener;
listener = ip;
listener.externalAddress() = external;
listener.setPort(sipPort);
_tcpListeners.push_back(listener);
}
if (wsEnabled)
{
OSS::IPAddress listener;
listener = ip;
listener.externalAddress() = external;
listener.setPort(sipPort);
_wsListeners.push_back(listener);
}
if (tlsEnabled)
{
OSS::IPAddress listener;
listener = ip;
listener.externalAddress() = external;
listener.setPort(tlsPort);
_tlsListeners.push_back(listener);
}
}
if (!hasFoundDefault)
{
//
// Set the default interface for the transport service the old fashioned way
//
if (listeners.exists("default-interface-address") &&
listeners.exists("default-interface-port"))
{
hasFoundDefault = true;
DataType defaultIface = listeners["default-interface-address"];
DataType defaultPort = listeners["default-interface-port"];
OSS::IPAddress defaultInterface((const char*)defaultIface);
defaultInterface.setPort((int)defaultPort);
//.........这里部分代码省略.........