本文整理汇总了C++中CoreDict::put方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreDict::put方法的具体用法?C++ CoreDict::put怎么用?C++ CoreDict::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreDict
的用法示例。
在下文中一共展示了CoreDict::put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: URI_getFields
/*# @method getFields URI
@brief Returns fields contained in the query element into a dictionary.
@return The fields as a dictionary of nil if the query part contains no element.
@raise ParamError if the string is not a valid URI/URL encoded string.
*/
FALCON_FUNC URI_getFields ( ::Falcon::VMachine *vm )
{
UriObject *self = dyncast<UriObject*>( vm->self().asObject() );
URI &uri = self->uri();
if ( uri.query().size() == 0 )
{
vm->retnil();
return;
}
if( uri.fieldCount() == 0 )
{
// we have a query but no fields; this means we still have to parse it.
if ( ! uri.parseQuery( true ) )
{
// todo: better signalation
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).
origin( e_orig_runtime ).extra( vm->moduleString( rtl_invalid_uri ) ) );
return;
}
// really nothing to parse?
if ( uri.fieldCount() == 0 )
{
vm->retnil();
return;
}
}
// ok, build our dictionary
uint32 count = uri.fieldCount();
CoreDict *dict = new CoreDict( new LinearDict( count ) );
CoreString *key = new CoreString;
CoreString *value = new CoreString;
uri.firstField( *key, *value );
count--;
dict->put( key, value );
while( count > 0 )
{
key = new CoreString;
value = new CoreString;
uri.nextField( *key, *value );
count --;
dict->put( key, value );
}
vm->retval( dict );
}
示例2: 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;
}
}
示例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 );
}
*/
}