本文整理汇总了C++中CoreDict::items方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreDict::items方法的具体用法?C++ CoreDict::items怎么用?C++ CoreDict::items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreDict
的用法示例。
在下文中一共展示了CoreDict::items方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mth_dictValues
FALCON_FUNC mth_dictValues( ::Falcon::VMachine *vm )
{
Item *i_dict;
if( vm->self().isMethodic() )
{
i_dict = &vm->self();
}
else {
i_dict = vm->param(0);
if( i_dict == 0 || ! i_dict->isDict() )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( "D" ) );
}
}
CoreDict *dict = i_dict->asDict();
CoreArray *array = new CoreArray;
array->reserve( dict->length() );
Iterator iter( &dict->items() );
while( iter.hasCurrent() )
{
array->append( iter.getCurrent() );
iter.next();
}
vm->retval( array );
}
示例2: Dictionary_mfcomp
FALCON_FUNC Dictionary_mfcomp ( ::Falcon::VMachine *vm )
{
Item* i_func = vm->param(0);
if ( i_func == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.extra( "C, ..." ) );
}
// Save the parameters as the stack may change greatly.
CoreDict* dict = vm->self().asDict();
StackFrame* current = vm->currentFrame();
Item i_check = *i_func;
// if this is a blessed dictionary, we must use the append method.
if ( dict->isBlessed() )
{
// this will throw if dict has not "append"
PoopSeq *seq = new PoopSeq( vm, dict );
vm->pushParam( new GarbagePointer( seq ) );
seq->comprehension_start( vm, dict, i_check );
}
else {
dict->items().comprehension_start( vm, dict, i_check );
}
for( uint32 i = 1; i < current->m_param_count; ++i )
{
vm->pushParam( current->m_params[i] );
}
}
示例3: Dictionary_comp
FALCON_FUNC Dictionary_comp ( ::Falcon::VMachine *vm )
{
if ( vm->param(0) == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.extra( "R|A|C|Sequence, [C]" ) );
}
// Save the parameters as the stack may change greatly.
CoreDict* dict = vm->self().asDict();
Item i_gen = *vm->param(0);
Item i_check = vm->param(1) == 0 ? Item(): *vm->param(1);
// if this is a blessed dictionary, we must use the append method.
if ( dict->isBlessed() )
{
// this will throw if dict has not "append"
PoopSeq *seq = new PoopSeq( vm, dict );
vm->pushParam( new GarbagePointer( seq ) );
seq->comprehension_start( vm, dict, i_check );
}
else {
dict->items().comprehension_start( vm, dict, i_check );
}
vm->pushParam( i_gen );
}
示例4: Dictionary_do
FALCON_FUNC Dictionary_do ( ::Falcon::VMachine *vm )
{
Item* i_func = vm->param(0);
if ( i_func == 0 || ! i_func->isCallable() )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.extra( "C, ..." ) );
}
// Save the parameters as the stack may change greatly.
CoreDict* dict = vm->self().asDict();
if ( dict->empty() )
{
vm->retnil();
return;
}
Iterator* iter = new Iterator(&dict->items());
vm->addLocals(1);
*vm->local(0) = new GarbagePointer(iter);
vm->returnHandler( Dictionary_do_next );
// do the first call.
vm->pushParam( iter->getCurrentKey() );
vm->pushParam( iter->getCurrent() );
vm->callFrame( *vm->param(0), 2 );
}
示例5: URI_setFields
/*# @method setFields URI
@brief Sets query fields for this uri.
@param fields A dictionary of fields or nil to clear the query.
@raise ParamError if the input dictionary contains non-string values.
*/
FALCON_FUNC URI_setFields ( ::Falcon::VMachine *vm )
{
UriObject *self = dyncast<UriObject*>( vm->self().asObject() );
URI &uri = self->uri();
Item *p0 = vm->param(0);
if ( ( p0 == 0 ) || ( ! p0->isDict() ) )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
origin( e_orig_runtime ).extra( "S" ) );
return;
}
CoreDict *dict = p0->asDict();
Iterator iter( &dict->items() );
while( iter.hasCurrent() )
{
if ( ( !iter.getCurrentKey().isString()) || (! iter.getCurrent().isString() ) )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
origin( e_orig_runtime ).extra( "S" ) );
return;
}
uri.setField( *iter.getCurrentKey().asString(), *iter.getCurrent().asString() );
iter.next();
}
uri.makeQuery();
}
示例6: mth_dictFront
/*#
@function dictFront
@brief Returns the first item in the dictionary.
@param dict The dictionary on which to operate.
@optparam remove If true, remove the dictionary entry too.
@optparam key If true, return the key instead of the value.
@return The first value (or key) in the dictionary.
@raise AccessError if the dictionary is empty
*/
FALCON_FUNC mth_dictFront( ::Falcon::VMachine *vm )
{
CoreDict* dict;
bool bKey;
bool bRemove;
process_dictFrontBackParams( vm, dict, bKey, bRemove );
Iterator iter( &dict->items() );
if ( bKey )
vm->retval( iter.getCurrentKey() );
else
vm->retval( iter.getCurrent() );
if ( bRemove )
iter.erase();
}
示例7: mth_dictFill
/*#
@method fill Dictionary
@brief Fills the array with the given element.
@param item The item to be replicated.
@return This dictionary.
This method allows to clear all the values in this dictionary,
resetting all the elements to a default value.
*/
FALCON_FUNC mth_dictFill ( ::Falcon::VMachine *vm )
{
Item *i_dict;
Item *i_item;
if ( vm->self().isMethodic() )
{
i_dict = &vm->self();
i_item = vm->param(0);
}
else
{
i_dict = vm->param(0);
i_item = vm->param(1);
}
if ( i_dict == 0 || ! i_dict->isDict()
|| i_item == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( vm->self().isMethodic() ? "X" : "D,X" ) );
}
CoreDict *dict = i_dict->asDict();
Iterator iter( &dict->items() );
while( iter.hasCurrent() )
{
if ( i_item->isString() )
iter.getCurrent() = new CoreString( *i_item->asString() );
else
iter.getCurrent() = *i_item;
iter.next();
}
vm->retval( dict );
}
示例8: Dictionary_mcomp
FALCON_FUNC Dictionary_mcomp ( ::Falcon::VMachine *vm )
{
// Save the parameters as the stack may change greatly.
CoreDict* dict = vm->self().asDict();
StackFrame* current = vm->currentFrame();
// if this is a blessed dictionary, we must use the append method.
if ( dict->isBlessed() )
{
// this will throw if dict has not "append"
PoopSeq *seq = new PoopSeq( vm, dict );
vm->pushParam( new GarbagePointer( seq ) );
seq->comprehension_start( vm, dict, Item() );
}
else {
dict->items().comprehension_start( vm, dict, Item() );
}
for( uint32 i = 0; i < current->m_param_count; ++i )
{
vm->pushParam( current->m_params[i] );
}
}
示例9: mth_dictFind
FALCON_FUNC mth_dictFind( ::Falcon::VMachine *vm )
{
Item *i_dict, *i_key;
if( vm->self().isMethodic() )
{
i_dict = &vm->self();
i_key = vm->param(0);
}
else {
i_dict = vm->param(0);
i_key = vm->param(1);
}
if( i_dict == 0 || ! i_dict->isDict() || i_key == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( vm->self().isMethodic() ? "X" : "D,X" ) );
}
CoreDict *dict = i_dict->asDict();
Iterator iter( &dict->items() );
if ( ! dict->findIterator( *i_key, iter ) )
vm->retnil();
else
{
// find the iterator class, we'll need it
Item *i_iclass = vm->findWKI( "Iterator" );
fassert( i_iclass != 0 );
CoreObject *ival = i_iclass->asClass()->createInstance( new Iterator( iter ) );
ival->setProperty( "_origin", *i_dict );
vm->retval( ival );
}
}
示例10: describe_internal
//.........这里部分代码省略.........
if ( count == 0 ) tgt += " ";
describe_internal( vm, tgt, & ((*arr)[count]), level + 1, maxLevel, maxSize );
if ( count + 1 < arr->length() )
tgt += ", ";
}
tgt +="]";
}
break;
case FLC_ITEM_DICT:
{
CoreDict *dict = elem->asDict();
if( dict->isBlessed() )
tgt += "*";
tgt += "[";
if ( level == maxLevel )
{
tgt += "...=>...]";
break;
}
if ( dict->length() == 0 )
{
tgt += "=>]";
break;
}
Item key, value;
Iterator iter( &dict->items() );
// separate the first loop to be able to add ", "
describe_internal( vm, tgt, &iter.getCurrentKey(), level + 1, maxLevel, maxSize );
tgt += " => ";
describe_internal( vm, tgt, &iter.getCurrent(), level + 1, maxLevel, maxSize );
iter.next();
while( iter.hasCurrent() )
{
tgt += ", ";
describe_internal( vm, tgt, &iter.getCurrentKey(), level + 1, maxLevel, maxSize );
tgt += " => ";
describe_internal( vm, tgt, &iter.getCurrent(), level + 1, maxLevel, maxSize );
iter.next();
}
tgt += "]";
}
break;
case FLC_ITEM_OBJECT:
{
CoreObject *arr = elem->asObjectSafe();
tgt += arr->generator()->symbol()->name() + "(){ ";
if ( level == maxLevel )
{
tgt += "...}";
break;
}
const PropertyTable &pt = arr->generator()->properties();
示例11: inspect_internal
//.........这里部分代码省略.........
break;
}
stream->writeString( "{\n" );
for( count = 0; count < arr->length(); count++ ) {
inspect_internal( vm, & ((*arr)[count]), level + 1, maxLevel, maxSize, i_stream, true, true );
}
for ( i = 0; i < level; i ++ )
{
stream->writeString( " " );
}
stream->writeString( "}" );
}
break;
case FLC_ITEM_DICT:
{
CoreDict *dict = elem->asDict();
temp = "Dict[";
temp.writeNumber( (int64) dict->length() );
temp += "]";
stream->writeString( temp );
if ( level == maxLevel )
{
stream->writeString( "{...}" );
break;
}
stream->writeString( "{\n" );
Iterator iter( &dict->items() );
while( iter.hasCurrent() )
{
inspect_internal( vm, &iter.getCurrentKey(), level + 1, maxLevel, maxSize, i_stream, true, false );
stream->writeString( " => " );
inspect_internal( vm, &iter.getCurrent(), level + 1, maxLevel, maxSize, i_stream, false, true );
iter.next();
}
for ( i = 0; i < level; i ++ )
{
stream->writeString(" ");
}
stream->writeString( "}" );
}
break;
case FLC_ITEM_OBJECT:
{
CoreObject *arr = elem->asObjectSafe();
stream->writeString( "Object of class " + arr->generator()->symbol()->name() );
if ( level == maxLevel )
{
stream->writeString( "{...}" );
break;
}
stream->writeString( " {\n" );
const PropertyTable &pt = arr->generator()->properties();
for( count = 0; count < pt.added() ; count++ )
{
for ( i = 0; i < (level+1); i ++ )
{
示例12: serialize
//.........这里部分代码省略.........
this->asMemBuf()->serialize( file, bLive );
}
}
break;
case FLC_ITEM_ARRAY:
{
byte type = FLC_ITEM_ARRAY;
file->write((byte *) &type, 1 );
CoreArray &array = *this->asArray();
int32 len = endianInt32( array.length() );
file->write( (byte *) &len, sizeof( len ) );
for( uint32 i = 0; i < array.length(); i ++ ) {
array[i].serialize( file, bLive );
if( ! file->good() )
return sc_ferror;
}
}
break;
case FLC_ITEM_DICT:
{
byte type = FLC_ITEM_DICT;
file->write( &type, 1 );
CoreDict *dict = this->asDict();
type = dict->isBlessed() ? 1:0;
file->write( &type, 1 );
int32 len = endianInt32( dict->length() );
file->write( (byte *) &len, sizeof( len ) );
Iterator iter( &dict->items() );
while( iter.hasCurrent() )
{
iter.getCurrentKey().serialize( file, bLive );
if( ! file->good() )
return sc_ferror;
iter.getCurrent().serialize( file, bLive );
if( ! file->good() )
return sc_ferror;
iter.next();
}
}
break;
case FLC_ITEM_FUNC:
serialize_function( file, this->asFunction(), bLive );
break;
case FLC_ITEM_METHOD:
{
byte type = FLC_ITEM_METHOD;
file->write( &type, 1 );
e_sercode sc = asMethodItem().serialize( file, bLive );
if( sc != sc_ok )
return sc;
CallPoint* cp = this->asMethodFunc();
if ( cp->isFunc() )
{
serialize_function( file, static_cast<CoreFunc*>(cp), bLive );
}