Data Structures
ai_map.h File Reference

Key/Value storage. More...

#include "ai_node_entry.h"
#include "ai_vector.h"
#include "ai_color.h"
#include "ai_api.h"
#include "ai_string.h"

Go to the source code of this file.

Data Structures

struct  AtParamValueMapEntry


AtParamValueMap Methods
AI_API AtParamValueMap * AiParamValueMap ()
 Creates a new map. More...
AI_API void AiParamValueMapDestroy (AtParamValueMap *map)
 Destroys a map object.
AI_API AtParamValueMapIterator * AiParamValueMapGetIterator (const AtParamValueMap *map)
 Creates a new map iterator and resets it to the first entry. More...
AI_API void AiParamValueMapMerge (AtParamValueMap *target_map, const AtParamValueMap *src_map)
 Merge all contents of a map into another map. More...
AI_API void AiParamValueMapIteratorDestroy (AtParamValueMapIterator *iter)
 Destroys a map iterator when it is no longer needed. More...
AI_API const AtParamValueMapEntryAiParamValueMapIteratorGetNext (AtParamValueMapIterator *iter)
 Returns current map entry and points map iterator to the next one. More...
AI_API bool AiParamValueMapIteratorFinished (const AtParamValueMapIterator *iter)
 Returns true if there is no more key/values to iterate over. More...
Value Writing

These functions allow inserting key/value pairs into a map.

Here is an example:

AiParamValueMapSetStr(map, AtString("author"), AtString("William Shakespeare"));
AiParamValueMapSetFlt(map, AtString("temperature"), 21.0f);
mapthe map to operate with
namethe key you want to insert
valuethe value you want to insert
AI_API void AiParamValueMapSetBool (AtParamValueMap *map, const AtString name, bool value)
AI_API void AiParamValueMapSetInt (AtParamValueMap *map, const AtString name, int value)
AI_API void AiParamValueMapSetFlt (AtParamValueMap *map, const AtString name, float value)
AI_API void AiParamValueMapSetRGB (AtParamValueMap *map, const AtString name, AtRGB value)
AI_API void AiParamValueMapSetVec (AtParamValueMap *map, const AtString name, AtVector value)
AI_API void AiParamValueMapSetVec2 (AtParamValueMap *map, const AtString name, AtVector2 value)
AI_API void AiParamValueMapSetStr (AtParamValueMap *map, const AtString name, AtString value)
Value Retrieval

These functions allow client code to retrieve values from a map

Following on the example above:

AtString author;
bool success = AiParamValueMapGetStr(map, AtString("author"), &author)
if (success)
printf("\nAuthor: %s", author.c_str());
mapthe map to read from
namethe key attached to the value you want to get
[out]valueif the read succeeds, the variable pointed to by value will be overwritten with the value
true when the lookup is succesful
AI_API bool AiParamValueMapGetBool (const AtParamValueMap *map, const AtString name, bool *value)
AI_API bool AiParamValueMapGetInt (const AtParamValueMap *map, const AtString name, int *value)
AI_API bool AiParamValueMapGetFlt (const AtParamValueMap *map, const AtString name, float *value)
AI_API bool AiParamValueMapGetRGB (const AtParamValueMap *map, const AtString name, AtRGB *value)
AI_API bool AiParamValueMapGetVec (const AtParamValueMap *map, const AtString name, AtVector *value)
AI_API bool AiParamValueMapGetVec2 (const AtParamValueMap *map, const AtString name, AtVector2 *value)
AI_API bool AiParamValueMapGetStr (const AtParamValueMap *map, const AtString name, AtString *value)

Detailed Description

Key/Value storage.

Function Documentation

AI_API AtParamValueMap* AiParamValueMap ( )

Creates a new map.

new map object
AI_API AtParamValueMapIterator* AiParamValueMapGetIterator ( const AtParamValueMap *  mds)

Creates a new map iterator and resets it to the first entry.

an iterator over all key/values in a map
AI_API void AiParamValueMapMerge ( AtParamValueMap *  target_map,
const AtParamValueMap *  src_map 

Merge all contents of a map into another map.

After merge, target map will contain all its previous attributes plus all the attributes in the source map

target_maptarget map where the other map contents will be merged
src_mapmap which contents will be merged to the target map
AI_API void AiParamValueMapIteratorDestroy ( AtParamValueMapIterator *  iter)

Destroys a map iterator when it is no longer needed.

itermap iterator that will be deallocated
AI_API const AtParamValueMapEntry* AiParamValueMapIteratorGetNext ( AtParamValueMapIterator *  iter)

Returns current map entry and points map iterator to the next one.

This function is designed to be used inside a loop, as illustrated by the following example, which prints all the keys of a given AtNodeEntry:

1 AtParamValueMapIterator *iter = AiParamValueMap();
2 while (!AiParamValueMapIteratorFinished(iter))
3 {
4  const AtParamValueMapEntry *entry = AiParamValueMapIteratorGetNext(iter);
5  printf("%s\n", entry->name);
6 }
7 AiParamValueMapIteratorDestroy(iter);

Consistent Ordering is not guaranteed

itera map iterator
the current metadata entry pointed by the iterator, or NULL if there is no more metadata to iterate over
AI_API bool AiParamValueMapIteratorFinished ( const AtParamValueMapIterator *  iter)

Returns true if there is no more key/values to iterate over.

itera map iterator
true if the map iterator has moved past the last entry

© 2020 Autodesk, Inc. · All rights reserved ·