live
liveMedia
include
Locale.hh
Go to the documentation of this file.
1
/**********
2
This library is free software; you can redistribute it and/or modify it under
3
the terms of the GNU Lesser General Public License as published by the
4
Free Software Foundation; either version 3 of the License, or (at your
5
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7
This library is distributed in the hope that it will be useful, but WITHOUT
8
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10
more details.
11
12
You should have received a copy of the GNU Lesser General Public License
13
along with this library; if not, write to the Free Software Foundation, Inc.,
14
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
**********/
16
// "liveMedia"
17
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18
// Support for temporarily setting the locale (e.g., to "C" or "POSIX") for (e.g.) parsing or printing
19
// floating-point numbers in protocol headers, or calling toupper()/tolower() on human-input strings.
20
// C++ header
21
22
#ifndef _LOCALE_HH
23
#define _LOCALE_HH
24
25
// If you're on a system that (for whatever reason) doesn't have either the "setlocale()" or the "newlocale()" function, then
26
// add "-DLOCALE_NOT_USED" to your "config.*" file.
27
28
// If you're on a system that (for whatever reason) has "setlocale()" but not "newlocale()", then
29
// add "-DNEWLOCALE_NOT_USED" to your "config.*" file.
30
// (Note that -DLOCALE_NOT_USED implies -DNEWLOCALE_NOT_USED; you do not need both.)
31
// Also, for Windows systems, we define "NEWLOCALE_NOT_USED" by default, because at least some Windows systems
32
// (or their development environments) don't have "newlocale()". If, however, your Windows system *does* have "newlocale()",
33
// then you can override this by defining "NEWLOCALE_USED" before #including this file.
34
35
// Finally, some old development environments need a header file "xlocale.h" to use "newlocale()".
36
// Should you need this header file, add "-DNEED_XLOCALE_H" to your "config.*" file.
37
38
#ifdef NEWLOCALE_USED
39
#undef LOCALE_NOT_USED
40
#undef NEWLOCALE_NOT_USED
41
#else
42
#if defined(__WIN32__) || defined(_WIN32)
43
#define NEWLOCALE_NOT_USED 1
44
#endif
45
#endif
46
47
#ifndef LOCALE_NOT_USED
48
#include <locale.h>
49
#ifndef NEWLOCALE_NOT_USED
50
#ifdef NEED_XLOCALE_H
51
#include <xlocale.h>
52
#endif
53
#endif
54
#endif
55
56
57
enum
LocaleCategory
{
All
,
Numeric
};
// define and implement more categories later, as needed
58
59
class
Locale
{
60
public
:
61
Locale
(
char
const
* newLocale,
LocaleCategory
category =
All
);
62
virtual
~Locale
();
63
64
private
:
65
#ifndef LOCALE_NOT_USED
66
#ifndef NEWLOCALE_NOT_USED
67
locale_t
fLocale
,
fPrevLocale
;
68
#else
69
int
fCategoryNum;
70
char
*
fPrevLocale
;
71
#endif
72
#endif
73
};
74
75
#endif
LocaleCategory
LocaleCategory
Definition:
Locale.hh:57
Numeric
@ Numeric
Definition:
Locale.hh:57
All
@ All
Definition:
Locale.hh:57
Locale
Definition:
Locale.hh:59
Locale::fPrevLocale
locale_t fPrevLocale
Definition:
Locale.hh:67
Locale::~Locale
virtual ~Locale()
Locale::fLocale
locale_t fLocale
Definition:
Locale.hh:67
Locale::Locale
Locale(char const *newLocale, LocaleCategory category=All)
Generated on Tue Jun 25 2024 22:52:35 for live by
1.9.5