(file) Return to WQLOperand.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / WQL

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2