Ejemplo n.º 1
0
static CScriptArrayInterface *QAS_SplitString( const asstring_t &str, const asstring_t &delim )
{
    asIScriptContext *ctx = asGetActiveContext();
    asIScriptEngine *engine = ctx->GetEngine();

    asIObjectType *ot = engine->GetObjectTypeById(engine->GetTypeIdByDecl("array<String @>"));

    CScriptArrayInterface *arr = QAS_NEW(CScriptArray)(0, ot);
    const char *pdelim = delim.buffer;
    const size_t delim_len = strlen( pdelim );

    const char *pbuf = str.buffer;
    const char *prev_pbuf = pbuf;

    // find all occurences of the delimiter in source string
    unsigned int count = 0;
    while( 1 ) {
        pbuf = strstr( prev_pbuf, pdelim );
        if( !pbuf ) {
            break;
        }

        arr->Resize( count + 1 );
        *((asstring_t **)arr->At(count)) = objectString_FactoryBuffer( prev_pbuf, pbuf - prev_pbuf );

        prev_pbuf = pbuf + delim_len;
        count++;
    }

    // append the remaining part
    arr->Resize( count + 1 );
    *((asstring_t **)arr->At(count)) = objectString_FactoryBuffer( prev_pbuf, strlen( prev_pbuf ) );

    return arr;
}
Ejemplo n.º 2
0
CScriptAnyInterface *qasCreateAnyCpp( asIScriptEngine *engine )
{
	return QAS_NEW(CScriptAny)( engine );
}
Ejemplo n.º 3
0
CScriptDictionaryInterface *qasCreateDictionaryCpp( asIScriptEngine *engine )
{
	return QAS_NEW(CScriptDictionary)( engine );
}
Ejemplo n.º 4
0
CScriptArrayInterface *qasCreateArrayCpp( unsigned int length, void *ot )
{
	return QAS_NEW(CScriptArray)( length, static_cast<asIObjectType *>( ot ) );
}
Ejemplo n.º 5
0
void *qasCreateAnyCpp( void *engine )
{
    return static_cast<void*>( QAS_NEW(CScriptAny)( static_cast<asIScriptEngine *>( engine ) ) );
}
Ejemplo n.º 6
0
void *qasCreateDictionaryCpp( void *engine )
{
    return static_cast<void*>( QAS_NEW(CScriptDictionary)( static_cast<asIScriptEngine *>( engine ) ) );
}