Functions used when accessing configuration file data from the QRMI C API.
◆ qrmi_config_free()
Frees the memory space pointed to by ptr, which must have been returned by a previous call to qrmi_config_load() or related functions. Otherwise, or if ptr has already been freed, segmentation fault occurs. If ptr is NULL, no operation is performed.
Safety
Example
QrmiConfig * qrmi_config_load(const char *filename)
QrmiReturnCode qrmi_config_free(QrmiConfig *ptr)
struct QrmiConfig QrmiConfig
Definition qrmi.h:222
- Parameters
-
| (ptr) | a pointer to Config to be free |
- Returns
- QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
- Version
- 0.6.0
◆ qrmi_config_load()
| QrmiConfig * qrmi_config_load |
( |
const char * | filename | ) |
|
Loads qrmi_config.json and returns it as Config.
Safety
- The memory pointed to by filename must contain a valid nul terminator.
- The nul terminator must be within isize::MAX from filename
Example
- Parameters
-
| (filename) | [in] qrmi_config.json file path |
- Returns
- A QrmiConfig if succeeded, otherwise NULL. Must call qrmi_config_free() to free if no longer used.
- Version
- 0.6.0
◆ qrmi_config_resource_def_free()
Frees the memory space pointed to by ptr, which must have been returned by a previous call to qrmi_config_get_resource_def() or related functions. Otherwise, or if ptr has already been freed, segmentation fault occurs. If ptr is NULL, no operation is performed.
Safety
Example
if (!cnf) {
if (res != NULL) {
printf(
"%s %d\n", res->
name, res->
type);
}
}
QrmiResourceDef * qrmi_config_resource_def_get(QrmiConfig *config, const char *resource_id)
QrmiReturnCode qrmi_config_resource_def_free(QrmiResourceDef *ptr)
QrmiResourceType type
Definition qrmi.h:291
char * name
Definition qrmi.h:287
- Parameters
-
| (ptr) | a pointer to ResourceDef to be free |
- Returns
- QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
- Version
- 0.6.0
◆ qrmi_config_resource_def_get()
Returns the resource definition for the specified resource.
Safety
- The memory pointed to by resource_id must contain a valid nul terminator.
- The nul terminator must be within isize::MAX from resource_id
Example
if (!cnf) {
if (res != NULL) {
printf(
"%s %d\n", res->
name, res->
type);
for (
int j = 0; j < envvars.
length; j++) {
printf(
"%s = %s\n", envvar.
key, envvar.
value);
}
}
}
QrmiKeyValue * variables
Definition qrmi.h:273
size_t length
Definition qrmi.h:277
char * value
Definition qrmi.h:263
char * key
Definition qrmi.h:259
QrmiEnvironmentVariables environments
Definition qrmi.h:299
- Parameters
-
| (config) | [in] a Config handle |
| (resource_id) | [in] resource identifier |
- Returns
- A QrmiResourceDef if succeeded, otherwise NULL. Must call qrmi_config_resource_def_free() to free if no longer used.
- Version
- 0.6.0
◆ qrmi_config_resource_names_get()
Returns a list of the resource names
Safety
- config must have been returned by a previous call to qrmi_config_load().
- The memory pointed to by outlen must have enough room to store size_t value.
- names must be non-null.
Example
size_t num_names = 0;
char **names = NULL;
for (int i = 0; i < num_names; i++) {
printf("[%s]\n", names[i]);
}
}
QrmiReturnCode qrmi_config_resource_names_get(QrmiConfig *config, size_t *num_names, char **names[])
QrmiReturnCode qrmi_string_array_free(size_t size, char *array[])
QrmiReturnCode
Definition qrmi.h:55
@ QRMI_RETURN_CODE_SUCCESS
Definition qrmi.h:59
- Parameters
-
| (config) | [in] A Config handle |
| (num_names) | [out] number of resource names in the list |
| (names) | [out] A list of the resource names if succeeded. Must call qrmi_string_array_free() to free if no longer used. |
- Returns
- QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
- Version
- 0.6.0
◆ qrmi_config_resource_type_from_str()
Parses the string representation used in qrmi_config.json and QRMI_JOB_QPU_TYPES, e.g. pasqal-local to QrmiResourceType::QRMI_RESOURCE_TYPE_PASQAL_LOCAL.
Safety
- The memory pointed to by type_str must contain a valid nul terminator.
- outp must be non-null.
Example
}
QrmiReturnCode qrmi_config_resource_type_from_str(const char *type_str, QrmiResourceType *outp)
QrmiQuantumResource * qrmi_resource_new(const char *resource_id, QrmiResourceType resource_type)
QrmiResourceType
Definition qrmi.h:125
struct QrmiQuantumResource QrmiQuantumResource
Definition qrmi.h:227
- Parameters
-
| (type_str) | [in] string representation of ResourceType |
| (outp) | [out] ResourceType variant if succeeded |
- Returns
- QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded, QrmiReturnCode::QRMI_RETURN_CODE_INVALID_INPUT_ERROR for an unknown string.
- Version
- 0.27.0
◆ qrmi_config_resource_type_to_str()
Converts ResourceType to string representation used in qrmi_config.json, e.g. QrmiResourceType::QRMI_RESOURCE_TYPE_IBM_QUANTUM_COMPUTE_SERVICE to ibm-quantum-compute-service.
Safety
Example
printf("%s\n", type_as_str);
const char * qrmi_config_resource_type_to_str(QrmiResourceType type)
QrmiReturnCode qrmi_string_free(char *ptr)
@ QRMI_RESOURCE_TYPE_IBM_QUANTUM_COMPUTE_SERVICE
Definition qrmi.h:137
- Parameters
-
- Returns
- string representation of ResourceType.
- Version
- 0.6.0