🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.2 KiB

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