1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
///
/// \file SoapySDR/Types.h
///
/// Misc data type definitions used in the API.
///
/// \copyright
/// Copyright (c) 2014-2020 Josh Blum
/// SPDX-License-Identifier: BSL-1.0
///
#pragma once
#include <SoapySDR/Config.h>
#include <stddef.h> //size_t
#ifdef __cplusplus
extern "C" {
#endif
//! String definition for boolean true used in settings
#define SOAPY_SDR_TRUE "true"
//! String definition for boolean false used in settings
#define SOAPY_SDR_FALSE "false"
//! Definition for a min/max numeric range
typedef struct
{
double minimum;
double maximum;
double step;
} SoapySDRRange;
//! Definition for a key/value string map
typedef struct
{
size_t size;
char **keys;
char **vals;
} SoapySDRKwargs;
/*!
* Convert a markup string to a key-value map.
* The markup format is: "key0=value0, key1=value1"
*/
SOAPY_SDR_API SoapySDRKwargs SoapySDRKwargs_fromString(const char *markup);
/*!
* Convert a key-value map to a markup string.
* The markup format is: "key0=value0, key1=value1"
*/
SOAPY_SDR_API char *SoapySDRKwargs_toString(const SoapySDRKwargs *args);
//! Possible data types for argument info
typedef enum
{
SOAPY_SDR_ARG_INFO_BOOL,
SOAPY_SDR_ARG_INFO_INT,
SOAPY_SDR_ARG_INFO_FLOAT,
SOAPY_SDR_ARG_INFO_STRING
} SoapySDRArgInfoType;
//! Definition for argument info
typedef struct
{
//! The key used to identify the argument (required)
char *key;
/*!
* The default value of the argument when not specified (required)
* Numbers should use standard floating point and integer formats.
* Boolean values should be represented as "true" and "false".
*/
char *value;
//! The displayable name of the argument (optional, use key if empty)
char *name;
//! A brief description about the argument (optional)
char *description;
//! The units of the argument: dB, Hz, etc (optional)
char *units;
//! The data type of the argument (required)
SoapySDRArgInfoType type;
/*!
* The range of possible numeric values (optional)
* When specified, the argument should be restricted to this range.
* The range is only applicable to numeric argument types.
*/
SoapySDRRange range;
//! The size of the options set, or 0 when not used.
size_t numOptions;
/*!
* A discrete list of possible values (optional)
* When specified, the argument should be restricted to this options set.
*/
char **options;
/*!
* A discrete list of displayable names for the enumerated options (optional)
* When not specified, the option value itself can be used as a display name.
*/
char **optionNames;
} SoapySDRArgInfo;
/*!
* Free a pointer allocated by SoapySDR.
* For most platforms this is a simple call around free()
*/
SOAPY_SDR_API void SoapySDR_free(void *ptr);
/*!
* Clear the contents of a list of string
* Convenience call to deal with results that return a string list.
*/
SOAPY_SDR_API void SoapySDRStrings_clear(char ***elems, const size_t length);
/*!
* Set a key/value pair in a kwargs structure.
* \post
* If the key exists, the existing entry will be modified;
* otherwise a new entry will be appended to args.
* On error, the elements of args will not be modified,
* and args is guaranteed to be in a good state.
* \return 0 for success, otherwise allocation error
*/
SOAPY_SDR_API int SoapySDRKwargs_set(SoapySDRKwargs *args, const char *key, const char *val);
/*!
* Get a value given a key in a kwargs structure.
* \return the string or NULL if not found
*/
SOAPY_SDR_API const char *SoapySDRKwargs_get(const SoapySDRKwargs *args, const char *key);
/*!
* Clear the contents of a kwargs structure.
* This frees all the underlying memory and clears the members.
*/
SOAPY_SDR_API void SoapySDRKwargs_clear(SoapySDRKwargs *args);
/*!
* Clear a list of kwargs structures.
* This frees all the underlying memory and clears the members.
*/
SOAPY_SDR_API void SoapySDRKwargsList_clear(SoapySDRKwargs *args, const size_t length);
/*!
* Clear the contents of a argument info structure.
* This frees all the underlying memory and clears the members.
*/
SOAPY_SDR_API void SoapySDRArgInfo_clear(SoapySDRArgInfo *info);
/*!
* Clear a list of argument info structures.
* This frees all the underlying memory and clears the members.
*/
SOAPY_SDR_API void SoapySDRArgInfoList_clear(SoapySDRArgInfo *info, const size_t length);
#ifdef __cplusplus
}
#endif
|