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