• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <iostream>
9 #include <string>
10 #include <set>
11 
12 #include <boost/locale.hpp>
13 
14 using namespace std;
15 using namespace boost::locale;
16 
main(int argc,char ** argv)17 int main(int argc,char **argv)
18 {
19     if(argc!=2) {
20         std::cerr << "Usage backend locale" << std::endl;
21         return 1;
22     }
23     /// Set global locale to requested
24 
25     /// Create a set that includes all strings sorted according to ABC order
26     /// std::locale can be used as object for comparison
27     std::vector<std::string> all;
28     typedef std::set<std::string,std::locale> set_type;
29     set_type all_strings;
30 
31     /// Read all strings into the set
32     while(!cin.eof()) {
33         std::string tmp;
34         getline(cin,tmp);
35         all.push_back(tmp);
36     }
37 
38     {
39         boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global();
40         mgr.select(argv[1]);
41         generator gen(mgr);
42         std::locale::global(gen(argv[2]));
43         for(int i=0;i<10000;i++) {
44             for(unsigned j=0;j<all.size();j++) {
45                 boost::locale::to_upper(all[j]);
46                 boost::locale::to_lower(all[j]);
47                 if(i==0) {
48                     std::cout << boost::locale::to_upper(all[j]) << std::endl;
49                     std::cout << boost::locale::to_lower(all[j]) << std::endl;
50                 }
51             }
52         }
53     }
54 
55 }
56 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
57