本文整理汇总了C++中ListIterator::current方法的典型用法代码示例。如果您正苦于以下问题:C++ ListIterator::current方法的具体用法?C++ ListIterator::current怎么用?C++ ListIterator::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListIterator
的用法示例。
在下文中一共展示了ListIterator::current方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_stl(ostream& output,
const ObjectWrapper &obj,
const LString &name, int _indent,int deref = 0)
{
const Address what = obj.get_address();
const MetaClass* type = obj.get_meta_class();
int field_deref = deref?deref-1:0;
output << type->get_instance_name()
<< '(' << type->get_meta_class_id() << ") ";
if (name)
output << ' ' << name << ' ';
STLMetaClass *p = (STLMetaClass*) type;
ListIterator* it = (ListIterator*) p->get_iterator(what);
output << '[' << it->length() << "] ";
if (it->current()) {
//output << "{\n";
output << endl;
//while (it->is_valid()) {
for (; it->is_valid(); it->next())
{
ObjectWrapper obj(it->current(), it->current_meta_class());
// const MetaClass* currentMetaClass = it->current_meta_class();
// const Address curAddr = it->current();
if (!obj.is_null()) {
indent(output, _indent+istep);
print2(output, obj, it->current_name(),
_indent+istep, field_deref);
}
//it->next();
}
//}
// } while (it->is_valid());
indent(output, _indent);
//output << "}\n";
}
else
output <<" {0x0}\n";
delete it;
return true;
}
示例2: if
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_list(ostream& output,
const ObjectWrapper &obj,
const LString &name,
int _indent, int deref = 0)
{
const Address what = obj.get_address();
const MetaClass* type = obj.get_meta_class();
//output << "list:deref = " << deref << endl;
int l_sep = list_separator;
int field_deref = deref?deref-1:0;
ListMetaClass *p = (ListMetaClass*) type;
ListIterator* it = (ListIterator*) p->get_iterator(what);
// bool verbose_list = false;
if (!print_all() && !it->is_valid()) {
if (list_separator != '\n')
output << "<None>";
return true;
}
size_t length = it->length();
if (!deref) {
if (print_all()) {
output << type->get_instance_name()
<< '(' << type->get_meta_class_id() << ") ";
if (name)
output << ' ' << name << ' ';
}
else // if (length != 1)
{
output <<"list ";
if (name)
output << ' ' << name << ' ';
}
}
else if (_indent > 0)
_indent -= istep;
{
if (print_all())
output << '[' << length << "]:";
if (it->current()) {
int num_elts = 0;
bool last_printed = true;
bool nl_needed = false;
if (deref && length == 1)
last_printed = false;
else {
//output << endl;
}
//output << '{';
//indent(output, istep);
//while (it->is_valid()) {
for (; it->is_valid(); it->next())
{
list_separator = l_sep;
ObjectWrapper element(it->current(),
it->current_meta_class());
// const MetaClass* currentMetaClass = it->current_meta_class();
// const Address curAddr = it->current();
if (!element.is_null()) {
// if (curAddr) {
if (last_printed &&
nl_needed) {
output << (char)list_separator;
if (list_separator != ' ') {
if (list_separator == '\n')
indent(output, _indent+istep);
else if (list_separator == ',')
output << ' ';
}
}
char buff[100] = { 0 };
if (print_all())
sprintf(buff,"[%d]", num_elts++);
last_printed = print2(output, element,
buff, _indent+istep, field_deref);
nl_needed = last_printed;
}
}
if (last_printed &&
nl_needed) {
if (list_separator == '\n') {
output << (char)list_separator;
indent(output, _indent+istep);
}
}
} else
output <<" {0x0} ";
}
delete it;
list_separator = l_sep;
return true;
}