MCPcopy Create free account
hub / github.com/anjo76/angelscript / At

Method At

sdk/add_on/scriptarray/scriptarray.cpp:952–967  ·  view source on GitHub ↗

Return a pointer to the array element. Returns 0 if the index is out of bounds

Source from the content-addressed store, hash-verified

950
951// Return a pointer to the array element. Returns 0 if the index is out of bounds
952const void *CScriptArray::At(asUINT index) const
953{
954 if( buffer == 0 || index >= buffer->numElements )
955 {
956 // If this is called from a script we raise a script exception
957 asIScriptContext *ctx = asGetActiveContext();
958 if( ctx )
959 ctx->SetException("Index out of bounds");
960 return 0;
961 }
962
963 if( (subTypeId & asTYPEID_MASK_OBJECT) && !(subTypeId & asTYPEID_OBJHANDLE) )
964 return *(void**)(buffer->data + elementSize*index);
965 else
966 return buffer->data + elementSize*index;
967}
968void *CScriptArray::At(asUINT index)
969{
970 return const_cast<void*>(const_cast<const CScriptArray *>(this)->At(index));

Callers 3

InsertAtMethod · 0.45
operator==Method · 0.45
ScriptArrayAt_GenericFunction · 0.45

Calls 1

SetExceptionMethod · 0.80

Tested by

no test coverage detected