libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
LocaleGuard.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
11
#ifndef ZYPP_BASE_LOCALEGUARD_H
12
#define ZYPP_BASE_LOCALEGUARD_H
13
14
#include <locale.h>
15
#include <string>
16
17
#include "
zypp/base/Easy.h
"
18
20
namespace
zypp
21
{
27
class
LocaleGuard
28
{
29
NON_COPYABLE
(
LocaleGuard
);
30
NON_MOVABLE
(
LocaleGuard
);
31
32
public
:
34
LocaleGuard
(
int
category_r,
const
std::string & value_r =
"C"
)
35
:
_category
( -1 )
36
{
37
const
char
* ovalue = ::setlocale( category_r,
nullptr
);
38
if
( ovalue && ovalue != value_r )
39
{
40
_category
= category_r;
41
_value
= ovalue;
42
::setlocale(
_category
, value_r.c_str() );
43
}
44
}
45
47
~LocaleGuard
()
48
{
restore
(); }
49
51
void
restore
()
52
{
53
if
(
_category
!= -1 )
54
{
55
::setlocale(
_category
,
_value
.c_str() );
56
_category
= -1;
57
}
58
}
59
60
private
:
61
int
_category
;
62
std::string
_value
;
63
};
64
}
// namespace zypp
66
#endif // ZYPP_BASE_LOCALEGUARD_H
zypp
base
LocaleGuard.h
Generated by
1.8.2