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

  1 karl  1.13 //%2006////////////////////////////////////////////////////////////////////////
  2 chuck 1.2  //
  3 karl  1.9  // 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 chuck 1.2  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.9  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9            // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 chuck 1.2  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // 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            // 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            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // 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            // 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            // 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            // Authors: David Rosckes (rosckes@us.ibm.com)
 33            //          Bert Rivero (hurivero@us.ibm.com)
 34 chuck 1.2  //          Chuck Carmack (carmack@us.ibm.com)
 35            //          Brian Lucier (lucier@us.ibm.com)
 36            //
 37 aruran.ms 1.12 // Modified By: Aruran, IBM(ashanmug@in.ibm.com) for Bug# 3589
 38 chuck     1.2  //
 39                //%/////////////////////////////////////////////////////////////////////////////
 40                
 41                //#include "CQLIdentifier.h"
 42                #include "CQLIdentifierRep.h"
 43                #include <Pegasus/Query/QueryCommon/QueryIdentifierRep.h>
 44                #include <Pegasus/Query/QueryCommon/QueryException.h>
 45 humberto  1.3  #include <Pegasus/Common/Tracer.h>
 46 chuck     1.2  PEGASUS_NAMESPACE_BEGIN
 47                
 48                
 49 chuck     1.10 Char16 CQLIdentifierRep::STAR = '*';
 50                Char16 CQLIdentifierRep::HASH = '#';
 51                Char16 CQLIdentifierRep::RBRKT = ']';
 52                Char16 CQLIdentifierRep::LBRKT = '[';
 53                const char CQLIdentifierRep::SCOPE[] = "::";
 54 chuck     1.2  
 55                CQLIdentifierRep::CQLIdentifierRep(): 
 56                  QueryIdentifierRep()
 57                {
 58                
 59                }
 60                
 61 aruran.ms 1.12 CQLIdentifierRep::CQLIdentifierRep(const String& identifier): 
 62 chuck     1.2    QueryIdentifierRep()
 63                {
 64                  _isWildcard = false;
 65                  _isSymbolicConstant = false;
 66                	parse(identifier);
 67                }
 68                
 69                CQLIdentifierRep::CQLIdentifierRep(const CQLIdentifierRep* rep):
 70                  QueryIdentifierRep()
 71                {
 72                	_symbolicConstant = rep->_symbolicConstant;
 73                   _scope = rep->_scope;
 74                   _indices = rep->_indices;
 75                   _name = rep->_name;
 76                   _isWildcard = rep->_isWildcard;
 77                   _isSymbolicConstant = rep->_isSymbolicConstant;
 78                }
 79                
 80                CQLIdentifierRep::~CQLIdentifierRep()
 81                {
 82                
 83 chuck     1.2  }
 84                
 85                CQLIdentifierRep& CQLIdentifierRep::operator=(const CQLIdentifierRep& rhs)
 86                {
 87                	_symbolicConstant = rhs._symbolicConstant;
 88                   _scope = rhs._scope;
 89                   _indices = rhs._indices; 
 90                   _name = rhs._name;
 91                   _isWildcard = rhs._isWildcard;
 92                   _isSymbolicConstant = rhs._isSymbolicConstant;
 93                	return *this;
 94                }
 95                
 96                void CQLIdentifierRep::parse(String identifier)
 97                {
 98 humberto  1.6  PEG_METHOD_ENTER(TRC_CQL, "CQLIdentifierRep::parse");
 99 chuck     1.2  	/*
100                	 - Parse for the following:
101                         1. A::<scoped string>
102                	 (a)  property name
103                         (b)  property[3]     e.g. an array index
104                         (c)  property#'OK'    e.g. a symbolic constant
105                         (d)  *   (wildcard)
106                	 (e)  class name
107                	 (f)  embedded object
108                	 (g)  namespace
109                	*/
110                
111                	Uint32 index;
112                	Boolean hasCIMName = true;
113                	if(identifier == String::EMPTY){
114                		_name = CIMName();
115                		return;	
116                	}
117                	// basic error check
118                	if((index = identifier.find(HASH)) != PEG_NOT_FOUND){
119                		if(((index = identifier.find(RBRKT)) != PEG_NOT_FOUND) || 
120 chuck     1.2  			((index = identifier.find(LBRKT)) != PEG_NOT_FOUND))	
121                		{
122                			//error
123 humberto  1.5  			MessageLoaderParms parms(String("CQL.CQLIdentifier.HASH_ARRAY_SYMBOL_MISMATCH"),
124                                			         String("The identifier contains a mismatched symbolic constant symbol and an array symbol: $0"),
125                                                	         identifier);
126                			throw CQLIdentifierParseException(parms);
127 chuck     1.2  		}
128                	}
129                
130 humberto  1.4  	String _SCOPE(SCOPE);
131                	if((index = identifier.find(_SCOPE)) != PEG_NOT_FOUND){
132 chuck     1.2  		_scope = identifier.subString(0,index);
133                		identifier = identifier.subString(index+2);
134                	}
135                
136                	if((index = identifier.find(RBRKT)) != PEG_NOT_FOUND){
137                		if((index = identifier.find(LBRKT)) != PEG_NOT_FOUND){
138                		  // found array index, parse for ','
139                		  String range = identifier.subString(index);
140                		  range = range.subString(1,range.size()-2);  // remove left and right bracket
141                		  while(index != PEG_NOT_FOUND){
142                			if((index = range.find(',')) != PEG_NOT_FOUND){
143 humberto  1.7  				// Basic query error
144                                        	MessageLoaderParms parms(String("CQL.CQLIdentifier.TOO_MANY_ARRAY_INDICES"),
145                                                                 String("The identifier contains one or more commas which is not allowed in CQL Basic query: $0"),
146                                                                 identifier);
147                                        	throw CQLIdentifierParseException(parms);
148                				// 
149                				// For basic query the following lines are disabled
150                				// An exception is thrown if we have ',' in the array range
151                				//
152                				//_indices.append(SubRange(range.subString(0,index)));
153                				//range = range.subString(index+1);
154 chuck     1.2  			}else{
155                				_indices.append(SubRange(range));
156                			}
157                		  }
158                		  // remove ranges from identifier
159                		  identifier = identifier.subString(0,identifier.find(LBRKT));
160                		}else{
161                		  // error
162 humberto  1.5  			MessageLoaderParms parms(String("CQL.CQLIdentifier.ARRAY_SYMBOL_MISMATCH"),
163                				                 String("The identifier contains a mismatched array symbol: $0"),
164                                                                 identifier);
165                			throw CQLIdentifierParseException(parms);
166 chuck     1.2  		}
167                	}else if((index = identifier.find(STAR)) != PEG_NOT_FOUND){
168                		// wildcard
169                		_isWildcard = true;
170                	}else if((index = identifier.find(HASH)) != PEG_NOT_FOUND){
171                		// symbolic constant
172                
173                		// check if we only have a symbolic constant without a leading identifier
174                		if(index == 0) hasCIMName = false;
175                
176                		_isSymbolicConstant = true;
177                		_symbolicConstant = identifier.subString(index+1);
178                		identifier = identifier.subString(0,index);
179                	}
180                
181                	// name
182                	if(!_isWildcard){
183                		try{
184                			if(hasCIMName)
185                				_name = CIMName(identifier);
186                		}catch(Exception e){
187 humberto  1.5  			MessageLoaderParms parms(String("CQL.CQLIdentifier.INVALID_CIMNAME"),
188                				                 String("The identifier contains an invalid CIMName: $0."),
189                                                                 identifier);
190                			throw CQLIdentifierParseException(parms);
191 chuck     1.2  		}
192                	}
193                	
194 humberto  1.3  PEG_METHOD_EXIT();
195                
196 chuck     1.2  }
197                
198                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2