Changeset 106 for XMLIO_V2/dev/dev_rv/src/XMLIO
- Timestamp:
- 06/14/10 15:32:15 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut_registrar.hpp
r104 r106 3 3 4 4 #include "attribut.hpp" 5 6 using XMLIOSERVER::XML::THashAttributes; 5 7 6 8 namespace XMLIOSERVER … … 14 16 15 17 void RegisterAttribut(BaseAttribut* attribut){ attrList.addObject(attribut); } 16 StrHashMap<BaseAttribut>& getAttributList(void){ return (attrList); }18 const StrHashMap<BaseAttribut>& getAttributList(void) const { return (attrList); } 17 19 size_t getNbAttributes() const {return (attrList.getSize()); } 18 bool hasAttribut(const string _id) { return (attrList.hasMappedValue(_id)); }20 bool hasAttribut(const string& _id) { return (attrList.hasMappedValue(_id)); } 19 21 20 BaseAttribut* getAttribut(const string _id) throw (XMLIOUndefinedValueException) { return (attrList[_id]); } 22 BaseAttribut* getAttribut(const string& _id) throw (XMLIOUndefinedValueException) { return (attrList[_id]); } 23 24 friend ostream& operator<< (ostream& out, const AttributRegistrar& c) 25 { 26 for(unsigned int i = 0; i < c.attrList.getVectorSize(); i++) out << *c.attrList.getVector()[i]; 27 return (out); 28 } 29 30 31 void setAttributes(const THashAttributes& _attr) 32 { 33 for (THashAttributes::ConstIterator it = _attr.begin(); it != _attr.end(); it++) 34 if ((*it).first.compare(string("id"))!= 0 and (*it).first.compare(string("src"))!=0) 35 // (Au dessus) Non prise en compte de l'identifiant et de l'inclusion de fichiers externes lors de l'affectation des attributs. 36 this->setSAttribut((*it).first, (*it).second); 37 return; 38 } 39 40 void addAttributes(const AttributRegistrar& _parent) 41 { 42 const StrHashMap<BaseAttribut>& _pattr = _parent.getAttributList(); 43 const StrHashMap<BaseAttribut>& _lattr = getAttributList(); 44 //_pattr contient les attributs du parent, _lattr les attributs locaux. 45 46 for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 47 { 48 if(_lattr.getVector()[i]->_hasValue() or !_pattr.getVector()[i]->_hasValue()) continue; 49 _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 50 } 51 } 21 52 22 53 void setSAttribut(const string& att_name, const std::string& value) -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r105 r106 9 9 public: 10 10 11 Context(void) : ObjectTemplate<Context>(), fieldDef(NULL) 11 Context(void) : ObjectTemplate<Context>(), fieldDef(NULL), fileDef(NULL) 12 12 {/* Ne rien faire de plus */} 13 Context(const string& _id) : ObjectTemplate<Context>(_id), fieldDef(NULL) 13 Context(const string& _id) : ObjectTemplate<Context>(_id), fieldDef(NULL), fileDef(NULL) 14 14 {/* Ne rien faire de plus */} 15 15 … … 18 18 // On modifie le context courrant pour tout les ObjectTemplate 19 19 Context::SetContext(id); 20 21 // Changement de context pour les champs et groupes de champs. 20 22 FieldGroup::SetContext(id); 21 Field::SetContext(id); 23 CField::SetContext(id); 24 25 // Changement de context pour les champs et groupes de champs. 26 FileGroup::SetContext(id); 27 CFile::SetContext(id); 22 28 } 23 29 … … 25 31 { 26 32 out << IncIndent << "<" << c.getName()<< " id=\"" << c.getId() << "\">" << std::endl; 33 27 34 if(c.fieldDef != NULL) out << *(FieldGroup*)c.fieldDef << std::endl; 35 if(c.fileDef != NULL) out << *(FileGroup*) c.fileDef << std::endl; 36 28 37 out << NIndent << "</" << c.getName()<< ">" << DecEndl; 29 38 return (out); … … 34 43 // Résolution des héritages descendants pour chacun des groupes de définitions. 35 44 if(fieldDef != NULL) fieldDef->resolveDescInheritance(); 45 if(fileDef != NULL) fileDef->resolveDescInheritance(); 36 46 } 37 47 … … 70 80 } 71 81 else if (name.compare("file_definition") == 0) 72 { // Parsing pour la définition des fichiers. 73 INFO("Le parsing des définitions de fichiers n'est pas encore implémenté"); 82 { // Parsing pour la définition des fichiers. 83 84 if (FileDefinition::HasObject("file_definition")) 85 WARNING("Le context possÚde déjà un noeud de définition de fichiers, le dernier défini complétera le premier !"); 86 87 fileDef = (FileDefinition*)&FileDefinition::CreateObject("file_definition"); // << Conversion possible car la classe Field n'a pas de propriétés. 88 fileDef->parse(_node); 89 90 continue; 74 91 } 75 92 else if (name.compare("axis_definition") == 0) … … 97 114 98 115 FieldDefinition* getFieldDefinition(void) { return (this->fieldDef); } 116 FileDefinition* getFileDefinition(void) { return (this->fileDef); } 99 117 100 118 ~Context() 101 { if(fieldDef != NULL) delete fieldDef; } 119 { 120 if(fieldDef != NULL) delete fieldDef; 121 if(fileDef != NULL) delete fileDef; 122 } 102 123 103 124 … … 105 126 106 127 FieldDefinition* fieldDef; 107 /*FileDefinition*fileDef;108 AxisDefinition* axisDef;128 FileDefinition* fileDef; 129 /*AxisDefinition* axisDef; 109 130 GridDefinition* gridDef;*/ 110 131 -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r105 r106 7 7 namespace XMLIOSERVER 8 8 { 9 class Field : public ObjectTemplate<Field>, public FieldAttribut9 class CField : public ObjectTemplate<CField>, public FieldAttribut 10 10 { 11 11 public: 12 12 13 Field(void) : ObjectTemplate<Field>(), FieldAttribut()13 CField(void) : ObjectTemplate<CField>(), FieldAttribut() 14 14 {/* Ne rien faire de plus */} 15 Field(const string& _id) : ObjectTemplate<Field>(_id), FieldAttribut()15 CField(const string& _id) : ObjectTemplate<CField>(_id), FieldAttribut() 16 16 {/* Ne rien faire de plus */} 17 17 18 friend ostream& operator<< (ostream& out, const Field& c)18 friend ostream& operator<< (ostream& out, const CField& c) 19 19 { 20 out << IncIndent << "<" << c.getName(); 21 if(c.hasId()) out << " id=\"" << c.getId() << "\""; 22 for(unsigned int i = 0; i < c.attrList.getVectorSize(); i++) out << *c.attrList.getVector()[i]; 23 out << "/>" << DecEndl; 24 20 const AttributRegistrar &ar = c; 21 out << IncIndent << "<" << c.getName() << c.printId() << ar << "/>" << DecEndl; 25 22 return (out); 26 23 } 27 28 void setAttributes(const THashAttributes& _attr) 29 { 30 for (THashAttributes::ConstIterator it = _attr.begin(); it != _attr.end(); it++) 31 if ((*it).first.compare(string("id"))) 32 // Non prise en compte de l'identifiant lors de l'affectation des attributs. 33 this->setSAttribut((*it).first, (*it).second); 34 } 35 36 void addAttributes(const StrHashMap<BaseAttribut>& _pattr) 37 { 38 StrHashMap<BaseAttribut>& _lattr = getAttributList(); 39 40 //_pattr contient les attributs du parent, _lattr les attributs locaux. 41 42 for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 43 { 44 if(_lattr.getVector()[i]->_hasValue() or !_pattr.getVector()[i]->_hasValue()) continue; 45 _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 46 } 47 } 48 24 49 25 const char* getName(void) const {return ("Field"); } 50 26 … … 65 41 } 66 42 67 ~ Field(void)43 ~CField(void) 68 44 { /* Ne rien faire de plus */ } 69 45 -
XMLIO_V2/dev/dev_rv/src/XMLIO/field_attribut.hpp
r104 r106 50 50 } 51 51 52 } ; // class CFieldAttribut52 } ; // class FieldAttribut 53 53 54 54 }// namespace XMLIOSERVER -
XMLIO_V2/dev/dev_rv/src/XMLIO/field_group.hpp
r105 r106 2 2 #define __FIELD_GROUP__ 3 3 4 5 using XMLIOSERVER::XML::THashAttributes;6 7 4 namespace XMLIOSERVER 8 5 { 9 class FieldGroup : public GroupTemplate< Field, FieldAttribut>6 class FieldGroup : public GroupTemplate<CField, FieldAttribut> 10 7 { 11 8 public: 12 9 13 FieldGroup(void) : GroupTemplate< Field, FieldAttribut>()10 FieldGroup(void) : GroupTemplate<CField, FieldAttribut>() 14 11 {/* Ne rien faire de plus */} 15 FieldGroup(const string& _id) : GroupTemplate< Field, FieldAttribut>(_id)12 FieldGroup(const string& _id) : GroupTemplate<CField, FieldAttribut>(_id) 16 13 {/* Ne rien faire de plus */} 17 18 void setAttributes(const THashAttributes& _attr) 19 { 20 for (THashAttributes::ConstIterator it = _attr.begin(); it != _attr.end(); it++) 21 if ((*it).first.compare(string("id"))!= 0 and (*it).first.compare(string("src"))!=0) 22 // (Au dessus) Non prise en compte de l'identifiant et de l'inclusion de fichiers externes lors de l'affectation des attributs. 23 this->setSAttribut((*it).first, (*it).second); 24 25 return; 26 } 27 14 28 15 const char* getName(void) const {return ("Field_Group"); } 29 16 17 18 /// TODO A remonter dans l'arbre des héritages 30 19 friend ostream& operator<< (ostream& out, const FieldGroup& c) 31 { 32 out << IncIndent << "<" << c.getName(); 33 if(c.hasId()) out << " id=\"" << c.getId() << "\""; 34 for(unsigned int i = 0; i < c.attrList.getVectorSize(); i++) out << *c.attrList.getVector()[i]; 35 out << ">" << std::endl; 20 { 21 const AttributRegistrar &ar = c; 22 out << IncIndent << "<" << c.getName() << c.printId() << ar << ">" << std::endl; 36 23 37 24 // Ecriture des sous-groupes. 38 25 for(unsigned int i = 0; i < c.groupList.getVector().size() ; i++) 39 26 out << *((FieldGroup*)c.groupList.getVector()[i]) << std::endl; 40 27 28 // Ecriture des enfants. 41 29 for(unsigned int i = 0; i < c.childList.getVector().size() ; i++) 42 30 out << *(c.childList.getVector()[i]) << std::endl; 43 31 44 32 out << NIndent << "</" << c.getName()<< ">" << DecEndl; 33 45 34 return (out); 46 } 47 48 void addAttributes(const StrHashMap<BaseAttribut>& _pattr) 49 { 50 StrHashMap<BaseAttribut>& _lattr = getAttributList(); 51 52 //_pattr contient les attributs du parent, _lattr les attributs locaux. 53 54 for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 55 { 56 if(_lattr.getVector()[i]->_hasValue() or !_pattr.getVector()[i]->_hasValue()) continue; 57 _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 58 } 59 } 35 } 60 36 61 void resolveDescInheritance(StrHashMap<BaseAttribut>* _pattr = 0) 37 /// TODO A remonter dans l'arbre des héritages 38 void resolveDescInheritance(const AttributRegistrar* _parent = 0) 62 39 { 63 const vector< Field*>& childvect = childList.getVector();64 const vector<GroupTemplate< Field, FieldAttribut>*>& groupvect = groupList.getVector();40 const vector<CField*>& childvect = childList.getVector(); 41 const vector<GroupTemplate<CField, FieldAttribut>*>& groupvect = groupList.getVector(); 65 42 66 43 // On complÚte les propres attributs du groupe. 67 if (_pa ttr!= NULL) addAttributes(*_pattr);44 if (_parent!= NULL) addAttributes(*_parent); 68 45 69 46 for(unsigned int i = 0; i < childvect.size() ; i++) 70 47 // on complÚte les attributs des champs enfants 71 childvect[i] -> addAttributes( this->attrList);48 childvect[i] -> addAttributes(*this); 72 49 73 50 for(unsigned int i = 0; i < groupvect.size() ; i++) 74 51 // on complÚte les attributs des groupes de champs enfants 75 ((FieldGroup*)groupvect[i]) -> resolveDescInheritance( &this->attrList);52 ((FieldGroup*)groupvect[i]) -> resolveDescInheritance(this); 76 53 } 77 54 78 void parse (XMLNode& _node )55 void parse (XMLNode& _node, bool _withAttr = true) 79 56 { 80 57 string name = _node.getElementName(); … … 82 59 83 60 /// PARSING GESTION DES ATTRIBUTS /// 84 _node.getAttributes(attributes); 85 this->setAttributes(attributes); 86 87 if (attributes.end() != attributes.find("src")) 88 { // Si une demande d'inclusion de fichier est trouvé. 89 XMLNode _node_inc = getNodeIncludedFile(attributes["src"], name); 90 parse (_node_inc); 61 if (_withAttr) 62 { 63 _node.getAttributes(attributes); 64 this->setAttributes(attributes); 65 66 if (attributes.end() != attributes.find("src")) 67 { // Si une demande d'inclusion de fichier est trouvé. 68 XMLNode _node_inc = getNodeIncludedFile(attributes["src"], name); 69 parse (_node_inc); 70 } 71 72 attributes.clear(); 91 73 } 92 93 attributes.clear();94 74 95 75 /// PARSING POUR GESION DES ENFANTS … … 121 101 fgroup = (FieldGroup*)(&createGroup()); 122 102 fgroup->parse(_node); 123 } 124 103 } 125 104 continue; 126 105 127 106 } 128 107 else if (name.compare("field") == 0) 129 { // Parsing pour les champs 108 { // Parsing pour les champs. 130 109 131 Field* field = NULL;110 CField* field = NULL; 132 111 133 112 if (attributes.end() != attributes.find("id")) 134 113 {// Si l'identifiant est défini. 135 if ( Field::HasObject(attributes["id"]))114 if (CField::HasObject(attributes["id"])) 136 115 WARNING("Dans le context actuel, un champ du même nom existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 137 field = ( Field*)(&createChild(attributes["id"]));116 field = (CField*)(&createChild(attributes["id"])); 138 117 field->parse(_node); 139 118 } 140 119 else 141 120 {// Si l'identifiant n'est pas défini. 142 field = ( Field*)(&createChild());121 field = (CField*)(&createChild()); 143 122 field->parse(_node); 144 } 145 123 } 146 124 continue; 147 125 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/main_cpp.cpp
r105 r106 11 11 try 12 12 { 13 string file("/local/svn/dev_rv/test/iodef_test.xml"); 13 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml"); 14 15 //string file("/local/XMLIOSERVER_DEV/dev_rv/iodef_test.xml"); 14 16 ifstream istr( file.c_str() , ifstream::in ); 15 17 -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r98 r106 27 27 #include "xmlio_xml_node.hpp" 28 28 #include "xmlio_object_template.hpp" 29 29 30 #include "field_attribut.hpp" 30 #include "field.hpp" 31 #include "xmlio_group_template.hpp" 32 #include "field_group.hpp" 31 #include "file_attribut.hpp" 32 33 #include "field.hpp" 34 35 36 #include "xmlio_group_template.hpp" 37 #include "field_group.hpp" 38 39 #include "file.hpp" 40 #include "file_group.hpp" 41 33 42 #include "context.hpp" 34 43 #include "xmlio_xml_parser.hpp" 35 44 36 37 45 #endif // __XMLIO__ -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_container.hpp
r104 r106 28 28 { 29 29 if(!hasMappedValue(kval)) 30 throw XMLIOUndefinedValueException("Appel de la méthode ExHashMap::operator[ ] invalide.");30 throw XMLIOUndefinedValueException("Appel de la méthode ExHashMap::operator["+kval+"] invalide."); 31 31 return (find(kval)->second); 32 32 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_group_template.hpp
r104 r106 13 13 GroupTemplate(const string& _id) : ObjectTemplate<GroupTemplate<T, U> >(_id), U(), childList(), groupList() 14 14 {/* Ne rien faire de plus */} 15 15 16 16 /// Pour les groupes d'objets enfants /// 17 17 -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_logger.hpp
r105 r106 51 51 // Initialisation de la classe de Logging 52 52 static ILogger LOGGER("xmlio.log"); 53 53 54 ///////////////////////////////////////////////////////////////////// 54 55 static unsigned int Indent; 55 56 … … 57 58 { for(unsigned int i = 0; i < Indent; i++) out << " "; return(out); } 58 59 59 std::ostream& IncIndent(std::ostream& out) 60 { Indent++; return (NIndent(out)); } 61 62 std::ostream& DecEndl(std::ostream& out) 63 { Indent--; return (NIndent(out)); } 60 std::ostream& IncIndent(std::ostream& out) { Indent++; return (NIndent(out)); } 61 std::ostream& DecEndl(std::ostream& out) { Indent--; return (NIndent(out)); } 62 ///////////////////////////////////////////////////////////////////// 64 63 65 64 /************* POUR MEMOIRE ********************** -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_object.hpp
r104 r106 33 33 bool operator==(const AbstractObject& other) 34 34 { 35 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets dene sont pas "égaux".35 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux". 36 36 if(!this->hasId() or !other.hasId()) return false; 37 37 return (id.compare(other.id) == 0); 38 38 } 39 40 string printId(void) const 41 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 39 42 40 43 virtual ~AbstractObject(void) -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_xml_node.hpp
r104 r106 61 61 { 62 62 XMLNode node(_rootName); 63 if ( (_istr.good()))63 if (_istr.good()) 64 64 { // S'il est possible de lire le flux en entrée ... 65 65 InputSource src(_istr); -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_xml_parser.hpp
r105 r106 83 83 string& id = (*it).first; 84 84 StrHashMap<Context>& sc = (*it).second; 85 Context::SetCurrentContext(id); 85 86 delete sc[id]; 86 87 }
Note: See TracChangeset
for help on using the changeset viewer.