1 karl 1.9 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.6 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.5 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.6 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.8 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.9 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.3 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.3 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.3 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #include <cstdio>
39 #include "WQLOperand.h"
40
41 PEGASUS_NAMESPACE_BEGIN
42
43 WQLOperand::WQLOperand() : _type(NULL_VALUE)
44 {
45
46 }
47
48 mike 1.2 WQLOperand::WQLOperand(const WQLOperand& x)
49 {
50 assign(x);
51 }
52
53 WQLOperand::~WQLOperand()
54 {
55 clear();
56 }
57
58 WQLOperand& WQLOperand::operator=(const WQLOperand& x)
59 {
60 clear();
61 assign(x);
62 return *this;
63 }
64
65 void WQLOperand::clear()
66 {
67 if (_type == PROPERTY_NAME)
68 ((String*)_propertyName)->~String();
69 mike 1.2 else if (_type == STRING_VALUE)
70 ((String*)_stringValue)->~String();
71
72 _type = NULL_VALUE;
73 }
74
75 void WQLOperand::assign(const WQLOperand& x)
76 {
77 switch (_type = x._type)
78 {
79 case PROPERTY_NAME:
80 new(_propertyName) String(*((String*)x._propertyName));
81 break;
82
83 case STRING_VALUE:
84 new(_stringValue) String(*((String*)x._stringValue));
85 break;
86
87 case INTEGER_VALUE:
88 _integerValue = x._integerValue;
89 break;
90 mike 1.2
91 case DOUBLE_VALUE:
92 _doubleValue = x._doubleValue;
93 break;
94
95 case BOOLEAN_VALUE:
96 _booleanValue = x._booleanValue;
97 break;
98
99 case NULL_VALUE:
100 _integerValue = 0;
101 break;
102 }
103 }
104
105 String WQLOperand::toString() const
106 {
107 String result;
108
109 switch (_type)
110 {
111 mike 1.2 case PROPERTY_NAME:
112 {
113 result = "PROPERTY_NAME: ";
|
114 kumpf 1.4 result.append(*((String*)_propertyName));
|
115 mike 1.2 break;
116 }
117
118 case STRING_VALUE:
119 {
120 result = "STRING_VALUE: ";
|
121 kumpf 1.4 result.append(*((String*)_stringValue));
|
122 mike 1.2 break;
123 }
124
125 case INTEGER_VALUE:
126 {
127 result = "INTEGER_VALUE: ";
128 char buffer[32];
|
129 w.otsuka 1.7 sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d",
130 _integerValue);
|
131 kumpf 1.4 result.append(buffer);
|
132 mike 1.2 break;
133 }
134
135 case DOUBLE_VALUE:
136 {
137 result = "DOUBLE_VALUE: ";
138 char buffer[32];
139 sprintf(buffer, "%f", _doubleValue);
|
140 kumpf 1.4 result.append(buffer);
|
141 mike 1.2 break;
142 }
143
144 case BOOLEAN_VALUE:
145 {
146 result = "BOOLEAN_VALUE: ";
147
148 if (_booleanValue)
|
149 kumpf 1.4 result.append("TRUE");
|
150 mike 1.2 else
|
151 kumpf 1.4 result.append("FALSE");
|
152 mike 1.2
153 break;
154 }
155
156 default:
157 result = "NULL_VALUE";
158 break;
159 }
160
161 return result;
162 }
163
164 PEGASUS_NAMESPACE_END
|