cmakepp_lang/utilities/global

Defines functions used to manipulate CMakePPLang global variables.

cmakepp_lang/utilities/global.cpp_append_global(key value)

Appends a value to a global list.

When we are manipulating a global state, which is actually a list, we often want to append to it and not “set” it (set in this context referring to overwriting the value with a new value). This function will append to the specified global variable the provided value. If the variable does not exist, the variable will be created and initialized to the provided value.

Parameters:
  • key (desc) – The name of the global variable to append to. key is case-insensitive.

  • value (str) – The value to append to key’s current value.

Error Checking

cpp_append_global will assert that it is called with only two arguments.

cmakepp_lang/utilities/global.cpp_set_global(key value)

Sets a global variable to the provided value.

This function will set a global variable to the value provided. If the global variable already exists it will overwrite its current value.

Parameters:
  • key (desc) – The name of the global variable to set. key is case-insensitive.

  • value (str) – The value to set key to.

Error Checking

cpp_set_global will assert that it is called with only two arguments.

cmakepp_lang/utilities/global.cpp_get_global(result key)

Retrieves the value of the requested global variable.

This function will get the value of the specified global variable. If the variable does not exist the empty string will be returned. It is thus not possible to discern between an uninitialized global variable and one set to the empty string. In practice this is not a problem because global variables are not typically set to the empty string.

Parameters:
  • result – Identifier for the variable which after this call will hold the value stored in global variable key.

  • key (desc) – The name of the global variable whose value has been requested. key is case-insensitive.

Returns:

result will be set to the value stored in global variable key. If key has not been set result will be set to the empty string.

Return type:

str

Error Checking

cpp_get_global will assert that it is called with only two arguments.