cmStandardIncludes.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. /**
  14. * Include header files as a function of the build process, compiler,
  15. * and operating system.
  16. */
  17. #ifndef cmStandardIncludes_h
  18. #define cmStandardIncludes_h
  19. // include configure generated header to define
  20. // CMAKE_NO_ANSI_STREAM_HEADERS and CMAKE_NO_STD_NAMESPACE
  21. #if defined(CMAKE_HAS_AUTOCONF) || defined(CMAKE_BUILD_WITH_CMAKE)
  22. #include "cmConfigure.h"
  23. #endif
  24. #ifdef _MSC_VER
  25. #pragma warning ( disable : 4786 )
  26. #pragma warning ( disable : 4503 )
  27. #define CMAKE_NO_ANSI_FOR_SCOPE
  28. #endif
  29. #ifdef __ICL
  30. #pragma warning ( disable : 985 )
  31. #endif
  32. #ifndef CMAKE_NO_ANSI_STREAM_HEADERS
  33. #include <fstream>
  34. #include <iostream>
  35. #include <strstream>
  36. #else
  37. #include <fstream.h>
  38. #include <iostream.h>
  39. #include <strstream.h>
  40. #endif
  41. // we must have stl with the standard include style
  42. #include <vector>
  43. #include <string>
  44. #include <iterator>
  45. #include <algorithm>
  46. #include <functional>
  47. #include <map>
  48. #include <list>
  49. #include <set>
  50. // include the "c" string header
  51. #include <string.h>
  52. // if std:: is not supported, then just #define it away
  53. #ifdef CMAKE_NO_STD_NAMESPACE
  54. #define std
  55. #endif
  56. // if the compiler does not support ansi for scoping of vars use a
  57. // #define hack
  58. #ifdef CMAKE_NO_ANSI_FOR_SCOPE
  59. #define for if(false) {} else for
  60. #endif
  61. // check for the 720 compiler on the SGI
  62. // which has some strange properties that I don't think are worth
  63. // checking for in a general way in configure
  64. #if defined(__sgi) && !defined(__GNUC__)
  65. # if (_COMPILER_VERSION >= 730)
  66. # define CM_SGI_CC_730
  67. # elif (_COMPILER_VERSION >= 720)
  68. # define CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
  69. # endif
  70. #endif
  71. #ifdef __DECCXX_VER
  72. # if __DECCXX_VER <= 60390008
  73. # define CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
  74. # endif
  75. #endif
  76. #ifdef CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
  77. // some compilers have std:: but not for the stream library,
  78. // so we have to bring it into the std namespace by hand.
  79. namespace std {
  80. using ::ostream;
  81. using ::istream;
  82. using ::ios;
  83. using ::cout;
  84. using ::cerr;
  85. using ::cin;
  86. using ::ifstream;
  87. using ::ofstream;
  88. using ::strstream;
  89. using ::endl;
  90. using ::ends;
  91. using ::flush;
  92. }
  93. // The string class is missing these operators so add them
  94. inline bool operator!=(std::string const& a, const char* b)
  95. { return !(a==std::string(b)); }
  96. inline bool operator==(std::string const& a, const char* b)
  97. { return (a==std::string(b)); }
  98. # endif // end CM_SGI_CC_720
  99. // use this class to shrink the size of symbols in .o files
  100. // std::string is really basic_string<....lots of stuff....>
  101. // when combined with a map or set, the symbols can be > 2000 chars!
  102. struct cmStdString : public std::string
  103. {
  104. typedef std::string StdString;
  105. typedef StdString::value_type value_type;
  106. typedef StdString::pointer pointer;
  107. typedef StdString::reference reference;
  108. typedef StdString::const_reference const_reference;
  109. typedef StdString::size_type size_type;
  110. typedef StdString::difference_type difference_type;
  111. typedef StdString::iterator iterator;
  112. typedef StdString::const_iterator const_iterator;
  113. typedef StdString::reverse_iterator reverse_iterator;
  114. typedef StdString::const_reverse_iterator const_reverse_iterator;
  115. cmStdString(): StdString() {}
  116. cmStdString(const value_type* s): StdString(s) {}
  117. cmStdString(const value_type* s, size_type n): StdString(s, n) {}
  118. cmStdString(const StdString& s, size_type pos=0, size_type n=npos):
  119. StdString(s, pos, n) {}
  120. };
  121. #endif