您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

69 行
1.8 KiB

  1. /******************************************************************************
  2. *
  3. * file: Constraint.h
  4. *
  5. * Copyright (c) 2005, Michael E. Smoot
  6. * All rights reverved.
  7. *
  8. * See the file COPYING in the top directory of this distribution for
  9. * more information.
  10. *
  11. * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  14. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  16. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. * DEALINGS IN THE SOFTWARE.
  18. *
  19. *****************************************************************************/
  20. #ifndef TCLAP_CONSTRAINT_H
  21. #define TCLAP_CONSTRAINT_H
  22. #include <string>
  23. #include <vector>
  24. #include <list>
  25. #include <iostream>
  26. #include <iomanip>
  27. #include <algorithm>
  28. namespace TCLAP {
  29. /**
  30. * The interface that defines the interaction between the Arg and Constraint.
  31. */
  32. template<class T>
  33. class Constraint
  34. {
  35. public:
  36. /**
  37. * Returns a description of the Constraint.
  38. */
  39. virtual std::string description() const =0;
  40. /**
  41. * Returns the short ID for the Constraint.
  42. */
  43. virtual std::string shortID() const =0;
  44. /**
  45. * The method used to verify that the value parsed from the command
  46. * line meets the constraint.
  47. * \param value - The value that will be checked.
  48. */
  49. virtual bool check(const T& value) const =0;
  50. /**
  51. * Destructor.
  52. * Silences warnings about Constraint being a base class with virtual
  53. * functions but without a virtual destructor.
  54. */
  55. virtual ~Constraint() { ; }
  56. };
  57. } //namespace TCLAP
  58. #endif