diff options
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/locale_guard.cc | 22 | ||||
-rw-r--r-- | libs/pbd/pbd/enumwriter.h | 4 | ||||
-rw-r--r-- | libs/pbd/pbd/locale_guard.h | 33 | ||||
-rw-r--r-- | libs/pbd/wscript | 1 |
4 files changed, 60 insertions, 0 deletions
diff --git a/libs/pbd/locale_guard.cc b/libs/pbd/locale_guard.cc new file mode 100644 index 0000000000..7d6c0708b8 --- /dev/null +++ b/libs/pbd/locale_guard.cc @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include <string.h> +#include <locale.h> + +#include "pbd/locale_guard.h" + +using namespace PBD; + +LocaleGuard::LocaleGuard (const char* str) +{ + old = strdup (setlocale (LC_NUMERIC, NULL)); + if (strcmp (old, str)) { + setlocale (LC_NUMERIC, str); + } +} + +LocaleGuard::~LocaleGuard () +{ + setlocale (LC_NUMERIC, old); + free ((char*)old); +} + diff --git a/libs/pbd/pbd/enumwriter.h b/libs/pbd/pbd/enumwriter.h index f53388f3cc..63a8ef6f6e 100644 --- a/libs/pbd/pbd/enumwriter.h +++ b/libs/pbd/pbd/enumwriter.h @@ -18,6 +18,9 @@ $Id$ */ +#ifndef __pbd_enumwriter_h__ +#define __pbd_enumwriter_h__ + #include <map> #include <string> #include <vector> @@ -75,3 +78,4 @@ class EnumWriter { #define enum_2_string(e) (PBD::EnumWriter::instance().write (typeid(e).name(), e)) #define string_2_enum(str,e) (PBD::EnumWriter::instance().read (typeid(e).name(), (str))) +#endif /* __pbd_enumwriter_h__ */ diff --git a/libs/pbd/pbd/locale_guard.h b/libs/pbd/pbd/locale_guard.h new file mode 100644 index 0000000000..480cc0fddb --- /dev/null +++ b/libs/pbd/pbd/locale_guard.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2009 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_locale_guard__ +#define __pbd_locale_guard__ + +namespace PBD { + +struct LocaleGuard { + LocaleGuard (const char*); + ~LocaleGuard (); + const char* old; +}; + +} + +#endif /* __pbd_locale_guard__ */ diff --git a/libs/pbd/wscript b/libs/pbd/wscript index be65a84ac1..5ecaf69643 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -64,6 +64,7 @@ def build(bld): file_utils.cc fpu.cc id.cc + locale_guard.cc malign.cc mountpoint.cc pathscanner.cc |