locale_impl.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 1999
  3. * Silicon Graphics Computer Systems, Inc.
  4. *
  5. * Copyright (c) 1999
  6. * Boris Fomitchev
  7. *
  8. * This material is provided "as is", with absolutely no warranty expressed
  9. * or implied. Any use is at your own risk.
  10. *
  11. * Permission to use or copy this software for any purpose is hereby granted
  12. * without fee, provided the above notices are retained on all copies.
  13. * Permission to modify the code and to distribute modified code is granted,
  14. * provided the above notices are retained, and a notice that the code was
  15. * modified is included with the above copyright notice.
  16. *
  17. */
  18. #ifndef LOCALE_IMPL_H
  19. #define LOCALE_IMPL_H
  20. #include <clocale> // C locale header file.
  21. #include <vector>
  22. #include <string>
  23. #include <locale>
  24. #include "c_locale.h"
  25. _STLP_BEGIN_NAMESPACE
  26. #if defined (_STLP_USE_TEMPLATE_EXPORT)
  27. //Export of _Locale_impl facets container:
  28. # if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
  29. //If we are using pointer specialization, vector<locale::facet*> will use
  30. //the already exported vector<void*> implementation.
  31. _STLP_EXPORT_TEMPLATE_CLASS allocator<locale::facet*>;
  32. _STLP_MOVE_TO_PRIV_NAMESPACE
  33. _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
  34. _STLP_EXPORT_TEMPLATE_CLASS _Vector_base<locale::facet*, allocator<locale::facet*> >;
  35. _STLP_MOVE_TO_STD_NAMESPACE
  36. # endif
  37. # if defined (_STLP_DEBUG)
  38. _STLP_MOVE_TO_PRIV_NAMESPACE
  39. # define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
  40. _STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
  41. _STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
  42. # undef _STLP_NON_DBG_VECTOR
  43. _STLP_MOVE_TO_STD_NAMESPACE
  44. # endif
  45. _STLP_EXPORT_TEMPLATE_CLASS vector<locale::facet*, allocator<locale::facet*> >;
  46. #endif
  47. //----------------------------------------------------------------------
  48. // Class _Locale_impl
  49. // This is the base class which implements access only and is supposed to
  50. // be used for classic locale only
  51. class _STLP_CLASS_DECLSPEC _Locale_impl : public _Refcount_Base {
  52. public:
  53. _Locale_impl(const char* s);
  54. _Locale_impl(const _Locale_impl&);
  55. _Locale_impl(size_t n, const char* s);
  56. private:
  57. ~_Locale_impl();
  58. public:
  59. size_t size() const { return facets_vec.size(); }
  60. basic_string<char, char_traits<char>, allocator<char> > name;
  61. static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast();
  62. private:
  63. void operator=(const _Locale_impl&);
  64. public:
  65. class _STLP_CLASS_DECLSPEC Init {
  66. public:
  67. Init();
  68. ~Init();
  69. private:
  70. _Refcount_Base& _M_count() const;
  71. };
  72. static void _STLP_CALL _S_initialize();
  73. static void _STLP_CALL _S_uninitialize();
  74. static void make_classic_locale();
  75. static void free_classic_locale();
  76. friend class Init;
  77. public:
  78. // void remove(size_t index);
  79. locale::facet* insert(locale::facet*, const locale::id& n);
  80. void insert(_Locale_impl* from, const locale::id& n);
  81. // Helper functions for byname construction of locales.
  82. _Locale_name_hint* insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  83. _Locale_name_hint* insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  84. _Locale_name_hint* insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  85. _Locale_name_hint* insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  86. _Locale_name_hint* insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  87. _Locale_name_hint* insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint);
  88. bool operator != (const locale& __loc) const { return __loc._M_impl != this; }
  89. private:
  90. vector<locale::facet*> facets_vec;
  91. private:
  92. friend _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl * );
  93. friend void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
  94. #if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
  95. defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
  96. friend class _STLP_NO_MEM_T_NAME(loc);
  97. #else
  98. friend class locale;
  99. #endif
  100. };
  101. void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
  102. _STLP_END_NAMESPACE
  103. #endif
  104. // Local Variables:
  105. // mode:C++
  106. // End: