GetFEM  5.4.2
getfem_locale.cc
1 /*===========================================================================
2 
3  Copyright (C) 2012-2020 Andriy Andreykiv.
4 
5  This file is a part of GetFEM
6 
7  GetFEM is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as published
9  by the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version along with the GCC Runtime Library
11  Exception either version 3.1 or (at your option) any later version.
12  This program is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  License and GCC Runtime Library Exception for more details.
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program; if not, write to the Free Software Foundation,
18  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20 ===========================================================================*/
21 
22 #include <iostream>
23 
24 #include <getfem/getfem_locale.h>
25 #include <getfem/getfem_omp.h>
26 
27 namespace getfem{
28 
29  #ifdef _WIN32
30 
31  standard_locale::standard_locale()
32  : cinloc(std::cin.getloc()){
34  cloc=setlocale(LC_NUMERIC, 0);
35  setlocale(LC_NUMERIC,"C");
36  }
37  }
38 
39  standard_locale::~standard_locale() {
41  setlocale(LC_NUMERIC, cloc.c_str());
42 
43  }
44 
45  #else
46 
47  standard_locale::standard_locale()
48  : cloc(setlocale(LC_NUMERIC, 0)), cinloc(std::cin.getloc()){
49  setlocale(LC_NUMERIC,"C"); std::cin.imbue(std::locale("C"));
50  }
51 
52  standard_locale::~standard_locale(){
53  setlocale(LC_NUMERIC, cloc.c_str()); std::cin.imbue(cinloc);
54  }
55 
56  #endif
57 
58 } /* end of namespace getfem. */
getfem::me_is_multithreaded_now
bool me_is_multithreaded_now()
is the program running in the parallel section
Definition: getfem_omp.cc:106
getfem
GEneric Tool for Finite Element Methods.
Definition: getfem_accumulated_distro.h:46
getfem_omp.h
Tools for multithreaded, OpenMP and Boost based parallelization.
getfem_locale.h
thread safe standard locale with RAII semantics