本文整理汇总了C++中IPAddressSQLHelper::GetAddress1String方法的典型用法代码示例。如果您正苦于以下问题:C++ IPAddressSQLHelper::GetAddress1String方法的具体用法?C++ IPAddressSQLHelper::GetAddress1String怎么用?C++ IPAddressSQLHelper::GetAddress1String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddressSQLHelper
的用法示例。
在下文中一共展示了IPAddressSQLHelper::GetAddress1String方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: command
shared_ptr<SecurityRange>
PersistentSecurityRange::ReadMatchingIP(const IPAddress &ipaddress)
{
shared_ptr<SecurityRange> empty;
IPAddressSQLHelper helper;
String sSQL;
if (ipaddress.GetType() == IPAddress::IPV4)
{
shared_ptr<SecurityRange> pSR = shared_ptr<SecurityRange>(new SecurityRange());
sSQL.Format(_T("select * from hm_securityranges where %s >= rangelowerip1 and %s <= rangeupperip1 and rangelowerip2 IS NULL and rangeupperip2 IS NULL order by rangepriorityid desc"),
String(helper.GetAddress1String(ipaddress)), String(helper.GetAddress1String(ipaddress)));
if (!ReadObject(pSR, SQLCommand(sSQL)))
return empty;
return pSR;
}
else
{
// Read all IPv6 items.
shared_ptr<SecurityRange> bestMatch;
SQLCommand command(_T("select * from hm_securityranges where rangelowerip2 is not null order by rangepriorityid desc"));
shared_ptr<DALRecordset> recordset = Application::Instance()->GetDBManager()->OpenRecordset(command);
if (!recordset)
return empty;
while (!recordset->IsEOF())
{
shared_ptr<SecurityRange> securityRange = shared_ptr<SecurityRange>(new SecurityRange());
if (ReadObject(securityRange, recordset) == false)
return empty;
if (ipaddress.WithinRange(securityRange->GetLowerIP(), securityRange->GetUpperIP()))
{
// This IP range matches the client. Does it have higher prio than the currently
// matching?
if (!bestMatch || securityRange->GetPriority() > bestMatch->GetPriority())
bestMatch = securityRange;
}
recordset->MoveNext();
}
return bestMatch;
}
}