Leaked source code of windows server 2003
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.

137 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. TstINIConfig.hxx
  5. Abstract:
  6. Class that manages the reading of the test scenario INI file. Each instance
  7. of the CVsTstINIConfig class refers to one INI section with the file. Which
  8. section is determined by the parameters passed to the constructor.
  9. Author:
  10. Stefan R. Steiner [ssteiner] 05-16-2000
  11. Revision History:
  12. --*/
  13. #ifndef __H_TSTINICONFIG_
  14. #define __H_TSTINICONFIG_
  15. #include "bsstring.hxx"
  16. //
  17. // Type of harness component.
  18. //
  19. enum EVsTstINISectionType
  20. {
  21. eVsTstSectionType_UNKNOWN,
  22. eVsTstSectionType_TestCoordinator, // The harness coordinator
  23. eVsTstSectionType_TestRequesterApp, // The requester app (backup)
  24. eVsTstSectionType_TestWriter, // The test writer
  25. eVsTstSectionType_TestProvider, // The test provider
  26. eVsTstSectionType_SENTINEL
  27. };
  28. //
  29. // Boolean values. Note that it has a third value and that is
  30. // random. Most test boolean options can have a random
  31. // value.
  32. //
  33. enum EVsTstINIBoolType
  34. {
  35. eVsTstBool_False = 0,
  36. eVsTstBool_True = 1,
  37. eVsTstBool_Random = 2
  38. };
  39. enum EVsTstINIOptionType
  40. {
  41. eVsTstOptType_Unknown = 0, // For internal use only
  42. eVsTstOptType_Comment = 1, // For internal use only
  43. eVsTstOptType_Boolean = 2,
  44. eVsTstOptType_String = 3,
  45. eVsTstOptType_Number = 4
  46. };
  47. class CVsTstINIConfig
  48. {
  49. public:
  50. //
  51. // Initializes the object
  52. //
  53. CVsTstINIConfig(
  54. IN EVsTstINISectionType eSectionType,
  55. IN LPCWSTR pwszSectionQualifier = L"DEFAULT", // The XXX in [SectionType.XXX]
  56. IN BOOL bWriteINIFile = TRUE, // If true, a default INI file will be written
  57. // if the file doesn't exist.
  58. IN LPCWSTR pwszINIFileName = NULL, // Full path to the INI file, if NULL, default
  59. // path is used.
  60. IN BOOL bContinueOnINIFileErrors = FALSE // If true, errors in INI file are skipped
  61. );
  62. virtual ~CVsTstINIConfig();
  63. // Get the option type
  64. EVsTstINIOptionType GetOptionType(
  65. IN LPCWSTR pwszOptionName
  66. );
  67. // Gets a string value
  68. VOID GetOptionValue(
  69. IN LPCWSTR pwszOptionName,
  70. OUT CBsString *pwsOptionValue,
  71. OUT BOOL *pbOverridden = NULL
  72. );
  73. // Gets a boolean value
  74. VOID GetOptionValue(
  75. IN LPCWSTR pwszOptionName,
  76. OUT EVsTstINIBoolType *peOptionValue,
  77. OUT BOOL *pbOverridden = NULL
  78. );
  79. // Get a number value
  80. VOID GetOptionValue(
  81. IN LPCWSTR pwszOptionName,
  82. OUT LONGLONG *pllOptionMinValue,
  83. OUT LONGLONG *pllOptionMaxValue,
  84. OUT BOOL *pbOverridden = NULL
  85. );
  86. private:
  87. CVsTstINIConfig() {}; // No default constructor, no copying allowed
  88. HRESULT LoadINIFileData();
  89. HRESULT CreateDefaultINIFile();
  90. HRESULT SetupDefaultValues();
  91. EVsTstINISectionType m_eSectionType;
  92. CBsString m_wsSectionName;
  93. CBsString m_wsINIFileName;
  94. BOOL m_bWriteINIFile;
  95. LPVOID m_pvOptionsList;
  96. BOOL m_bContinueOnINIFileErrors;
  97. };
  98. //
  99. // Class which is thrown when an error is found in the INI file
  100. //
  101. class CVsTstINIConfigException
  102. {
  103. friend CVsTstINIConfig;
  104. public:
  105. CBsString& GetExceptionString() { return m_cwsExceptionString; }
  106. private:
  107. CBsString m_cwsExceptionString;
  108. };
  109. #endif // __H_TSTINICONFIG_