本文整理汇总了C++中PtrList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ PtrList::push_back方法的具体用法?C++ PtrList::push_back怎么用?C++ PtrList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PtrList
的用法示例。
在下文中一共展示了PtrList::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetValue
// ------------------------------------------------------------------------------------------------
SQInteger LookupResult::GetValue(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
// The lookup result instance
LookupResult * lookup = nullptr;
// Attempt to extract the lookup result instance
try
{
lookup = Var< LookupResult * >(vm, 1).value;
}
catch (const Sqrat::Exception & e)
{
return sq_throwerror(vm, e.what());
}
// Do we have a valid lookup result instance?
if (!lookup)
{
return sq_throwerror(vm, "Invalid lookup result instance");
}
// See if there's a handle
else if (!lookup->m_Handle)
{
return sq_throwerror(vm, "Invalid Maxmind database reference");
}
// See if there's an entry
else if (!(lookup->m_Result.found_entry))
{
return sq_throwerror(vm, "Result does not have an entry");
}
typedef std::vector< StackStrF > ArgList;
// The list of extracted arguments
ArgList arglist;
// Extract each argument as a string
for (SQInteger i = 2; i <= top; ++i)
{
arglist.emplace_back(vm, i, false);
// Did we fail to extract the argument value?
if (SQ_FAILED(arglist.back().mRes))
{
return arglist.back().mRes; // Propagate the error
}
}
typedef std::vector< CSStr > PtrList;
// The list of pointers to path segments
PtrList ptrlist;
// Grab the pointers to argument values
for (const auto & a : arglist)
{
ptrlist.push_back(a.mPtr);
}
// Push null to specify the end of the list
ptrlist.push_back(nullptr);
MMDB_entry_data_s entry_data;
// Attempt to retrieve the specified entry data
const int status = MMDB_aget_value(&(lookup->m_Result.entry), &entry_data, ptrlist.data());
// Validate the status code
if (status != MMDB_SUCCESS)
{
return sq_throwerror(vm, ToStrF("Unable to get entry data [%s]", MMDB_strerror(status)));
}
// Push the resulted list object onto the stack
try
{
ClassType< EntryData >::PushInstance(vm, new EntryData(lookup->m_Handle, entry_data));
}
catch (const Sqrat::Exception & e)
{
return sq_throwerror(vm, e.what());
}
// Specify that we returned a value
return 1;
}