cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_visualtest_sut_configparser.h (3243B)


      1/* See COPYING.txt for the full license governing this code. */
      2/**
      3 * \file SDL_visualtest_sut_configparser.h
      4 *
      5 * Header for the parser for SUT config files.
      6 */
      7
      8#ifndef _SDL_visualtest_sut_configparser_h
      9#define _SDL_visualtest_sut_configparser_h
     10
     11/** Maximum length of the name of an SUT option */
     12#define MAX_SUTOPTION_NAME_LEN 100
     13/** Maximum length of the name of a category of an SUT option */
     14#define MAX_SUTOPTION_CATEGORY_LEN 40
     15/** Maximum length of one enum value of an SUT option */
     16#define MAX_SUTOPTION_ENUMVAL_LEN 40
     17/** Maximum length of a line in the paramters file */
     18#define MAX_SUTOPTION_LINE_LENGTH 256
     19
     20/* Set up for C function definitions, even when using C++ */
     21#ifdef __cplusplus
     22extern "C" {
     23#endif
     24
     25/**
     26 * Describes the different kinds of options to the SUT.
     27 */
     28typedef enum {
     29    SDL_SUT_OPTIONTYPE_STRING = 0,
     30    SDL_SUT_OPTIONTYPE_INT,
     31    SDL_SUT_OPTIONTYPE_ENUM,
     32    SDL_SUT_OPTIONTYPE_BOOL
     33} SDLVisualTest_SUTOptionType;
     34
     35/**
     36 * Represents the range of values an integer option can take.
     37 */
     38typedef struct SDLVisualTest_SUTIntRange {
     39    /*! Minimum value of the integer option */
     40    int min;
     41    /*! Maximum value of the integer option */
     42    int max;
     43} SDLVisualTest_SUTIntRange;
     44
     45/**
     46 * Struct that defines an option to be passed to the SUT.
     47 */
     48typedef struct SDLVisualTest_SUTOption {
     49    /*! The name of the option. This is what you would pass in the command line
     50        along with two leading hyphens. */
     51    char name[MAX_SUTOPTION_NAME_LEN];
     52    /*! An array of categories that the option belongs to. The last element is
     53        NULL. */
     54    char** categories;
     55    /*! Type of the option - integer, boolean, etc. */
     56    SDLVisualTest_SUTOptionType type;
     57    /*! Whether the option is required or not */
     58    SDL_bool required;
     59    /*! extra data that is required for certain types */
     60    union {
     61        /*! This field is valid only for integer type options; it defines the
     62        valid range for such an option */
     63        SDLVisualTest_SUTIntRange range;
     64        /*! This field is valid only for enum type options; it holds the list of values
     65        that the option can take. The last element is NULL */
     66        char** enum_values;
     67    } data;
     68} SDLVisualTest_SUTOption;
     69
     70/**
     71 * Struct to hold all the options to an SUT application.
     72 */
     73typedef struct SDLVisualTest_SUTConfig
     74{
     75    /*! Pointer to an array of options */
     76    SDLVisualTest_SUTOption* options;
     77    /*! Number of options in \c options */
     78    int num_options;
     79} SDLVisualTest_SUTConfig;
     80
     81/**
     82 * Parses a configuration file that describes the command line options an SUT
     83 * application will take and populates a SUT config object. All lines in the
     84 * config file must be smaller than 
     85 *
     86 * \param file Path to the configuration file.
     87 * \param config Pointer to an object that represents an SUT configuration.
     88 *
     89 * \return zero on failure, non-zero on success
     90 */
     91int SDLVisualTest_ParseSUTConfig(char* file, SDLVisualTest_SUTConfig* config);
     92
     93/**
     94 * Free any resources associated with the config object pointed to by \c config.
     95 */
     96void SDLVisualTest_FreeSUTConfig(SDLVisualTest_SUTConfig* config);
     97
     98/* Ends C function definitions when using C++ */
     99#ifdef __cplusplus
    100}
    101#endif
    102
    103#endif /* _SDL_visualtest_sut_configparser_h */