• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (c) 2004
4  * John Maddock
5  *
6  * Use, modification and distribution are subject to the
7  * Boost Software License, Version 1.0. (See accompanying file
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11 
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         test_locale.hpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Helper classes for testing locale-specific expressions.
17   */
18 
19 
20 #ifndef BOOST_REGEX_REGRESS_TEST_LOCALE_HPP
21 #define BOOST_REGEX_REGRESS_TEST_LOCALE_HPP
22 //
23 // defines class test_locale that handles the locale used for testing:
24 //
25 class test_locale
26 {
27 public:
28    enum{
29       no_test,
30       test_no_locale,
31       test_with_locale
32    };
33 
34    test_locale(const char* c_name, boost::uint32_t lcid);
35    ~test_locale();
36 
c_locale_state()37    static int c_locale_state()
38    {
39       return s_c_locale;
40    }
cpp_locale_state()41    static int cpp_locale_state()
42    {
43       return s_cpp_locale;
44    }
win_locale_state()45    static int win_locale_state()
46    {
47       return s_win_locale;
48    }
c_str()49    static const char* c_str()
50    {
51       return m_name.c_str();
52    }
53 #ifndef BOOST_NO_STD_LOCALE
cpp_locale()54    static std::locale cpp_locale()
55    {
56       return s_cpp_locale_inst;
57    }
58 #endif
win_locale()59    static boost::uint32_t win_locale()
60    {
61       return s_win_locale_inst;
62    }
63 
64 private:
65    // the actions to take for each locale type:
66    static int s_c_locale;
67    static int s_cpp_locale;
68    static int s_win_locale;
69    // current locales:
70 #ifndef BOOST_NO_STD_LOCALE
71    static std::locale s_cpp_locale_inst;
72 #endif
73    static boost::uint32_t s_win_locale_inst;
74    static std::string m_name;
75 
76    // backed up versions of the previous locales and their action state:
77    std::string     m_old_c_locale;
78    std::string     m_old_name;
79    int             m_old_c_state;
80 #ifndef BOOST_NO_STD_LOCALE
81    std::locale     m_old_cpp_locale;
82 #endif
83    int             m_old_cpp_state;
84    boost::uint32_t m_old_win_locale;
85    int             m_old_win_state;
86 
87 };
88 
89 #endif
90 
91