1 karl 1.8 //%2006////////////////////////////////////////////////////////////////////////
|
2 chuck 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 chuck 1.2 // 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 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.8 // 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.7 // Modified By: Aruran, IBM(ashanmug@in.ibm.com) for Bug# 3588
|
38 chuck 1.2 //
39 //%/////////////////////////////////////////////////////////////////////////////
40
41 #include "CQLChainedIdentifier.h"
42 #include "CQLChainedIdentifierRep.h"
43 #include <Pegasus/CQL/CQLFactory.h>
|
44 humberto 1.4 #include <Pegasus/Common/Tracer.h>
|
45 chuck 1.2 #include <Pegasus/Query/QueryCommon/QueryContext.h>
46 #include <Pegasus/Query/QueryCommon/QueryIdentifier.h>
47 #include <Pegasus/Query/QueryCommon/QueryException.h>
48
49 PEGASUS_NAMESPACE_BEGIN
50
51 CQLChainedIdentifierRep::CQLChainedIdentifierRep():
52 QueryChainedIdentifierRep()
53 {
54 }
55
|
56 aruran.ms 1.7 CQLChainedIdentifierRep::CQLChainedIdentifierRep(const String& inString):
|
57 chuck 1.2 QueryChainedIdentifierRep()
58 {
59 parse(inString);
60 }
61
62 CQLChainedIdentifierRep::CQLChainedIdentifierRep(const CQLIdentifier &id):
63 QueryChainedIdentifierRep()
64 {
65 _subIdentifiers.append(id);
66 }
67
68 CQLChainedIdentifierRep::CQLChainedIdentifierRep(const CQLChainedIdentifierRep* rep):
69 QueryChainedIdentifierRep()
70 {
71 _subIdentifiers = rep->_subIdentifiers;
72 }
73
74 CQLChainedIdentifierRep::~CQLChainedIdentifierRep(){
75
76 }
77
78 chuck 1.2 Array<CQLIdentifier> CQLChainedIdentifierRep::getSubIdentifiers()const
79 {
80 Array<CQLIdentifier> result;
81
82 for (Uint32 i = 0; i < _subIdentifiers.size(); i++)
83 {
84 result.append(CQLIdentifier(_subIdentifiers[i]));
85 }
86
87 return result;
88 }
89
90 CQLIdentifier CQLChainedIdentifierRep::getLastIdentifier()const{
91 if(_subIdentifiers.size() > 0)
92 return CQLIdentifier(_subIdentifiers[_subIdentifiers.size()-1]);
93 return CQLIdentifier();
94 }
95
96 CQLIdentifier CQLChainedIdentifierRep::operator[](Uint32 index)const
97 {
98 return CQLIdentifier(_subIdentifiers[index]);
99 chuck 1.2 }
100
101 CQLChainedIdentifierRep& CQLChainedIdentifierRep::operator=(const CQLChainedIdentifierRep& rhs){
102 if(&rhs != this){
103 _subIdentifiers = rhs._subIdentifiers;
104 }
105 return *this;
106 }
107
|
108 aruran.ms 1.7 void CQLChainedIdentifierRep::parse(const String & string){
|
109 humberto 1.3 PEG_METHOD_ENTER(TRC_CQL, "CQLChainedIdentifierRep::parse");
|
110 chuck 1.2 /*
111 - parse string on "."
112 - start from the end of string
113 - if more than one substring found,
114 -- store first found string then
115 -- prepend remaining substrings
116 */
117 Char16 delim('.');
118 Uint32 index;
119 String range;
120
121 index = string.reverseFind(delim);
122 if(index == PEG_NOT_FOUND){
123 _subIdentifiers.append(CQLIdentifier(string));
124 }else{
125 String tmp = string.subString(index+1);
126 _subIdentifiers.append(CQLIdentifier(tmp));
127
128 while(index != PEG_NOT_FOUND){
129 tmp = string.subString(0,index);
130 index = tmp.reverseFind(delim);
131 chuck 1.2 if(index == PEG_NOT_FOUND){
132 _subIdentifiers.prepend(CQLIdentifier(tmp));
133 }
134 else{
135 _subIdentifiers.prepend(CQLIdentifier(tmp.subString(index+1)));
136 }
137 }
138 }
|
139 humberto 1.3 PEG_METHOD_EXIT();
|
140 chuck 1.2 }
141
142 PEGASUS_NAMESPACE_END
|