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