ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

160 lines
5.4 KiB

  1. //
  2. // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. #ifndef BOOSTER_LOCALE_LOCALIZATION_BACKEND_HPP
  9. #define BOOSTER_LOCALE_LOCALIZATION_BACKEND_HPP
  10. #include <booster/config.h>
  11. #include <booster/locale/generator.h>
  12. #ifdef BOOSTER_MSVC
  13. # pragma warning(push)
  14. # pragma warning(disable : 4275 4251 4231 4660)
  15. #endif
  16. #include <string>
  17. #include <locale>
  18. #include <vector>
  19. #include <booster/auto_ptr_inc.h>
  20. namespace booster {
  21. namespace locale {
  22. ///
  23. /// \brief this class represents a localization backend that can be used for localizing your application.
  24. ///
  25. /// Backends are usually registered inside the localization backends manager and allow transparent support
  26. /// of different backends, so a user can switch the backend by simply linking the application to the correct one.
  27. ///
  28. /// Backends may support different tuning options, but these are the default options available to the user
  29. /// for all of them
  30. ///
  31. /// -# \c locale - the name of the locale in POSIX format like en_US.UTF-8
  32. /// -# \c use_ansi_encoding - select system locale using ANSI codepages rather then UTF-8 under Windows
  33. /// by default
  34. /// -# \c message_path - path to the location of message catalogs (vector of strings)
  35. /// -# \c message_application - the name of applications that use message catalogs (vector of strings)
  36. ///
  37. /// Each backend can be installed with a different default priotiry so when you work with two different backends, you
  38. /// can specify priotiry so this backend will be chosen according to their priority.
  39. ///
  40. class localization_backend {
  41. localization_backend(localization_backend const &);
  42. void operator=(localization_backend const &);
  43. public:
  44. localization_backend()
  45. {
  46. }
  47. virtual ~localization_backend()
  48. {
  49. }
  50. ///
  51. /// Make a polymorphic copy of the backend
  52. ///
  53. virtual localization_backend *clone() const = 0;
  54. ///
  55. /// Set option for backend, for example "locale" or "encoding"
  56. ///
  57. virtual void set_option(std::string const &name,std::string const &value) = 0;
  58. ///
  59. /// Clear all options
  60. ///
  61. virtual void clear_options() = 0;
  62. ///
  63. /// Create a facet for category \a category and character type \a type
  64. ///
  65. virtual std::locale install(std::locale const &base,locale_category_type category,character_facet_type type = nochar_facet) = 0;
  66. }; // localization_backend
  67. ///
  68. /// \brief Localization backend manager is a class that holds various backend and allows creation
  69. /// of their combination or selection
  70. ///
  71. class BOOSTER_API localization_backend_manager {
  72. public:
  73. ///
  74. /// New empty localization_backend_manager
  75. ///
  76. localization_backend_manager();
  77. ///
  78. /// Copy localization_backend_manager
  79. ///
  80. localization_backend_manager(localization_backend_manager const &);
  81. ///
  82. /// Assign localization_backend_manager
  83. ///
  84. localization_backend_manager const &operator=(localization_backend_manager const &);
  85. ///
  86. /// Destructor
  87. ///
  88. ~localization_backend_manager();
  89. ///
  90. /// Create new localization backend according to current settings.
  91. ///
  92. std::auto_ptr<localization_backend> get() const;
  93. ///
  94. /// Add new backend to the manager, each backend should be uniquely defined by its name.
  95. ///
  96. /// This library provides: "icu", "posix", "winapi" and "std" backends.
  97. ///
  98. void add_backend(std::string const &name,std::auto_ptr<localization_backend> backend);
  99. ///
  100. /// Clear backend
  101. ///
  102. void remove_all_backends();
  103. ///
  104. /// Get list of all available backends
  105. ///
  106. std::vector<std::string> get_all_backends() const;
  107. ///
  108. /// Select specific backend by name for a category \a category. It allows combining different
  109. /// backends for user preferences.
  110. ///
  111. void select(std::string const &backend_name,locale_category_type category = all_categories);
  112. ///
  113. /// Set new global backend manager, the old one is returned.
  114. ///
  115. /// This function is thread safe
  116. ///
  117. static localization_backend_manager global(localization_backend_manager const &);
  118. ///
  119. /// Get global backend manager
  120. ///
  121. /// This function is thread safe
  122. ///
  123. static localization_backend_manager global();
  124. private:
  125. class impl;
  126. std::auto_ptr<impl> pimpl_;
  127. };
  128. } // locale
  129. } // boost
  130. #ifdef BOOSTER_MSVC
  131. #pragma warning(pop)
  132. #endif
  133. #endif
  134. // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4