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.
 
 
 

88 rivejä
2.6 KiB

  1. // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
  2. /******************************************************************************
  3. *
  4. * file: ArgTraits.h
  5. *
  6. * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
  7. * All rights reverved.
  8. *
  9. * See the file COPYING in the top directory of this distribution for
  10. * more information.
  11. *
  12. * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  17. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  18. * DEALINGS IN THE SOFTWARE.
  19. *
  20. *****************************************************************************/
  21. // This is an internal tclap file, you should probably not have to
  22. // include this directly
  23. #ifndef TCLAP_ARGTRAITS_H
  24. #define TCLAP_ARGTRAITS_H
  25. namespace TCLAP {
  26. // We use two empty structs to get compile type specialization
  27. // function to work
  28. /**
  29. * A value like argument value type is a value that can be set using
  30. * operator>>. This is the default value type.
  31. */
  32. struct ValueLike {
  33. typedef ValueLike ValueCategory;
  34. virtual ~ValueLike() {}
  35. };
  36. /**
  37. * A string like argument value type is a value that can be set using
  38. * operator=(string). Usefull if the value type contains spaces which
  39. * will be broken up into individual tokens by operator>>.
  40. */
  41. struct StringLike {
  42. virtual ~StringLike() {}
  43. };
  44. /**
  45. * A class can inherit from this object to make it have string like
  46. * traits. This is a compile time thing and does not add any overhead
  47. * to the inherenting class.
  48. */
  49. struct StringLikeTrait {
  50. typedef StringLike ValueCategory;
  51. virtual ~StringLikeTrait() {}
  52. };
  53. /**
  54. * A class can inherit from this object to make it have value like
  55. * traits. This is a compile time thing and does not add any overhead
  56. * to the inherenting class.
  57. */
  58. struct ValueLikeTrait {
  59. typedef ValueLike ValueCategory;
  60. virtual ~ValueLikeTrait() {}
  61. };
  62. /**
  63. * Arg traits are used to get compile type specialization when parsing
  64. * argument values. Using an ArgTraits you can specify the way that
  65. * values gets assigned to any particular type during parsing. The two
  66. * supported types are StringLike and ValueLike.
  67. */
  68. template<typename T>
  69. struct ArgTraits {
  70. typedef typename T::ValueCategory ValueCategory;
  71. virtual ~ArgTraits() {}
  72. //typedef ValueLike ValueCategory;
  73. };
  74. #endif
  75. } // namespace