summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/globalstuff.h
blob: 7bc4173a3c9f1b3a8196cab4c8d1bbbd7a54414f (plain)
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
/***************************************************************************
 *                                                                         *
 *   copyright (C) 2003, 2004 by Michael Buesch                            *
 *   email: mbuesch@freenet.de                                             *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 * copyright (C) 2004 by Ulf Schenk
 * This file is originaly based on version 1.0.1 of pwmanager
 * and was modified to run on embedded devices that run microkde
 *
 * $Id$
 **************************************************************************/  

#ifndef __GLOBALSTUFF_H
#define __GLOBALSTUFF_H

#ifndef PWM_EMBEDDED
#include "config.h"
#endif

#include "compiler.h"

#include <string>
#include <sstream>

#ifndef CONFIG_KEYCARD
class QWidget;
void no_keycard_support_msg_box(QWidget *parentWidget);
#endif // CONFIG_KEYCARD

#ifdef PROG_NAME
# undef PROG_NAME
#endif
#define PROG_NAME	"PwManager"

#ifdef PACKAGE_NAME
# undef PACKAGE_NAME
#endif
#define PACKAGE_NAME	"pwmanager"

#ifdef PACKAGE_VER
# undef PACKAGE_VER
#endif
#define PACKAGE_VER	"1.0.1"

#ifdef CONFIG_DEBUG
# define PWM_DEBUG
#else
# undef PWM_DEBUG
#endif

#ifdef QT_MAKE_VERSION
# undef QT_MAKE_VERSION
#endif
#define QT_MAKE_VERSION(a,b,c)	(((a) << 16) | ((b) << 8) | (c))

/** remove "unused parameter" warnings */
#ifdef PARAM_UNUSED
# undef PARAM_UNUSED
#endif
#define PARAM_UNUSED(x)	(void)x

/** return the number of elements in an array */
#ifdef array_size
# undef array_size
#endif
#define array_size(x)	(sizeof(x) / sizeof((x)[0]))

/** convert something to string using ostringstream */
template <class T> inline
std::string tostr(const T &t)
{
	std::ostringstream s;
	s << t;
	return s.str();
}

/** delete the memory and NULL the pointer */
template<class T> inline
void delete_and_null(T *&p)
{
	delete p;
	p = 0;
}
/** delete the memory if the pointer isn't a NULL pointer */
template<class T> inline
void delete_ifnot_null(T *&p)
{
	if (p)
		delete_and_null(p);
}

template<class T> inline
void delete_and_null_array(T *&p)
{
	delete [] p;
	p = 0;
}

template<class T> inline
void delete_ifnot_null_array(T *&p)
{
	if (p)
		delete_and_null_array(p);
}

#endif // GLOBALSTUFF_H