本文整理汇总了C++中CoreDict::find方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreDict::find方法的具体用法?C++ CoreDict::find怎么用?C++ CoreDict::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreDict
的用法示例。
在下文中一共展示了CoreDict::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mth_dictSet
/*#
@function set Dictionary
@brief Stores a value in a dictionary
@param key The key to be found.
@param value The key to be set.
@return True if the value was overwritten, false if it has been inserted anew.
@note This method bypassess setIndex__ override in blessed (POOP) dictionaries.
@see oob
*/
FALCON_FUNC mth_dictSet( ::Falcon::VMachine *vm )
{
Item *i_dict, *i_key, *i_value;
if( vm->self().isMethodic() )
{
i_dict = &vm->self();
i_key = vm->param(0);
i_value = vm->param(1);
}
else {
i_dict = vm->param(0);
i_key = vm->param(1);
i_value = vm->param(2);
}
if( i_dict == 0 || ! i_dict->isDict() || i_key == 0 || i_value == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( vm->self().isMethodic() ? "X,X" : "D,X,X" ) );
}
CoreDict *dict = i_dict->asDict();
Item *value = dict->find( *i_key );
if ( value == 0 )
{
vm->regA().setBoolean( false );
dict->put( *i_key, *i_value );
}
else {
vm->regA().setBoolean( true );
*value = *i_value;
}
}
示例2: mth_dictGet
/*#
@method get Dictionary
@brief Retreives a value associated with the given key
@param key The key to be found.
@return The value associated with a key, or an out-of-band nil if not found.
Return the value associated with the key, if present, or one of the
values if more than one key matching the given one is present. If
not present, the value returned will be nil. Notice that nil may be also
returned if the value associated with a given key is exactly nil. In
case the key cannot be found, the returned value will be marked as OOB.
@note This method bypassess getIndex__ override in blessed (POOP) dictionaries.
@see oob
*/
FALCON_FUNC mth_dictGet( ::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();
Item *value = dict->find( *i_key );
if ( value == 0 )
{
vm->retnil();
vm->regA().setOob();
}
else
vm->retval( *value );
}
示例3: internal_record_fetch
static void internal_record_fetch( VMachine* vm, DBIRecordset* dbr, Item& target )
{
int count = dbr->getColumnCount();
if( target.isArray() )
{
CoreArray* aret = target.asArray();
aret->resize( count );
for ( int i = 0; i < count; i++ )
{
dbr->getColumnValue( i, aret->items()[i] );
}
vm->retval( aret );
}
else if( target.isDict() )
{
CoreDict* dret = target.asDict();
for ( int i = 0; i < count; i++ )
{
String fieldName;
dbr->getColumnName( i, fieldName );
Item* value = dret->find( Item(&fieldName) );
if( value == 0 )
{
Item v;
dbr->getColumnValue( i, v );
CoreString* key = new CoreString(fieldName);
key->bufferize();
dret->put( key, v );
}
else
{
dbr->getColumnValue( i, *value );
}
}
vm->retval( dret );
}
/*
else
{
CoreTable* tbl = dyncast<CoreTable*>(target.asObject()->getFalconData());
ItemArray iaCols( count );
if( tbl->order() == CoreTable::noitem )
{
String* fieldName = new String[count];
for( int i = 0; i < count; ++ i )
{
dbr->getColumnName( i, fieldName[i] );
iaCols.append( fieldName );
}
if( ! tbl->setHeader( iaCols ) )
{
delete[] fieldName;
throw new DBIError( ErrorParam( FALCON_DBI_ERROR_FETCH, __LINE__ )
.extra("Incompatible table columns" ) );
}
delete[] fieldName;
}
else
{
if( tbl->order() != (unsigned) count )
{
throw new DBIError( ErrorParam( FALCON_DBI_ERROR_FETCH, __LINE__ )
.extra("Incompatible table columns" ) );
}
}
// put in the values
do {
CoreArray* row = new CoreArray();
row->resize( count );
for( int i = 0; i < count; ++ i )
{
dbr->getColumnValue( i, row->at( i ) );
}
tbl->insertRow( row );
}
while( dbr->fetchRow() );
vm->retval( target );
}
*/
}