本文整理汇总了C++中CoreDict::length方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreDict::length方法的具体用法?C++ CoreDict::length怎么用?C++ CoreDict::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreDict
的用法示例。
在下文中一共展示了CoreDict::length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: describe_internal
static void describe_internal( VMachine *vm, String &tgt, const Item *elem, int32 level, int32 maxLevel, int32 maxSize )
{
uint32 count;
// return if we reached the maximum level.
if ( maxLevel >= 0 && level > maxLevel )
{
tgt += "...";
return;
}
switch( elem->type() )
{
case FLC_ITEM_NIL:
tgt += "Nil";
break;
case FLC_ITEM_UNB:
tgt += "_";
break;
case FLC_ITEM_BOOL:
tgt += elem->asBoolean() ? "true" : "false";
break;
case FLC_ITEM_INT:
tgt.writeNumber( elem->asInteger() );
break;
case FLC_ITEM_NUM:
tgt.writeNumber( elem->asNumeric(), "%g" );
break;
case FLC_ITEM_RANGE:
elem->toString(tgt);
break;
case FLC_ITEM_STRING:
tgt += "\"";
if ( maxSize < 0 || elem->asString()->length() < (uint32) maxSize )
{
tgt += *elem->asString();
tgt += "\"";
}
else {
tgt += elem->asString()->subString(0, maxSize );
tgt += " ... \"";
}
break;
case FLC_ITEM_LBIND:
tgt += "&";
tgt += *elem->asLBind();
if (elem->isFutureBind())
{
tgt +="|";
describe_internal( vm, tgt, &elem->asFutureBind(), level+1, maxLevel, maxSize );
}
break;
case FLC_ITEM_MEMBUF:
{
MemBuf *mb = elem->asMemBuf();
tgt += "MB(";
tgt.writeNumber( (int64) mb->length() );
tgt += ",";
tgt.writeNumber( (int64) mb->wordSize() );
tgt += ")";
tgt += " [";
String fmt;
int limit = 0;
switch ( mb->wordSize() )
{
case 1: fmt = "%02" LLFMT "X"; limit = 24; break;
case 2: fmt = "%04" LLFMT "X"; limit = 12; break;
case 3: fmt = "%06" LLFMT "X"; limit = 9; break;
case 4: fmt = "%08" LLFMT "X"; limit = 6; break;
}
uint32 max = maxSize < 0 || mb->length() < (uint32) maxSize ? mb->length() : (uint32) maxSize;
for( count = 0; count < max; count++ )
{
tgt.writeNumber( (int64) mb->get( count ), fmt );
tgt += " ";
}
if ( count == (uint32) maxSize )
tgt += " ...";
tgt += "]";
}
break;
case FLC_ITEM_ARRAY:
{
CoreArray *arr = elem->asArray();
tgt += "[";
//.........这里部分代码省略.........
示例3: inspect_internal
void inspect_internal( VMachine *vm, const Item *elem, int32 level, int32 maxLevel, int32 maxSize, Item* i_stream, bool add, bool addline )
{
uint32 count;
int32 i;
Stream *stream = i_stream != 0 ?
dyncast<Stream*>(i_stream->asObjectSafe()->getFalconData()) :
vm->stdErr();
// return if we reached the maximum level.
if ( maxLevel >= 0 && level > maxLevel )
{
stream->writeString( "..." );
if ( addline )
stream->writeString( "\n" );
return;
}
if ( stream == 0 )
{
stream = vm->stdOut();
if ( stream == 0 )
return;
}
if ( add )
for ( i = 0; i < level*3; i ++ )
{
stream->put( 0x20 ); // space
}
if ( elem == 0 ) {
stream->writeString( "Nothing" );
if ( addline )
stream->writeString( "\n" );
return;
}
String temp;
switch( elem->type() )
{
case FLC_ITEM_NIL:
stream->writeString( "Nil" );
break;
case FLC_ITEM_UNB:
stream->writeString( "_" );
break;
case FLC_ITEM_BOOL:
stream->writeString( elem->asBoolean() ? "true" : "false" );
break;
case FLC_ITEM_INT:
temp.writeNumber( elem->asInteger() );
stream->writeString( "int(" );
stream->writeString( temp );
stream->writeString( ")" );
break;
case FLC_ITEM_NUM:
temp.writeNumber( elem->asNumeric(), "%g" );
stream->writeString( "num(" );
stream->writeString( temp );
stream->writeString( ")" );
break;
case FLC_ITEM_RANGE:
elem->toString(temp);
stream->writeString( temp );
break;
case FLC_ITEM_STRING:
stream->writeString( "\"" );
if ( maxSize < 0 || elem->asString()->length() < (uint32) maxSize )
{
stream->writeString( *elem->asString() );
stream->writeString( "\"" );
}
else {
stream->writeString( elem->asString()->subString(0, maxSize ) );
stream->writeString( " ... \"" );
}
break;
case FLC_ITEM_LBIND:
stream->writeString( "&" );
stream->writeString( *elem->asLBind() );
break;
case FLC_ITEM_MEMBUF:
{
MemBuf *mb = elem->asMemBuf();
temp = "MemBuf(";
temp.writeNumber( (int64) mb->length() );
temp += ",";
temp.writeNumber( (int64) mb->wordSize() );
temp += ")";
//.........这里部分代码省略.........
示例4: serialize
Item::e_sercode Item::serialize( Stream *file, bool bLive ) const
{
if( file->bad() )
return sc_ferror;
switch( this->type() )
{
case FLC_ITEM_BOOL:
{
byte type = FLC_ITEM_BOOL;
file->write((byte *) &type, 1 );
byte bval = this->asBoolean() ? 1 : 0;
file->write( (byte *) &bval, sizeof( bval ) );
}
break;
case FLC_ITEM_INT:
{
byte type = FLC_ITEM_INT;
file->write((byte *) &type, 1 );
int64 val = endianInt64( this->asInteger() );
file->write( (byte *) &val, sizeof( val ) );
}
break;
case FLC_ITEM_RANGE:
{
byte type = FLC_ITEM_RANGE;
file->write((byte *) &type, 1 );
int64 val1 = endianInt64(this->asRangeStart());
int64 val2 = endianInt64(this->asRangeEnd());
int64 val3 = endianInt64(this->asRangeStep());
//byte isOpen = this->asRangeIsOpen() ? 1 : 0;
file->write( (byte *) &val1, sizeof( val1 ) );
file->write( (byte *) &val2, sizeof( val2 ) );
file->write( (byte *) &val3, sizeof( val3 ) );
//file->write( (byte *) &isOpen, sizeof( isOpen ) );
}
break;
case FLC_ITEM_NUM:
{
byte type = FLC_ITEM_NUM;
file->write((byte *) &type, 1 );
numeric val = endianNum( this->asNumeric() );
file->write( (byte *) &val, sizeof( val ) );
}
break;
case FLC_ITEM_STRING:
{
byte type = FLC_ITEM_STRING;
file->write((byte *) &type, 1 );
this->asString()->serialize( file );
}
break;
case FLC_ITEM_LBIND:
{
byte type = FLC_ITEM_LBIND;
file->write((byte *) &type, 1 );
// Future bindings are temporary items; as such, their future
// value is not to be serialized.
asLBind()->serialize( file );
}
break;
case FLC_ITEM_MEMBUF:
{
byte type = FLC_ITEM_MEMBUF;
if ( bLive )
{
type |= 0x80;
file->write( &type, 1 );
MemBuf* mb = asMemBuf();
file->write( &mb, sizeof(mb) );
}
else {
file->write( &type, 1 );
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() )
//.........这里部分代码省略.........