ctkCmdLineModuleXmlValidator.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKCMDLINEMODULEXMLVALIDATOR_H
  16. #define CTKCMDLINEMODULEXMLVALIDATOR_H
  17. #include <ctkCommandLineModulesCoreExport.h>
  18. #include <QScopedPointer>
  19. class ctkCmdLineModuleXmlValidatorPrivate;
  20. class QIODevice;
  21. /**
  22. * @ingroup CommandLineModulesCore_API
  23. *
  24. * @brief Provides validation of an XML document against an XML schema.
  25. *
  26. */
  27. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleXmlValidator
  28. {
  29. public:
  30. ctkCmdLineModuleXmlValidator(QIODevice* input = 0);
  31. ~ctkCmdLineModuleXmlValidator();
  32. /**
  33. * @brief Set the XML input.
  34. * @param input The Xml input.
  35. */
  36. void setInput(QIODevice* input);
  37. /**
  38. * @brief Get the XML input device.
  39. * @return The XML input device.
  40. */
  41. QIODevice* input() const;
  42. /**
  43. * @brief Set the XML schema to be used during validation.
  44. * @param input The XML schema.
  45. */
  46. void setInputSchema(QIODevice* input);
  47. /**
  48. * @brief Validate the XML input against the XML schema set via setInputSchema().
  49. * @return \c true if validation was successful, \c false otherwise.
  50. */
  51. virtual bool validateInput();
  52. /**
  53. * @brief Get the error flag.
  54. * @return \c true if an error occured during validation, \c false otherwise.
  55. */
  56. virtual bool error() const;
  57. /**
  58. * @brief Get the error string.
  59. * @return A description of the validation error, if any.
  60. */
  61. virtual QString errorString() const;
  62. private:
  63. QScopedPointer<ctkCmdLineModuleXmlValidatorPrivate> d;
  64. };
  65. #endif // CTKCMDLINEMODULEXMLVALIDATOR_H