1 karl 1.9 //%2005////////////////////////////////////////////////////////////////////////
|
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 chuck 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Authors: David Rosckes (rosckes@us.ibm.com)
31 // Bert Rivero (hurivero@us.ibm.com)
32 chuck 1.2 // Chuck Carmack (carmack@us.ibm.com)
33 // Brian Lucier (lucier@us.ibm.com)
34 //
|
35 aruran.ms 1.12 // Modified By: Aruran, IBM(ashanmug@in.ibm.com) for Bug# 3589
|
36 chuck 1.2 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 //#include "CQLIdentifier.h"
40 #include "CQLIdentifierRep.h"
41 #include <Pegasus/Query/QueryCommon/QueryIdentifierRep.h>
42 #include <Pegasus/Query/QueryCommon/QueryException.h>
|
43 humberto 1.3 #include <Pegasus/Common/Tracer.h>
|
44 chuck 1.2 PEGASUS_NAMESPACE_BEGIN
45
46
|
47 chuck 1.10 Char16 CQLIdentifierRep::STAR = '*';
48 Char16 CQLIdentifierRep::HASH = '#';
49 Char16 CQLIdentifierRep::RBRKT = ']';
50 Char16 CQLIdentifierRep::LBRKT = '[';
51 const char CQLIdentifierRep::SCOPE[] = "::";
|
52 chuck 1.2
53 CQLIdentifierRep::CQLIdentifierRep():
54 QueryIdentifierRep()
55 {
56
57 }
58
|
59 aruran.ms 1.12 CQLIdentifierRep::CQLIdentifierRep(const String& identifier):
|
60 chuck 1.2 QueryIdentifierRep()
61 {
62 _isWildcard = false;
63 _isSymbolicConstant = false;
64 parse(identifier);
65 }
66
67 CQLIdentifierRep::CQLIdentifierRep(const CQLIdentifierRep* rep):
68 QueryIdentifierRep()
69 {
70 _symbolicConstant = rep->_symbolicConstant;
71 _scope = rep->_scope;
72 _indices = rep->_indices;
73 _name = rep->_name;
74 _isWildcard = rep->_isWildcard;
75 _isSymbolicConstant = rep->_isSymbolicConstant;
76 }
77
78 CQLIdentifierRep::~CQLIdentifierRep()
79 {
80
81 chuck 1.2 }
82
83 CQLIdentifierRep& CQLIdentifierRep::operator=(const CQLIdentifierRep& rhs)
84 {
85 _symbolicConstant = rhs._symbolicConstant;
86 _scope = rhs._scope;
87 _indices = rhs._indices;
88 _name = rhs._name;
89 _isWildcard = rhs._isWildcard;
90 _isSymbolicConstant = rhs._isSymbolicConstant;
91 return *this;
92 }
93
94 void CQLIdentifierRep::parse(String identifier)
95 {
|
96 humberto 1.6 PEG_METHOD_ENTER(TRC_CQL, "CQLIdentifierRep::parse");
|
97 chuck 1.2 /*
98 - Parse for the following:
99 1. A::<scoped string>
100 (a) property name
101 (b) property[3] e.g. an array index
102 (c) property#'OK' e.g. a symbolic constant
103 (d) * (wildcard)
104 (e) class name
105 (f) embedded object
106 (g) namespace
107 */
108
109 Uint32 index;
110 Boolean hasCIMName = true;
111 if(identifier == String::EMPTY){
112 _name = CIMName();
113 return;
114 }
115 // basic error check
116 if((index = identifier.find(HASH)) != PEG_NOT_FOUND){
117 if(((index = identifier.find(RBRKT)) != PEG_NOT_FOUND) ||
118 chuck 1.2 ((index = identifier.find(LBRKT)) != PEG_NOT_FOUND))
119 {
120 //error
|
121 humberto 1.5 MessageLoaderParms parms(String("CQL.CQLIdentifier.HASH_ARRAY_SYMBOL_MISMATCH"),
122 String("The identifier contains a mismatched symbolic constant symbol and an array symbol: $0"),
123 identifier);
124 throw CQLIdentifierParseException(parms);
|
125 chuck 1.2 }
126 }
127
|
128 humberto 1.4 String _SCOPE(SCOPE);
129 if((index = identifier.find(_SCOPE)) != PEG_NOT_FOUND){
|
130 chuck 1.2 _scope = identifier.subString(0,index);
131 identifier = identifier.subString(index+2);
132 }
133
134 if((index = identifier.find(RBRKT)) != PEG_NOT_FOUND){
135 if((index = identifier.find(LBRKT)) != PEG_NOT_FOUND){
136 // found array index, parse for ','
137 String range = identifier.subString(index);
138 range = range.subString(1,range.size()-2); // remove left and right bracket
139 while(index != PEG_NOT_FOUND){
140 if((index = range.find(',')) != PEG_NOT_FOUND){
|
141 humberto 1.7 // Basic query error
142 MessageLoaderParms parms(String("CQL.CQLIdentifier.TOO_MANY_ARRAY_INDICES"),
143 String("The identifier contains one or more commas which is not allowed in CQL Basic query: $0"),
144 identifier);
145 throw CQLIdentifierParseException(parms);
146 //
147 // For basic query the following lines are disabled
148 // An exception is thrown if we have ',' in the array range
149 //
150 //_indices.append(SubRange(range.subString(0,index)));
151 //range = range.subString(index+1);
|
152 chuck 1.2 }else{
153 _indices.append(SubRange(range));
154 }
155 }
156 // remove ranges from identifier
157 identifier = identifier.subString(0,identifier.find(LBRKT));
158 }else{
159 // error
|
160 humberto 1.5 MessageLoaderParms parms(String("CQL.CQLIdentifier.ARRAY_SYMBOL_MISMATCH"),
161 String("The identifier contains a mismatched array symbol: $0"),
162 identifier);
163 throw CQLIdentifierParseException(parms);
|
164 chuck 1.2 }
165 }else if((index = identifier.find(STAR)) != PEG_NOT_FOUND){
166 // wildcard
167 _isWildcard = true;
168 }else if((index = identifier.find(HASH)) != PEG_NOT_FOUND){
169 // symbolic constant
170
171 // check if we only have a symbolic constant without a leading identifier
172 if(index == 0) hasCIMName = false;
173
174 _isSymbolicConstant = true;
175 _symbolicConstant = identifier.subString(index+1);
176 identifier = identifier.subString(0,index);
177 }
178
179 // name
180 if(!_isWildcard){
181 try{
182 if(hasCIMName)
183 _name = CIMName(identifier);
184 }catch(Exception e){
|
185 humberto 1.5 MessageLoaderParms parms(String("CQL.CQLIdentifier.INVALID_CIMNAME"),
186 String("The identifier contains an invalid CIMName: $0."),
187 identifier);
188 throw CQLIdentifierParseException(parms);
|
189 chuck 1.2 }
190 }
191
|
192 humberto 1.3 PEG_METHOD_EXIT();
193
|
194 chuck 1.2 }
195
196 PEGASUS_NAMESPACE_END
|