AngelScript

dictionary object

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.

# Public C++ interface

class CScriptDictionary
{
public:
// Memory management
CScriptDictionary(asIScriptEngine *engine);
void AddRef() const;
void Release() const;
// Perform a shallow copy of the other dictionary
CScriptDictionary &operator=(const CScriptDictionary &other);
// Sets/Gets a variable type value for a key
void Set(const std::string &key, void *value, int typeId);
bool Get(const std::string &key, void *value, int typeId) const;
// Sets/Gets an integer number value for a key
void Set(const std::string &key, asINT64 &value);
bool Get(const std::string &key, asINT64 &value) const;
// Sets/Gets a real number value for a key
void Set(const std::string &key, double &value);
bool Get(const std::string &key, double &value) const;
// Returns the type id of the stored value, or negative if it doesn't exist
int GetTypeId(const std::string &key) const;
// Get an array of all keys
CScriptArray *GetKeys() const;
// Returns true if the key is set
bool Exists(const std::string &key) const;
// Returns true if the dictionary is empty
bool IsEmpty() const;
// Returns the number of keys in the dictionary
asUINT GetSize() const;
// Deletes the key
void Delete(const std::string &key);
// Deletes all keys
void DeleteAll();
// STL style iterator
class CIterator
{
public:
void operator++(); // Pre-increment
void operator++(int); // Post-increment
bool operator==(const CIterator &other) const;
bool operator!=(const CIterator &other) const;
// Accessors
const std::string &GetKey() const;
int GetTypeId() const;
bool GetValue(asINT64 &value) const;
bool GetValue(double &value) const;
bool GetValue(void *value, int typeId) const;
};
CIterator begin() const;
CIterator end() const;
};

# Public script interface

See Also
  Dictionaries in the script language