Validator.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // Validator.h
  3. //
  4. // Library: Util
  5. // Package: Options
  6. // Module: Validator
  7. //
  8. // Definition of the Validator class.
  9. //
  10. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Util_Validator_INCLUDED
  16. #define Util_Validator_INCLUDED
  17. #include "Poco/Util/Util.h"
  18. #include "Poco/RefCountedObject.h"
  19. namespace Poco {
  20. namespace Util {
  21. class Option;
  22. class Util_API Validator: public Poco::RefCountedObject
  23. /// Validator specifies the interface for option validators.
  24. ///
  25. /// Option validators provide a simple way for the automatic
  26. /// validation of command line argument values.
  27. {
  28. public:
  29. virtual void validate(const Option& option, const std::string& value) = 0;
  30. /// Validates the value for the given option.
  31. /// Does nothing if the value is valid.
  32. ///
  33. /// Throws an OptionException otherwise.
  34. protected:
  35. Validator();
  36. /// Creates the Validator.
  37. virtual ~Validator();
  38. /// Destroys the Validator.
  39. };
  40. } } // namespace Poco::Util
  41. #endif // Util_Validator_INCLUDED