forked from cloudbase/EHS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datum.cpp
142 lines (122 loc) · 2.9 KB
/
datum.cpp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* $Id$
*
* EHS is a library for embedding HTTP(S) support into a C++ application
*
* Copyright (C) 2004 Zachary J. Hansen
*
* Code cleanup, new features and bugfixes: Copyright (C) 2010 Fritz Elfert
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This can be found in the 'COPYING' file.
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "datum.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
Datum & Datum::operator = ( const Datum & other )
{
sDatum = other.sDatum;
return *this;
}
Datum & Datum::operator= ( unsigned long inUL )
{
char psBuffer [ 100 ];
sprintf ( psBuffer, "%lu", inUL );
sDatum = psBuffer;
return *this;
}
Datum & Datum::operator= ( long inLong )
{
char psBuffer [ 100 ];
sprintf ( psBuffer, "%ld", inLong );
sDatum = psBuffer;
return *this;
}
Datum & Datum::operator= ( unsigned int inUI )
{
char psBuffer [ 100 ];
sprintf ( psBuffer, "%u", inUI );
sDatum = psBuffer;
return *this;
}
Datum & Datum::operator= ( int inInt )
{
char psBuffer [ 100 ];
sprintf ( psBuffer, "%d", inInt );
sDatum = psBuffer;
return *this;
}
Datum & Datum::operator= ( double inDouble )
{
char psBuffer [ 100 ];
sprintf ( psBuffer, "%f", inDouble );
sDatum = psBuffer;
return *this;
}
Datum & Datum::operator= ( std::string isString )
{
sDatum = isString;
return *this;
}
Datum & Datum::operator= ( char * ipsString )
{
sDatum = ipsString;
return *this;
}
Datum & Datum::operator= ( const char * ipsString )
{
sDatum = ipsString;
return *this;
}
bool Datum::operator== ( const char * ipsString )
{
return sDatum == ipsString;
}
Datum::operator unsigned long ( )
{
return strtoul ( sDatum.c_str ( ) , NULL, 10);
}
Datum::operator long ( )
{
return atol ( sDatum.c_str ( ) );
}
Datum::operator int ( )
{
return atoi ( sDatum.c_str ( ) );
}
Datum::operator double ( )
{
return atof ( sDatum.c_str ( ) );
}
Datum::operator std::string ( )
{
return sDatum;
}
Datum::operator const char * ( )
{
return sDatum.c_str ( );
}
bool Datum::operator!= ( int inCompare )
{
return ((int)*this) != inCompare;
}
bool Datum::operator != ( const char * ipsCompare )
{
return strcasecmp ( (const char*)*this, ipsCompare );
}