char* cc = (char*)theEntry.c_str();
int n = 0;
- std::vector<int> tags;
+ int i=0;
while (*cc != '\0') {
while ( *cc >= '0' && *cc <= '9') {
++cc;
}
if (*cc == ':' || *cc == '\0') {
- tags.push_back(n);
+ if(i>0)
+ {
+ if(aLabel.IsNull())break;
+ aLabel = aLabel.FindChild(n, isCreated);
+ }
+ i++;
n = 0;
if (*cc != '\0') ++cc;
}
else {
- tags.clear();
- break;
+ return DF_Label();
}
}
- if(!tags.size()) return DF_Label();
-
- for(int i = 1, len = tags.size(); !aLabel.IsNull() && i<len; i++)
- aLabel = aLabel.FindChild(tags[i], isCreated);
-
return aLabel;
}
{
if(!_node) return NULL;
- if(_node->_attributes.find(theID) == _node->_attributes.end()) return NULL;
- return _node->_attributes[theID];
+ std::map< std::string, DF_Attribute* >::iterator it=_node->_attributes.find(theID);
+ if(it == _node->_attributes.end()) return NULL;
+ return it->second;
+
}
//Returns true if there is an Attribute with given ID on this Label.
//Returns a string entry of this Label
std::string DF_Label::Entry() const
{
- std::string entry = "";
- std::vector<int> vi;
DF_LabelNode* father = this->_node;
- while(father) {
- vi.push_back(father->_tag);
- father = father->_father;
- }
-
- int len = vi.size();
- if(len == 1) {
- entry = "0:";
- }
- else {
- char buffer[128];
- for(int i = len-1; i>=0; i--) {
- int tag = vi[i];
- sprintf(buffer, "%d", tag);
- entry+=std::string(buffer);
- if(i) entry += ":";
+ if(!father->_father)return "0:";
+ int tag;
+ char buff[128];
+ char* wstr= buff;
+ char* str = buff;
+
+ while(father)
+ {
+ tag=father->_tag;
+ do{
+ // Conversion. Number is reversed.
+ *wstr++ = '0' + (tag % 10);
+ }while(tag /= 10);
+ father = father->_father;
+ if(father)*wstr++ = ':';
}
- }
+ *wstr-- = '\0';
+
+ //reverse the buffer
+ char aux;
+ while (wstr > str)
+ aux = *wstr, *wstr-- = *str, *str++ = aux;
- return entry;
+ return buff;
}
bool DF_Label::IsEqual(const DF_Label& theLabel)
#include "SALOMEDS_AttributeParameter_i.hxx"
#include "SALOMEDS_AttributeString_i.hxx"
-#define __CreateCORBAAttribute(CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+#define __CreateCORBAAttribute(CORBA_Name) else if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
SALOMEDSImpl_##CORBA_Name* A = dynamic_cast<SALOMEDSImpl_##CORBA_Name*>(theAttr); \
SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(A, theOrb); \
attr_servant = Attr; \
#define __CreateGenericCORBAAttribute \
+ if(0){} \
__CreateCORBAAttribute(AttributeReal) \
__CreateCORBAAttribute(AttributeInteger) \
__CreateCORBAAttribute(AttributeSequenceOfReal) \
SALOMEDSImpl_SObject aResult ;
// searching in the datamap for optimization
- if (myIORLabels.find(anObjectIOR) != myIORLabels.end()) {
- aResult = GetSObject(myIORLabels[anObjectIOR]);
+ std::map<std::string, DF_Label>::iterator it=myIORLabels.find(anObjectIOR);
+ if (it != myIORLabels.end()) {
+ aResult = GetSObject(it->second);
// 11 oct 2002: forbidden attributes must be checked here
if (!aResult.GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) {
myIORLabels.erase(anObjectIOR);
{
_errorCode = "";
DF_Label aLabel = DF_Label::Label(_doc->Main(), anEntry, true);
- if (myIORLabels.find(anIOR) != myIORLabels.end()) myIORLabels.erase(anIOR);
+ std::map<std::string, DF_Label>::iterator it=myIORLabels.find(anIOR);
+ if (it != myIORLabels.end()) myIORLabels.erase(it);
myIORLabels[anIOR] = aLabel;
}
void SALOMEDSImpl_Study::DeleteIORLabelMapItem(const std::string& anIOR)
{
- if (myIORLabels.find(anIOR) != myIORLabels.end())
+ std::map<std::string, DF_Label>::iterator it=myIORLabels.find(anIOR);
+ if (it != myIORLabels.end())
{
//remove the ior entry and decref the genericobj (if it's one)
- myIORLabels.erase(anIOR);
+ myIORLabels.erase(it);
}
}
SALOMEDSImpl_SObject SALOMEDSImpl_Study::GetSObject(const std::string& theEntry)
{
SALOMEDSImpl_SObject aSO;
- if(_mapOfSO.find(theEntry) != _mapOfSO.end())
- aSO = _mapOfSO[theEntry];
+ std::map<std::string, SALOMEDSImpl_SObject>::iterator it=_mapOfSO.find(theEntry);
+ if(it != _mapOfSO.end())
+ aSO = it->second;
else {
DF_Label aLabel = DF_Label::Label(_doc->Main(), theEntry);
aSO = SALOMEDSImpl_SObject(aLabel);