本文整理汇总了C++中key_type::compareTo方法的典型用法代码示例。如果您正苦于以下问题:C++ key_type::compareTo方法的具体用法?C++ key_type::compareTo怎么用?C++ key_type::compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类key_type
的用法示例。
在下文中一共展示了key_type::compareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
MappingIterator::MappingIterator(const ObjectHandle& containerHandle, const container_type& container,
const key_type& key, const Converters& typeConverters)
: containerHandle_(containerHandle), container_(container), keys_(container_.keys(PyScript::ScriptErrorPrint())),
index_(0), key_(key), typeConverters_(typeConverters)
{
if (!key_.exists())
{
index_ = container_.size();
}
else
{
bool found = false;
// If the key is not found, then index_ == end
for (; index_ < keys_.size(); ++index_)
{
auto scriptKey = keys_.getItem(index_);
if (key.compareTo(scriptKey, PyScript::ScriptErrorPrint()) == 0)
{
found = true;
break;
}
}
// HACK NGT-1603 Try to cast key to an index
// Work-around for how ReflectedPropertyItem::getChild will try to
// access items with the a string "[index]"
if (!found)
{
Variant result;
ObjectHandle parentHandle;
const char* childPath = "";
const bool success = typeConverters_.toVariant(key_, result, parentHandle, childPath);
PyScript::ScriptList::size_type fakeIndex = container_.size();
const bool isIndex = result.tryCast(fakeIndex);
if (isIndex && (fakeIndex >= 0) && (fakeIndex < container_.size()))
{
index_ = fakeIndex;
key_ = keys_.getItem(index_);
}
}
}
}