Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkDICOMTagScanner.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkDICOMTagScanner.h"
14 
15 itk::MutexLock::Pointer mitk::DICOMTagScanner::s_LocaleMutex = itk::MutexLock::New();
16 
18 {
19 }
20 
21 
23 {
24 }
25 
27 {
28  s_LocaleMutex->Lock();
29 
30  std::string currentCLocale = setlocale(LC_NUMERIC, nullptr);
31  m_ReplacedCLocales.push(currentCLocale);
32  setlocale(LC_NUMERIC, "C");
33 
34  std::locale currentCinLocale(std::cin.getloc());
35  m_ReplacedCinLocales.push(currentCinLocale);
36  std::locale l("C");
37  std::cin.imbue(l);
38 
39  s_LocaleMutex->Unlock();
40 }
41 
43 {
44  s_LocaleMutex->Lock();
45 
46  if (!m_ReplacedCLocales.empty())
47  {
48  setlocale(LC_NUMERIC, m_ReplacedCLocales.top().c_str());
49  m_ReplacedCLocales.pop();
50  }
51  else
52  {
53  MITK_WARN << "Mismatched PopLocale on DICOMITKSeriesGDCMReader.";
54  }
55 
56  if (!m_ReplacedCinLocales.empty())
57  {
58  std::cin.imbue(m_ReplacedCinLocales.top());
59  m_ReplacedCinLocales.pop();
60  }
61  else
62  {
63  MITK_WARN << "Mismatched PopLocale on DICOMITKSeriesGDCMReader.";
64  }
65 
66  s_LocaleMutex->Unlock();
67 }
68 
70 {
71  return setlocale(LC_NUMERIC, nullptr);
72 }
#define MITK_WARN
Definition: mitkLogMacros.h:19
void PopLocale() const
Activate last remembered locale from locale stack "C" locale is required for correct parsing of numbe...
void PushLocale() const
Remember current locale on stack, activate "C" locale. "C" locale is required for correct parsing of ...
static std::string GetActiveLocale()
Return active C locale.