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

  1 humberto 1.1.2.1 #include "CQLChainedIdentifier.h"
  2                  #include "CQLChainedIdentifierRep.h"
  3 humberto 1.1.2.2 #include <Pegasus/CQL/CQLFactory.h>
  4 humberto 1.1.2.1 PEGASUS_NAMESPACE_BEGIN
  5                  
  6 humberto 1.1.2.3 CQLChainedIdentifierRep::CQLChainedIdentifierRep(){
  7                  //	printf("CQLChainedIdentifier()\n");
  8                  }
  9                  
 10 humberto 1.1.2.1 CQLChainedIdentifierRep::CQLChainedIdentifierRep(String inString)
 11                  {
 12                  	parse(inString);
 13                  }
 14                  
 15                  CQLChainedIdentifierRep::CQLChainedIdentifierRep(CQLIdentifier &id)
 16                  {
 17                          _subIdentifiers.append(id);
 18 humberto 1.1.2.3 //	printf("CQLChainedIdentifier(CQLIdentifier &id)\n");
 19 humberto 1.1.2.1 }
 20                  
 21 humberto 1.1.2.3 CQLChainedIdentifierRep::CQLChainedIdentifierRep(const CQLChainedIdentifierRep* rep){
 22                  	_subIdentifiers = rep->_subIdentifiers;
 23                  //	printf("CQLChainedIdentifier COPY CONSTR\n");	
 24                  }
 25                  
 26                  CQLChainedIdentifierRep::~CQLChainedIdentifierRep(){
 27                  	
 28                  //	printf("~CQLChainedIdentifierRep()\n");
 29 humberto 1.1.2.1 }
 30                  
 31                  const Array<CQLIdentifier>& CQLChainedIdentifierRep::getSubIdentifiers()const
 32                  {
 33                  	return _subIdentifiers;
 34                  }
 35                  
 36                  CQLIdentifier CQLChainedIdentifierRep::getLastIdentifier(){
 37                  	if(_subIdentifiers.size() > 0)
 38                  		return _subIdentifiers[_subIdentifiers.size()-1];
 39                  	return CQLIdentifier();
 40                  }
 41                  
 42                  String CQLChainedIdentifierRep::toString()const{
 43                  	String s;
 44                  	for(Uint32 i = 0; i < _subIdentifiers.size(); i++){
 45                  		s.append(_subIdentifiers[i].toString());
 46                  		if(i < _subIdentifiers.size() - 1)
 47                  			s.append(".");
 48                  	}
 49                  	return s;
 50 humberto 1.1.2.1 }
 51                  
 52                  void CQLChainedIdentifierRep::append(CQLIdentifier & id){
 53                  	_subIdentifiers.append(id);
 54                  }
 55                  
 56                  Boolean CQLChainedIdentifierRep::isSubChain(CQLChainedIdentifier & chain){
 57                  	Array<CQLIdentifier> ids = chain.getSubIdentifiers();
 58                  	for(Uint32 i = 0; i < ids.size(); i++){
 59                  		if(ids[i] != _subIdentifiers[i].getName())
 60                  			return false;
 61                  	}
 62                  	return true;
 63                  }
 64                  
 65                  CQLIdentifier& CQLChainedIdentifierRep::operator[](Uint32 index){
 66                  	return _subIdentifiers[index];
 67                  }
 68                  
 69 humberto 1.1.2.3 CQLChainedIdentifierRep& CQLChainedIdentifierRep::operator=(const CQLChainedIdentifierRep& rhs){
 70                  	if(&rhs != this){
 71                  		_subIdentifiers = rhs._subIdentifiers;
 72                  //		printf("CQLChainedIdentifierRep::operator=\n");
 73                  	}
 74                  	return *this;
 75                  }
 76                  
 77 humberto 1.1.2.1 Uint32 CQLChainedIdentifierRep::size(){
 78                  	return _subIdentifiers.size();
 79                  }
 80                  
 81                  Boolean CQLChainedIdentifierRep::prepend(CQLIdentifier & id){
 82                  	/*
 83                  	   Compare id against the first element in _subIdentifiers, 
 84                  	   if not an exact match, then prepend.  This is used to fully
 85                  	   qualify the chained identifier.
 86                  	*/
 87                  	if(id != _subIdentifiers[0]){
 88                  		_subIdentifiers.prepend(id);
 89                  		return true;
 90                  	}
 91                  	return false;
 92                  }
 93                  
 94 chuck    1.1.2.4 void CQLChainedIdentifierRep::applyContext(QueryContext& inContext)
 95                  {
 96                    // ATTN - Fill this in
 97 humberto 1.1.2.1 }
 98                  
 99                  void CQLChainedIdentifierRep::parse(String & string){
100                  	/* 
101                  	  - parse string on "."
102                  	  - start from the end of string
103                  	  - if more than one substring found, 
104                  		-- store first found string then
105                  		-- prepend remaining substrings 
106                  	*/
107                  	Char16 delim('.');
108                  	Uint32 index;
109                  	String range;
110                  
111                  	/* remove any array ranges so we dont parse a false . */
112                  	if((index = string.find("[")) != PEG_NOT_FOUND){
113                  		range = string.subString(index);
114                  		string.remove(index);
115                  	}
116                  
117                  	index = string.reverseFind(delim);
118 humberto 1.1.2.1 	if(index == PEG_NOT_FOUND){
119                  		/* append the range we may have removed */
120                  		string.append(range);
121                  		_subIdentifiers.append(CQLIdentifier(string));
122                  	}else{
123                  		/* append the range we may have removed */
124                  		String tmp = string.subString(index+1);
125                  		tmp.append(range);
126                  		PEGASUS_STD(cout) << "tmp = " << tmp << PEGASUS_STD(endl);
127                  		_subIdentifiers.append(CQLIdentifier(tmp));
128                  
129                  		while(index != PEG_NOT_FOUND){
130                  			tmp = string.subString(0,index);
131                  			index = tmp.reverseFind(delim);
132                  			if(index == PEG_NOT_FOUND){
133                  				_subIdentifiers.prepend(CQLIdentifier(tmp));
134                  			}
135                  			else{
136                  				_subIdentifiers.prepend(CQLIdentifier(tmp.subString(index+1)));
137                  			}
138                  		}
139 humberto 1.1.2.1 	}
140                  }
141                  
142                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2