|
AngelScript
|
Path: /sdk/add_on/scriptdictionary/
The dictionary object maps string values to values or objects of other types.
Register with RegisterScriptDictionary(asIScriptEngine*).
Compile the add-on with the pre-processor define AS_USE_STLNAMES=1 to register the methods with the same names as used by C++ STL where the methods have the same significance. Not all methods from STL is implemented in the add-on, but many of the most frequent once are so a port from script to C++ and vice versa might be easier if STL names are used.
class dictionary
{
dictionary &opAssign(const dictionary &in other); void set(const string &in key, ? &in value);
bool get(const string &in key, ? &out value) const; void set(const string &in key, int64 &in value);
bool get(const string &in key, int64 &out value) const; void set(const string &in key, double &in value);
bool get(const string &in key, double &out value) const;array<string> @getKeys() const;
bool exists(const string &in key) const;
void delete(const string &in key);
void deleteAll();
bool isEmpty() const;
uint getSize() const;
}
obj object;
obj @handle;
dictionary dict = ({'one', 1}, {'object', object}, {'handle', @handle}}; if( dict.exists('one') )
{
bool found = dict.get('handle', @handle);
if( found )
{
dict.delete('object');
}
} dict.set('newvalue', 42);dict.deleteAll();