Maps are very versatile and are missing dearly from CMake in my opinion. Maps are references as is standard in many languages. They are signified by having properties which are adressed by keys and can take any value.
Due to the "variable variable" system (ie names of variables are string which can be generated from other variables) it is very easy to implement the map system. Under the hood a value is mapped by calling address_set(${map}.${key})
.
- is_map
- map_append
- map_append_string
- map_append_unique
- map_delete
- map_duplicate
- map_get
- map_get_special
- map_has
- map_keys
- map_new
- map_remove
- map_remove_item
- map_set
- map_set_hidden
- map_set_special
- map_tryget
- dfs
- dfs_callback
- list_match
- map_all_paths
- map_at
- map_capture
- map_capture_new
- map_clear
- map_copy_shallow
- map_count
- map_defaults
- map_ensure
- map_extract
- map_fill
- map_flatten
- map_from_keyvaluelist
- map_get_default
- map_get_map
- map_has_all
- map_has_any
- map_invert
- map_isempty
- map_keys_append
- map_keys_clear
- map_keys_remove
- map_keys_set
- map_keys_sort
- map_key_at
- map_match
- map_matches
- map_match_properties
- map_omit
- map_omit_regex
- map_overwrite
- map_pairs
- test
- map_path_get
- map_path_set
- map_peek_back
- map_peek_front
- map_pick
- map_pick_regex
- map_pop_back
- map_pop_front
- map_promote
- map_property_length
- map_push_back
- map_push_front
- map_rename
- map_set_default
- map_to_keyvaluelist
- map_to_valuelist
- map_unpack
- map_values
- mm
- map_iterator
- map_iterator_break
- map_iterator_next
- map_import_properties
- map_match_obj
- map_clone
- map_clone_deep
- map_clone_shallow
- map_equal
- map_equal_obj
- map_foreach
- map_issubsetof
- map_merge
- map_union
appends a value to the end of a map entry
returns all keys for the specified map
set a value in the map
tries to get the value map[key] and returns NOTFOUND if it is not found
iterates a the graph with root nodes in ${ARGN} in depth first order expand must consider cycles
emits events parsing a list of map type elements expects a callback function that takes the event type string as a first argument follwowing events are called (available context variables are listed as subelements: value
- list_length (may be 0 or 1 which is good for a null check)
- content_length (contains the length of the content)
- node (contains the value) list_begin
- list_length (number of elements the list contains)
- content_length (accumulated length of list elements + semicolon separators)
- node (contains all values of the lsit) list_end
- list_length(number of elements in list)
- node (whole list)
- list_char_length (length of list content)
- content_length (accumulated length of list elements + semicolon separators) list_element_begin
- list_length(number of elements in list)
- node (whole list)
- list_char_length (length of list content)
- content_length (accumulated length of list elements + semicolon separators)
- list_element (contains current list element)
- list_element_index (contains current index )
list_element_end - list_length(number of elements in list)
- node (whole list)
- list_char_length (length of list content)
- content_length (accumulated length of list elements + semicolon separators)
- list_element (contains current list element)
- list_element_index (contains current index ) visited_reference
- node (contains ref to revisited map) unvisited_reference
- node (contains ref to unvisited map) map_begin
- node( contains ref to map)
- map_keys (contains all keys of map)
- map_length (contains number of keys of map) map_end
- node( contains ref to map)
- map_keys (contains all keys of map)
- map_length (contains number of keys of map) map_element_begin
- node( contains ref to map)
- map_keys (contains all keys of map)
- map_length (contains number of keys of map)
- map_element_key (current key)
- map_element_value (current value)
- map_element_index (current index) map_element_end
- node( contains ref to map)
- map_keys (contains all keys of map)
- map_length (contains number of keys of map)
- map_element_key (current key)
- map_element_value (current value)
- map_element_index (current index)
matches the object list
returns all possible paths for the map (currently crashing on cycles cycles) todo: implement
removes all properties from map
copies the values of the source map into the target map by assignment (shallow copy)
sets all undefined properties of map to the default value
ensures that the specified vars are a map parsing structured data if necessary
adds the keyvalues list to the map (if not map specified created one)
returns true if map has all keys specified as varargs
returns true if map has any of the keys specified as varargs
returns a copy of map with key values inverted only works correctly for bijective maps
returns a function which returns true of all
returns true if map's properties match all properties of attrs
returns a copy of map without the specified keys (argn)
returns a map with all properties except those matched by any of the specified regexes
returns a list key;value;key;value;... only works if key and value are not lists (ie do not contain ;)
returns the value at the specified path (path is specified as path fragment list) e.g. map = {a:{b:{c:{d:{e:3}}}}} map_path_get(${map} a b c d e) returns 3 this function is somewhat faster than map_navigate()
todo implement
returns a copy of map returning only the whitelisted keys
returns a map containing all properties whose keys were matched by any of the specified regexes
converts a map to a key value list
returns all values of the map which are passed as ARNG
use this macro inside of a while(true) loop it breaks when the iterator is over e.g. this prints all key values in the map while(true) map_iterator_break(myiterator) message("${myiterator.key} = ${myiterator.value}") endwhile()
compares two maps and returns true if they are equal order of list values is important order of map keys is not important cycles are respected.
executes action (key, value)->void on every key value pair in map exmpl: map = {id:'1',val:'3'} map_foreach("${map}" "(k,v)-> message($k $v)") prints id;1 val;3
creates a union from all all maps passed as ARGN and combines them in result you can merge two maps by typing map_union(${map1} ${map1} ${map2}) maps are merged in order ( the last one takes precedence)
creates a union from all all maps passed as ARGN and combines them in the first you can merge two maps by typing map_union(${map1} ${map1} ${map2}) maps are merged in order ( the last one takes precedence)