1 martin 1.11 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.12 //
|
3 martin 1.11 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.12 //
|
10 martin 1.11 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.12 //
|
17 martin 1.11 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.12 //
|
20 martin 1.11 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.12 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.11 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.12 //
|
28 martin 1.11 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <cstdio>
33 #include "WQLOperand.h"
34
35 PEGASUS_NAMESPACE_BEGIN
36
|
37 kumpf 1.13 WQLOperand::WQLOperand() : _type(NULL_VALUE)
38 {
|
39 mike 1.2
40 }
41
42 WQLOperand::WQLOperand(const WQLOperand& x)
43 {
44 assign(x);
45 }
46
47 WQLOperand::~WQLOperand()
48 {
49 clear();
50 }
51
52 WQLOperand& WQLOperand::operator=(const WQLOperand& x)
53 {
54 clear();
55 assign(x);
56 return *this;
57 }
58
59 void WQLOperand::clear()
60 mike 1.2 {
61 if (_type == PROPERTY_NAME)
|
62 karl 1.10 ((String*)_propertyName)->~String();
|
63 mike 1.2 else if (_type == STRING_VALUE)
|
64 karl 1.10 ((String*)_stringValue)->~String();
|
65 mike 1.2
66 _type = NULL_VALUE;
67 }
68
69 void WQLOperand::assign(const WQLOperand& x)
70 {
71 switch (_type = x._type)
72 {
|
73 karl 1.10 case PROPERTY_NAME:
74 new(_propertyName) String(*((String*)x._propertyName));
75 break;
76
77 case STRING_VALUE:
78 new(_stringValue) String(*((String*)x._stringValue));
79 break;
80
81 case INTEGER_VALUE:
82 _integerValue = x._integerValue;
83 break;
84
85 case DOUBLE_VALUE:
86 _doubleValue = x._doubleValue;
87 break;
88
89 case BOOLEAN_VALUE:
90 _booleanValue = x._booleanValue;
91 break;
92
93 case NULL_VALUE:
94 karl 1.10 _integerValue = 0;
95 break;
|
96 mike 1.2 }
97 }
98
99 String WQLOperand::toString() const
100 {
101 String result;
102
103 switch (_type)
104 {
|
105 karl 1.10 case PROPERTY_NAME:
106 {
107 result = "PROPERTY_NAME: ";
108 result.append(*((String*)_propertyName));
109 break;
110 }
111
112 case STRING_VALUE:
113 {
114 result = "STRING_VALUE: ";
115 result.append(*((String*)_stringValue));
116 break;
117 }
118
119 case INTEGER_VALUE:
120 {
121 result = "INTEGER_VALUE: ";
122 char buffer[32];
|
123 kumpf 1.13 sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d",
|
124 w.otsuka 1.7 _integerValue);
|
125 karl 1.10 result.append(buffer);
126 break;
127 }
128
129 case DOUBLE_VALUE:
130 {
131 result = "DOUBLE_VALUE: ";
132 char buffer[32];
133 sprintf(buffer, "%f", _doubleValue);
134 result.append(buffer);
135 break;
|
136 kumpf 1.13 }
|
137 karl 1.10
138 case BOOLEAN_VALUE:
139 {
140 result = "BOOLEAN_VALUE: ";
141
142 if (_booleanValue)
143 result.append("TRUE");
144 else
145 result.append("FALSE");
146
147 break;
148 }
149
150 default:
151 result = "NULL_VALUE";
152 break;
|
153 mike 1.2 }
154
155 return result;
156 }
157
158 PEGASUS_NAMESPACE_END
|