perf_convert.cpp 1.6 KB

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