flex_string.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // flex_string
  3. // Copyright (c) 2001 by Andrei Alexandrescu
  4. // Permission to use, copy, modify, distribute and sell this software for any
  5. // purpose is hereby granted without fee, provided that the above copyright
  6. // notice appear in all copies and that both that copyright notice and this
  7. // permission notice appear in supporting documentation.
  8. // The author makes no representations about the
  9. // suitability of this software for any purpose. It is provided "as is"
  10. // without express or implied warranty.
  11. ////////////////////////////////////////////////////////////////////////////////
  12. #ifndef DAHUA_FLEX_STRING_INC_
  13. #define DAHUA_FLEX_STRING_INC_
  14. // revision 754
  15. ////////////////////////////////////////////////////////////////////////////////
  16. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  17. #include <utility>
  18. namespace std {
  19. template<>
  20. struct iterator_traits<char*>
  21. {
  22. typedef random_access_iterator_tag iterator_category;
  23. typedef char value_type;
  24. typedef ptrdiff_t distance_type;
  25. typedef char* pointer;
  26. typedef char& reference;
  27. };
  28. template<>
  29. struct iterator_traits<const char*>
  30. {
  31. typedef random_access_iterator_tag iterator_category;
  32. typedef char value_type;
  33. typedef ptrdiff_t distance_type;
  34. typedef const char* pointer;
  35. typedef const char& reference;
  36. };
  37. template<>
  38. struct iterator_traits<wchar_t*>
  39. {
  40. typedef random_access_iterator_tag iterator_category;
  41. typedef wchar_t value_type;
  42. typedef ptrdiff_t distance_type;
  43. typedef wchar_t* pointer;
  44. typedef wchar_t& reference;
  45. };
  46. template<>
  47. struct iterator_traits<const wchar_t*>
  48. {
  49. typedef random_access_iterator_tag iterator_category;
  50. typedef wchar_t value_type;
  51. typedef ptrdiff_t distance_type;
  52. typedef const wchar_t* pointer;
  53. typedef const wchar_t& reference;
  54. };
  55. } // namespace std
  56. #endif
  57. ////////////////////////////////////////////////////////////////////////////////
  58. //#define DAHUA_DEBUG_FLEX_STRING
  59. // Ïû³ý GCC strict-aliasing ¾¯¸æ
  60. #if defined(__GNUC__) && (__GNUC__ >= 4)
  61. #pragma GCC system_header
  62. #endif
  63. #if defined(_MSC_VER)
  64. #pragma warning (push)
  65. #pragma warning (disable : 4786)
  66. #endif
  67. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  68. #define NO_ITERATOR_TRAITS
  69. #define DAHUA_DEDUCED_TYPENAME
  70. #else
  71. #define DAHUA_DEDUCED_TYPENAME typename
  72. #endif
  73. ////////////////////////////////////////////////////////////////////////////////
  74. // <THE> string
  75. #include "flex_string_shell.h"
  76. // Storage policies
  77. #include "simplestringstorage.h"
  78. #include "ministringstorage.h"
  79. #include "allocatorstringstorage.h"
  80. #include "vectorstringstorage.h"
  81. #include "smallstringopt.h"
  82. //#include "cowstringopt.h"
  83. //#include "utf16encoding.h"
  84. #if defined(_MSC_VER)
  85. #pragma warning (pop)
  86. #endif
  87. #undef DAHUA_DEDUCED_TYPENAME
  88. #undef DAHUA_DEBUG_FLEX_STRING
  89. #endif // DAHUA_FLEX_STRING_INC_