liveMedia/include/Locale.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2013 Live Networks, Inc.  All rights reserved.
00018 // Support for temporarily setting the locale (e.g., to "C" or "POSIX") for (e.g.) parsing or printing
00019 // floating-point numbers in protocol headers, or calling toupper()/tolower() on human-input strings.
00020 // C++ header
00021 
00022 #ifndef _LOCALE_HH
00023 #define _LOCALE_HH
00024 
00025 // If you're on a system that (for whatever reason) doesn't have either the "setlocale()" or the "newlocale()" function, then
00026 // add "-DLOCALE_NOT_USED" to your "config.*" file.
00027 
00028 // If you're on a system that (for whatever reason) has "setlocale()" but not "newlocale()", then
00029 // add "-DXLOCALE_NOT_USED" to your "config.*" file.
00030 // (Note that -DLOCALE_NOT_USED implies -DXLOCALE_NOT_USED; you do not need both.)
00031 // Also, for Windows systems, we define "XLOCALE_NOT_USED" by default, because at least some Windows systems
00032 // (or their development environments) don't have "newlocale()".  If, however, your Windows system *does* have "newlocale()",
00033 // then you can override this by defining "XLOCALE_USED" before #including this file.
00034 
00035 #ifdef XLOCALE_USED
00036 #undef LOCALE_NOT_USED
00037 #undef XLOCALE_NOT_USED
00038 #else
00039 #if defined(__WIN32__) || defined(_WIN32)
00040 #define XLOCALE_NOT_USED 1
00041 #endif
00042 #endif
00043 
00044 #ifndef LOCALE_NOT_USED
00045 #include <locale.h>
00046 #ifndef XLOCALE_NOT_USED
00047 #include <xlocale.h> // because, on some systems, <locale.h> doesn't include <xlocale.h>; this makes sure that we get both
00048 #endif
00049 #endif
00050 
00051 
00052 enum LocaleCategory { All, Numeric }; // define and implement more categories later, as needed
00053 
00054 class Locale {
00055 public:
00056   Locale(char const* newLocale, LocaleCategory category = All);
00057   virtual ~Locale();
00058 
00059 private:
00060 #ifndef LOCALE_NOT_USED
00061 #ifndef XLOCALE_NOT_USED
00062   locale_t fLocale, fPrevLocale;
00063 #else
00064   int fCategoryNum;
00065   char* fPrevLocale;
00066 #endif
00067 #endif
00068 };
00069 
00070 #endif

Generated on Mon Apr 29 13:28:01 2013 for live by  doxygen 1.5.2