cmStandardIncludes.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2001 Insight Consortium
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright notice,
  14. this list of conditions and the following disclaimer in the documentation
  15. and/or other materials provided with the distribution.
  16. * The name of the Insight Consortium, nor the names of any consortium members,
  17. nor of any contributors, may be used to endorse or promote products derived
  18. from this software without specific prior written permission.
  19. * Modified source versions must be plainly marked as such, and must not be
  20. misrepresented as being the original software.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  25. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. =========================================================================*/
  32. /**
  33. * Include header files as a function of the build process, compiler,
  34. * and operating system.
  35. */
  36. #ifndef cmStandardIncludes_h
  37. #define cmStandardIncludes_h
  38. // include configure generated header to define
  39. // CMAKE_NO_ANSI_STREAM_HEADERS and CMAKE_NO_STD_NAMESPACE
  40. #if defined(CMAKE_HAS_AUTOCONF) || defined(CMAKE_BUILD_WITH_CMAKE)
  41. #include "cmConfigure.h"
  42. #endif
  43. #ifdef _MSC_VER
  44. #pragma warning ( disable : 4786 )
  45. #pragma warning ( disable : 4503 )
  46. #define CMAKE_NO_ANSI_FOR_SCOPE
  47. #endif
  48. #ifdef __ICL
  49. #pragma warning ( disable : 985 )
  50. #endif
  51. #ifndef CMAKE_NO_ANSI_STREAM_HEADERS
  52. #include <fstream>
  53. #include <iostream>
  54. #include <strstream>
  55. #else
  56. #include <fstream.h>
  57. #include <iostream.h>
  58. #include <strstream.h>
  59. #endif
  60. // we must have stl with the standard include style
  61. #include <vector>
  62. #include <string>
  63. #include <iterator>
  64. #include <algorithm>
  65. #include <functional>
  66. #include <map>
  67. #include <list>
  68. #include <set>
  69. // include the "c" string header
  70. #include <string.h>
  71. // if std:: is not supported, then just #define it away
  72. #ifdef CMAKE_NO_STD_NAMESPACE
  73. #define std
  74. #endif
  75. // if the compiler does not support ansi for scoping of vars use a
  76. // #define hack
  77. #ifdef CMAKE_NO_ANSI_FOR_SCOPE
  78. #define for if(false) {} else for
  79. #endif
  80. // check for the 720 compiler on the SGI
  81. // which has some strange properties that I don't think are worth
  82. // checking for in a general way in configure
  83. #if defined(__sgi) && !defined(__GNUC__)
  84. # if (_COMPILER_VERSION >= 730)
  85. # define CM_SGI_CC_730
  86. # elif (_COMPILER_VERSION >= 720)
  87. # define CM_SGI_CC_720
  88. # endif
  89. #endif
  90. # ifdef CM_SGI_CC_720
  91. // the 720 sgi compiler has std:: but not for the stream library,
  92. // so we have to bring it into the std namespace by hand.
  93. namespace std {
  94. using ::ostream;
  95. using ::istream;
  96. using ::ios;
  97. using ::cout;
  98. using ::cerr;
  99. using ::cin;
  100. using ::ifstream;
  101. using ::ofstream;
  102. using ::strstream;
  103. using ::endl;
  104. using ::ends;
  105. using ::flush;
  106. }
  107. // The string class is missing these operators so add them
  108. inline bool operator!=(std::string const& a, const char* b)
  109. { return !(a==std::string(b)); }
  110. inline bool operator==(std::string const& a, const char* b)
  111. { return (a==std::string(b)); }
  112. # endif // end CM_SGI_CC_720
  113. // use this class to shrink the size of symbols in .o files
  114. // std::string is really basic_string<....lots of stuff....>
  115. // when combined with a map or set, the symbols can be > 2000 chars!
  116. struct cmStdString : public std::string
  117. {
  118. typedef std::string StdString;
  119. typedef StdString::value_type value_type;
  120. typedef StdString::pointer pointer;
  121. typedef StdString::reference reference;
  122. typedef StdString::const_reference const_reference;
  123. typedef StdString::size_type size_type;
  124. typedef StdString::difference_type difference_type;
  125. typedef StdString::iterator iterator;
  126. typedef StdString::const_iterator const_iterator;
  127. typedef StdString::reverse_iterator reverse_iterator;
  128. typedef StdString::const_reverse_iterator const_reverse_iterator;
  129. cmStdString(): StdString() {}
  130. cmStdString(const value_type* s): StdString(s) {}
  131. cmStdString(const value_type* s, size_type n): StdString(s, n) {}
  132. cmStdString(const StdString& s, size_type pos=0, size_type n=npos):
  133. StdString(s, pos, n) {}
  134. };
  135. #endif