IOStream.hxx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
  3. #ifndef cmsys_IOStream_hxx
  4. #define cmsys_IOStream_hxx
  5. #include <iosfwd>
  6. /* Define these macros temporarily to keep the code readable. */
  7. #if !defined(KWSYS_NAMESPACE) && !cmsys_NAME_IS_KWSYS
  8. #define kwsysEXPORT cmsys_EXPORT
  9. #endif
  10. /* Whether istream supports long long. */
  11. #define cmsys_IOS_HAS_ISTREAM_LONG_LONG \
  12. 1
  13. /* Whether ostream supports long long. */
  14. #define cmsys_IOS_HAS_OSTREAM_LONG_LONG \
  15. 1
  16. /* Determine whether we need to define the streaming operators for
  17. long long or __int64. */
  18. #if 1
  19. #if !cmsys_IOS_HAS_ISTREAM_LONG_LONG || \
  20. !cmsys_IOS_HAS_OSTREAM_LONG_LONG
  21. #define cmsys_IOS_NEED_OPERATORS_LL 1
  22. namespace cmsys {
  23. typedef long long IOStreamSLL;
  24. typedef unsigned long long IOStreamULL;
  25. }
  26. #endif
  27. #elif defined(_MSC_VER) && _MSC_VER < 1300
  28. #define cmsys_IOS_NEED_OPERATORS_LL 1
  29. namespace cmsys {
  30. typedef __int64 IOStreamSLL;
  31. typedef unsigned __int64 IOStreamULL;
  32. }
  33. #endif
  34. #if !defined(cmsys_IOS_NEED_OPERATORS_LL)
  35. #define cmsys_IOS_NEED_OPERATORS_LL 0
  36. #endif
  37. #if cmsys_IOS_NEED_OPERATORS_LL
  38. #if !cmsys_IOS_HAS_ISTREAM_LONG_LONG
  39. /* Input stream operator implementation functions. */
  40. namespace cmsys {
  41. kwsysEXPORT std::istream& IOStreamScan(std::istream&, IOStreamSLL&);
  42. kwsysEXPORT std::istream& IOStreamScan(std::istream&, IOStreamULL&);
  43. }
  44. /* Provide input stream operator for long long. */
  45. #if !defined(cmsys_IOS_NO_ISTREAM_LONG_LONG) && \
  46. !defined(KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED)
  47. #define KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED
  48. #define cmsys_IOS_ISTREAM_LONG_LONG_DEFINED
  49. inline std::istream& operator>>(std::istream& is,
  50. cmsys::IOStreamSLL& value)
  51. {
  52. return cmsys::IOStreamScan(is, value);
  53. }
  54. #endif
  55. /* Provide input stream operator for unsigned long long. */
  56. #if !defined(cmsys_IOS_NO_ISTREAM_UNSIGNED_LONG_LONG) && \
  57. !defined(KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED)
  58. #define KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
  59. #define cmsys_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
  60. inline std::istream& operator>>(std::istream& is,
  61. cmsys::IOStreamULL& value)
  62. {
  63. return cmsys::IOStreamScan(is, value);
  64. }
  65. #endif
  66. #endif /* !cmsys_IOS_HAS_ISTREAM_LONG_LONG */
  67. #if !cmsys_IOS_HAS_OSTREAM_LONG_LONG
  68. /* Output stream operator implementation functions. */
  69. namespace cmsys {
  70. kwsysEXPORT std::ostream& IOStreamPrint(std::ostream&, IOStreamSLL);
  71. kwsysEXPORT std::ostream& IOStreamPrint(std::ostream&, IOStreamULL);
  72. }
  73. /* Provide output stream operator for long long. */
  74. #if !defined(cmsys_IOS_NO_OSTREAM_LONG_LONG) && \
  75. !defined(KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED)
  76. #define KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED
  77. #define cmsys_IOS_OSTREAM_LONG_LONG_DEFINED
  78. inline std::ostream& operator<<(std::ostream& os,
  79. cmsys::IOStreamSLL value)
  80. {
  81. return cmsys::IOStreamPrint(os, value);
  82. }
  83. #endif
  84. /* Provide output stream operator for unsigned long long. */
  85. #if !defined(cmsys_IOS_NO_OSTREAM_UNSIGNED_LONG_LONG) && \
  86. !defined(KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED)
  87. #define KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
  88. #define cmsys_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
  89. inline std::ostream& operator<<(std::ostream& os,
  90. cmsys::IOStreamULL value)
  91. {
  92. return cmsys::IOStreamPrint(os, value);
  93. }
  94. #endif
  95. #endif /* !cmsys_IOS_HAS_OSTREAM_LONG_LONG */
  96. #endif /* cmsys_IOS_NEED_OPERATORS_LL */
  97. /* Undefine temporary macros. */
  98. #if !defined(KWSYS_NAMESPACE) && !cmsys_NAME_IS_KWSYS
  99. #undef kwsysEXPORT
  100. #endif
  101. /* If building a C++ file in kwsys itself, give the source file
  102. access to the macros without a configured namespace. */
  103. #if defined(KWSYS_NAMESPACE)
  104. #define KWSYS_IOS_HAS_ISTREAM_LONG_LONG \
  105. cmsys_IOS_HAS_ISTREAM_LONG_LONG
  106. #define KWSYS_IOS_HAS_OSTREAM_LONG_LONG \
  107. cmsys_IOS_HAS_OSTREAM_LONG_LONG
  108. #define KWSYS_IOS_NEED_OPERATORS_LL cmsys_IOS_NEED_OPERATORS_LL
  109. #endif
  110. #endif