String.hxx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_String_hxx
  4. #define cmsys_String_hxx
  5. #include <string>
  6. namespace cmsys {
  7. /** \class String
  8. * \brief Short-name version of the STL basic_string class template.
  9. *
  10. * The standard library "string" type is actually a typedef for
  11. * "basic_string<..long argument list..>". This string class is
  12. * simply a subclass of this type with the same interface so that the
  13. * name is shorter in debugging symbols and error messages.
  14. */
  15. class String : public std::string
  16. {
  17. /** The original string type. */
  18. typedef std::string stl_string;
  19. public:
  20. /** String member types. */
  21. typedef stl_string::value_type value_type;
  22. typedef stl_string::pointer pointer;
  23. typedef stl_string::reference reference;
  24. typedef stl_string::const_reference const_reference;
  25. typedef stl_string::size_type size_type;
  26. typedef stl_string::difference_type difference_type;
  27. typedef stl_string::iterator iterator;
  28. typedef stl_string::const_iterator const_iterator;
  29. typedef stl_string::reverse_iterator reverse_iterator;
  30. typedef stl_string::const_reverse_iterator const_reverse_iterator;
  31. /** String constructors. */
  32. String()
  33. : stl_string()
  34. {
  35. }
  36. String(const value_type* s)
  37. : stl_string(s)
  38. {
  39. }
  40. String(const value_type* s, size_type n)
  41. : stl_string(s, n)
  42. {
  43. }
  44. String(const stl_string& s, size_type pos = 0, size_type n = npos)
  45. : stl_string(s, pos, n)
  46. {
  47. }
  48. }; // End Class: String
  49. #if defined(__WATCOMC__)
  50. inline bool operator<(String const& l, String const& r)
  51. {
  52. return (static_cast<std::string const&>(l) <
  53. static_cast<std::string const&>(r));
  54. }
  55. #endif
  56. } // namespace cmsys
  57. #endif