Subversion Repositories Scribus

Rev

Rev 18204 | Rev 21644 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13453 pierre 1
//
2
// C++ Interface: sclocale
3
//
4
// Description: 
5
//
6
//
7
// Author: Pierre Marchand <pierremarc@oep-h.com>, (C) 2009
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
 
13
#ifndef SCCLOCALE_H
14
#define SCCLOCALE_H
15
 
16
#include <QLocale>
13469 cbradney 17
#include <QString>
13497 jghali 18
 
13589 jghali 19
#include <clocale>
13596 cbradney 20
#if defined(Q_OS_MAC)
21
#include <xlocale.h>
22
#endif
13589 jghali 23
 
18186 craig 24
#if defined(Q_OS_SOLARIS) || defined (Q_OS_OPENBSD) || defined(Q_OS_FREEBSD) || defined(Q_OS_HAIKU)
14566 cbradney 25
#include <locale.h>
26
#endif
27
 
18204 fschmid 28
#if defined(Q_OS_WIN)
13589 jghali 29
#define XLocaleType _locale_t
30
#else
18186 craig 31
  #if defined (Q_OS_SOLARIS) || defined (Q_OS_OPENBSD) || defined(Q_OS_FREEBSD) || defined(Q_OS_HAIKU)
14671 cbradney 32
  #define XLocaleType char*   //dummy?
14669 cbradney 33
  #else
34
  #define XLocaleType locale_t
35
  #endif
13589 jghali 36
#endif
37
 
13455 jghali 38
#include "scribusapi.h"
13453 pierre 39
 
13497 jghali 40
class SCRIBUS_API ScCLocale
13453 pierre 41
{
42
        ScCLocale();
13589 jghali 43
        ~ScCLocale();
13497 jghali 44
        QLocale qLocale;
13589 jghali 45
        XLocaleType cLocale;
13497 jghali 46
 
13453 pierre 47
        static ScCLocale * m_instance;
48
        static ScCLocale * that();
49
 
50
        public:
21616 jghali 51
                static inline bool isDigit(ushort ch);
52
                static double toDoubleC(const QChar *&str);
13453 pierre 53
                static double toDoubleC(const QString& str, bool * ok = 0);
13460 jghali 54
                static double toDoubleC(const QString& str, double defValue);
13469 cbradney 55
                static float toFloatC(const QString& str, bool * ok = 0);
56
                static float toFloatC(const QString& str, float defValue);
15179 jghali 57
                static QString toQStringC(double d, int prec = 3);
13589 jghali 58
                static double strtod ( const char * str, char ** endptr );
13453 pierre 59
 
60
};
61
 
21616 jghali 62
// The code of this function has been borrowed from Qt SVG module
63
inline bool ScCLocale::isDigit(ushort ch)
64
{
65
        static quint16 magic = 0x3ff;
66
        return ((ch >> 4) == 3) && (magic >> (ch & 15));
67
}
68
 
13453 pierre 69
#endif // SCCLOCALE_H
70
 
13497 jghali 71
 
13589 jghali 72