当前位置: 首页>>代码示例>>C++>>正文


C++ CoreObject类代码示例

本文整理汇总了C++中CoreObject的典型用法代码示例。如果您正苦于以下问题:C++ CoreObject类的具体用法?C++ CoreObject怎么用?C++ CoreObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CoreObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Handle_aquery

void Handle_aquery( VMachine *vm )
{
   Item* i_sql = vm->param(0);
   Item* i_params = vm->param(1);
   if ( i_sql == 0 || ! i_sql->isString()
      || i_params == 0 || ! i_params->isArray() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "S,A" ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbt = static_cast<DBIHandle *>( self->getUserData() );

   DBIRecordset* res = 0;
   res = dbt->query( *i_sql->asString(), &i_params->asArray()->items() );

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );
      vm->retval( rset );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:28,代码来源:dbi_ext.cpp

示例2: Handle_expand

void Handle_expand( VMachine *vm )
{
   Item* i_sql = vm->param(0);

   if ( i_sql == 0 || ! i_sql->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "S, ..." ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbt = static_cast<DBIHandle *>( self->getUserData() );


   DBIRecordset* res = 0;
   int32 pCount = vm->paramCount();
   CoreString* target = new CoreString;
   
   ItemArray params( pCount - 1 );      
   for( int32 i = 1; i < vm->paramCount(); i++)
   {
      params.append( *vm->param(i) );
   }
      
   // May throw
   dbt->sqlExpand( *i_sql->asString(), *target, params );
   vm->retval( target );
}
开发者ID:Klaim,项目名称:falcon,代码行数:28,代码来源:dbi_ext.cpp

示例3: value

/*#
   @method getOne ConfParser
   @brief Retreives the value associated with a key.
   @param key The key of which the value is to be read.
   @optparam section If provided, the section where the key is found.
   @return The value (or values) of associated to the key, or nil if not found.

   This method is equivalent to the @a ConfParser.get method, except for the fact that if more
   than one value has been given for the determined key in the configuration file,
   only the last one among them is returned.
*/
FALCON_FUNC  ConfParser_getOne( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_key = vm->param(0);
   Item *i_section = vm->param(1);

   if ( i_key == 0 || ! i_key->isString() ||
        ( i_section != 0 && ! i_section->isString() && ! i_section->isNil() )
      )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
   }

   String value;

   if ( i_section != 0 && ! i_section->isNil() )
   {
      if ( ! cfile->getValue( *i_section->asString(), *i_key->asString(), value ) )
      {
         vm->retnil();
         return;
      }
   }
   else {
      if ( ! cfile->getValue( *i_key->asString(), value ) )
      {
         vm->retnil();
         return;
      }
   }

   vm->retval( value );
}
开发者ID:Klaim,项目名称:falcon,代码行数:45,代码来源:confparser_ext.cpp

示例4: parse

/*#
   @method format Format
   @brief Performs desired formatting on a target item.
   @param item The item to be formatted
   @optparam dest A string where to store the formatted data.
   @return A formatted string
   @raise ParamError if a format specifier has not been set yet.
   @raise TypeError if the format specifier can't be applied the item because of
         incompatible type.

   Formats the variable as per the given format descriptor. If the class has been
   instantiated without format, and the parse() method has not been called yet,
   a ParamError is raised. If the type of the variable is incompatible with the
   format descriptor, the method returns nil; a particular format specifier allows
   to throw a TypeError in this case.

   On success, the method returns a string containing a valid formatted representation
   of the variable.

   It is possible to provide a pre-allocated string where to store the formatted
   result to improve performace and spare memory.
*/
FALCON_FUNC  Format_format ( ::Falcon::VMachine *vm )
{
   CoreObject *einst = vm->self().asObject();
   Format *fmt = dyncast<Format*>( einst->getFalconData() );

   Item *param = vm->param( 0 );
   Item *dest = vm->param( 1 );
   if( param == 0 || ( dest != 0 && ! dest->isString() ) )
   {
      throw new ParamError( ErrorParam( e_inv_params ).extra( "X,[S]" ) );
   }
   else
   {
      CoreString *tgt;

      if( dest != 0 )
      {
         tgt = dest->asCoreString();
      }
      else {
         tgt = new CoreString;
      }

      if( ! fmt->format( vm, *param, *tgt ) )
         vm->retnil();
      else
         vm->retval( tgt );
   }
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:51,代码来源:format_ext.cpp

示例5: Statement_aexec

void Statement_aexec( VMachine *vm )
{
   Item* i_params = vm->param(0);
   if( i_params == 0 || ! i_params->isArray() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                               .extra( "A" ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIStatement *dbt = static_cast<DBIStatement *>( self->getUserData() );

   DBIRecordset* res;
   res = dbt->execute( &i_params->asArray()->items() );

   if( res != 0 )
   {
      Item* rset_item = vm->findWKI( "%Recordset" );
      fassert( rset_item != 0 );
      fassert( rset_item->isClass() );

      CoreObject* rset = rset_item->asClass()->createInstance();
      rset->setUserData( res );

      vm->retval( rset );
   }
   else
   {
      vm->retnil();
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:31,代码来源:dbi_ext.cpp

示例6: query

/*#
   @method lselect Handle
   @brief Returns a "select" query configured to access a sub-recordset.
   @param sql The query (excluded the "select" command).
   @optparam begin The first row to be returned (0 based).
   @optparam count The number of rows to be returned.
   @return A fully configured sql command that can be fed into @a Handle.query

   This method should create a "select" query adding the commands and/or the
    parameters needed by the engine to limit the resultset to a specified part
    part of the dataset.

    The query parameter must be a complete query EXCEPT for the "select" command,
    which is added by the engine. It must NOT terminate with a ";", which, in case
    of need is added by the engine.

    For example, to limit the following query to rows 5-14 (row 5 is the 6th row):
    @code
       SELECT field1, field2 FROM mytable WHERE key = ?;
    @endcode

    write this Falcon code:
    @code
       // dbh is a DBI handle
       rset = dbh.query(
                   dbh.lselect( "field1, field2 FROM mytable WHERE key = ?", 5, 10 ),
                   "Key value" )
    @endcode

    The @b count parameter can be 0 or @b nil to indicate "from @b begin to the end".
    It's not possible to return the n-last elements; to do that, reverse the
    query ordering logic.

    @note If the engine doesn't support limited recordsets, the limit parameters are
    ignored.
*/
void Handle_lselect( VMachine *vm )
{
   Item* i_sql = vm->param(0);
   Item* i_nBegin = vm->param(1);
   Item* i_nCount = vm->param(2);

   if( i_sql == 0 || ! i_sql->isString()
      || ( i_nBegin != 0 && ! (i_nBegin->isOrdinal() || i_nBegin->isNil() ) )
      || ( i_nCount != 0 && ! i_nCount->isOrdinal() )
         )
   {
      throw new ParamError(ErrorParam( e_inv_params, __LINE__ )
           .extra( "S,[N],[N]") );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbh = static_cast<DBIHandle *>( self->getUserData() );

   CoreString* result = new CoreString;
   dbh->selectLimited( *i_sql->asString(),
         i_nBegin == 0 ? 0 : i_nBegin->forceInteger(),
         i_nCount == 0 ? 0 : i_nCount->forceInteger(), *result );

   vm->retval( result );
}
开发者ID:Klaim,项目名称:falcon,代码行数:61,代码来源:dbi_ext.cpp

示例7: ConfParser_getCategoryKeys

/*#
   @method getCategoryKeys ConfParser
   @brief Get the keys filed under a given category.
   @param category The category of which the key list is required
   @optparam section If provided, the section where the category is defined.
   @return All the keys listed in the given category.

   This method returns a list of all the keys belonging to a certain category.

   See the "Categorized keys" section in @a ConfParser.
*/
FALCON_FUNC  ConfParser_getCategoryKeys( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_keyMask = vm->param( 0 );
   Item *i_section = vm->param( 1 );

   if ( i_keyMask == 0 || ! i_keyMask->isString() ||
        ( i_section != 0 && ! i_section->isString() && ! i_section->isNil() )
      )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
      return;
   }

   String key;
   CoreArray *ret = new CoreArray;
   bool next;

   if ( i_section != 0 && ! i_section->isNil() ) {
      next = cfile->getFirstKey( *i_section->asString(), *i_keyMask->asString(), key );
   }
   else {
      next = cfile->getFirstKey( *i_keyMask->asString(), key );
   }

   while ( next )
   {
      ret->append( new CoreString( String( key, i_keyMask->asString()->length() + 1 ) ) );
      next = cfile->getNextKey( key );
   }

   vm->retval( ret );
}
开发者ID:Klaim,项目名称:falcon,代码行数:45,代码来源:confparser_ext.cpp

示例8: Handle_result

void Handle_result( VMachine *vm )
{
   Item* i_sql = vm->param(0);

   if ( i_sql == 0 || ! i_sql->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "S, ..." ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIHandle *dbt = static_cast<DBIHandle *>( self->getUserData() );

   int32 pCount = vm->paramCount();
   Item result;
   if( pCount > 1 )
   {
      ItemArray params( pCount - 1 );
      for( int32 i = 1; i < vm->paramCount(); i++)
      {
         params.append( *vm->param(i) );
      }

      // Query may throw.
      dbt->result( *i_sql->asString(), result, &params );
   }
   else
   {
	  dbt->result( *i_sql->asString(), result );
   }

   vm->retval(result);
}
开发者ID:Klaim,项目名称:falcon,代码行数:33,代码来源:dbi_ext.cpp

示例9: GetObjectByHandle

//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void CoreObjectManager::DeleteObjectByHandle(CoreObjectHandle handle)
{
	CoreObject* pObject = GetObjectByHandle(handle);
	if(pObject != NULL)
	{
		pObject->DeleteObject();
	}
}
开发者ID:MegaJiXiang,项目名称:CoreEngine3D,代码行数:10,代码来源:CoreObject_Manager.cpp

示例10: DBIError_init

void DBIError_init( VMachine *vm )
{
   CoreObject *einst = vm->self().asObject();
   if( einst->getUserData() == 0 )
      einst->setUserData( new DBIError );

   ::Falcon::core::Error_init( vm );
}
开发者ID:Klaim,项目名称:falcon,代码行数:8,代码来源:dbi_ext.cpp

示例11: internal_stmt_open

static void internal_stmt_open( VMachine* vm, DBIStatement* trans )
{
   Item *trclass = vm->findWKI( "%Statement" );
   fassert( trclass != 0 && trclass->isClass() );

   CoreObject *oth = trclass->asClass()->createInstance();
   oth->setUserData( trans );
   vm->retval( oth );
}
开发者ID:Klaim,项目名称:falcon,代码行数:9,代码来源:dbi_ext.cpp

示例12: Dictionary_last

FALCON_FUNC Dictionary_last( VMachine *vm )
{
   Item *itclass = vm->findWKI( "Iterator" );
   fassert( itclass != 0 );

   CoreObject *iterator = itclass->asClass()->createInstance();
   // we need to set the FalconData flag
   iterator->setUserData( new Iterator( &vm->self().asDict()->items(), true  ) );
   vm->retval( iterator );
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:10,代码来源:dict_ext.cpp

示例13: ConfParser_getDictionary

/*#
   @method getDictionary ConfParser
   @brief Retreives keys and values given under a certain category.
   @optparam section If given, the section from which to extract the dictionary.
   @return A dictionary containing a pair of key-values in the given section.

   This method retrieves all the pairs of key and values in the main section, or if
   a non-nil section parameter is provided, from the given section. If the
   requested section cannot be found, or if it doesn't contain any entry, an empty
   dictionary is returned. If a key has multiple values, its element is set to an
   array containing all the values.
*/
FALCON_FUNC  ConfParser_getDictionary( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_section = vm->param( 0 );

   if ( i_section != 0 && ! i_section->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
   }

   String key;
   LinearDict *ret = new LinearDict();
   LinearDict *current = ret;
   bool next;

   if ( i_section != 0 ) {
      next = cfile->getFirstKey( *i_section->asString(), "", key );
   }
   else {
      next = cfile->getFirstKey( "", key );
   }

   while( next )
   {
      String value;

      // seeking a value won't alter key iterators.
      if( i_section != 0 )
         cfile->getValue( *i_section->asString(), key, value );
      else
         cfile->getValue( key, value );

      // we have at least one value. but do we have more?
      String value1;
      if ( cfile->getNextValue( value1 ) )
      {
         CoreArray *array = new CoreArray( 5 );
         array->append( new CoreString( value ) );
         array->append( new CoreString( value1 ) );

         while( cfile->getNextValue( value1 ) )
            array->append( new CoreString( value1 ) );

         current->put( new CoreString( key ), array );
      }
      else {
         current->put( new CoreString( key ), new CoreString( value ) );
      }

      next = cfile->getNextKey( key );
   }

   vm->retval( new CoreDict(ret) );
}
开发者ID:Klaim,项目名称:falcon,代码行数:67,代码来源:confparser_ext.cpp

示例14: Recordset_discard

void Recordset_discard( VMachine *vm )
{
   Item *i_count = vm->param( 0 );
   if ( i_count == 0 || ! i_count->isOrdinal() ) {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
                                        .extra( "N" ) );
   }

   CoreObject *self = vm->self().asObject();
   DBIRecordset *dbr = static_cast<DBIRecordset *>( self->getUserData() );
   vm->regA().setBoolean( dbr->discard( i_count->forceInteger() ) );
}
开发者ID:Klaim,项目名称:falcon,代码行数:12,代码来源:dbi_ext.cpp

示例15: ConfParser_removeSection

FALCON_FUNC  ConfParser_removeSection( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_section = vm->param(0);

   if ( i_section == 0 ||  ! i_section->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "S" ) );
   }

   vm->retval( (int64) ( cfile->removeSection( *i_section->asString() ) ? 1: 0) );
}
开发者ID:Klaim,项目名称:falcon,代码行数:13,代码来源:confparser_ext.cpp


注:本文中的CoreObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。