1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/***************************************************************************
common.h - Things that are needed often
-------------------
begin : Mon Mar 18 2002
copyright : (C) 2002-2007 by Joachim Eibl
email : joachim.eibl at gmx.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef _COMMON_H
#define _COMMON_H
#include <assert.h>
template< class T >
T min2( T x, T y )
{
return x<y ? x : y;
}
template< class T >
T max2( T x, T y )
{
return x>y ? x : y;
}
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
template <class T>
T min3( T d1, T d2, T d3 )
{
if ( d1 < d2 && d1 < d3 ) return d1;
if ( d2 < d3 ) return d2;
return d3;
}
template <class T>
T max3( T d1, T d2, T d3 )
{
if ( d1 > d2 && d1 > d3 ) return d1;
if ( d2 > d3 ) return d2;
return d3;
}
template <class T>
T minMaxLimiter( T d, T minimum, T maximum )
{
assert(minimum<=maximum);
if ( d < minimum ) return minimum;
if ( d > maximum ) return maximum;
return d;
}
#include <map>
#include <qstring.h>
class QFont;
class QColor;
class QSize;
class QPoint;
class QStringList;
class QTextStream;
class ValueMap
{
private:
std::map<QString,QString> m_map;
public:
ValueMap();
virtual ~ValueMap();
void save( QTextStream& ts );
void load( QTextStream& ts );
QString getAsString();
// void load( const QString& s );
virtual void writeEntry(const QString&, const QFont& );
virtual void writeEntry(const QString&, const QColor& );
virtual void writeEntry(const QString&, const QSize& );
virtual void writeEntry(const QString&, const QPoint& );
virtual void writeEntry(const QString&, int );
virtual void writeEntry(const QString&, bool );
virtual void writeEntry(const QString&, const QStringList&, char separator );
virtual void writeEntry(const QString&, const QString& );
virtual void writeEntry(const QString&, const char* );
virtual QFont readFontEntry (const QString&, QFont* defaultVal );
virtual QColor readColorEntry(const QString&, QColor* defaultVal );
virtual QSize readSizeEntry (const QString&, QSize* defaultVal );
virtual QPoint readPointEntry(const QString&, QPoint* defaultVal );
virtual bool readBoolEntry (const QString&, bool bDefault );
virtual int readNumEntry (const QString&, int iDefault );
virtual QStringList readListEntry (const QString&, const QStringList& defaultVal, char separator );
virtual QString readEntry (const QString&, const QString& );
};
QStringList safeStringSplit(const QString& s, char sepChar=',', char metaChar='\\' );
QString safeStringJoin(const QStringList& sl, char sepChar=',', char metaChar='\\' );
#endif
|