• 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     boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global();
24     mgr.select(argv[1]);
25     generator gen(mgr);
26     std::locale::global(gen(argv[2]));
27     /// Set global locale to requested
28 
29     /// Create a set that includes all strings sorted according to ABC order
30     /// std::locale can be used as object for comparison
31     std::vector<std::string> all;
32     typedef std::set<std::string,std::locale> set_type;
33     set_type all_strings;
34 
35     /// Read all strings into the set
36     while(!cin.eof()) {
37         std::string tmp;
38         getline(cin,tmp);
39         all.push_back(tmp);
40     }
41     for(int i=0;i<10000;i++) {
42         std::vector<std::string> tmp = all;
43         std::sort(tmp.begin(),tmp.end(),std::locale());
44         if(i==0) {
45             for(unsigned j=0;j<tmp.size();j++)
46                 std::cout << tmp[j] << std::endl;
47         }
48     }
49 
50 }
51 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
52