Changeset 171 for XMLIO_V2/dev/dev_rv/src
- Timestamp:
- 04/12/11 11:48:48 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/xmlio
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/array_impl.hpp
r152 r171 77 77 shape.push_back(temp); 78 78 } 79 this->res hape(shape);79 this->resize(shape); 80 80 is.read (reinterpret_cast<char*>(&nelem), sizeof(LSize)); 81 81 is.read (reinterpret_cast<char*>(this->data()), nelem * sizeof(ValueType)); -
XMLIO_V2/dev/dev_rv/src/xmlio/attribute_map.cpp
r152 r171 14 14 CAttributeMap::~CAttributeMap(void) 15 15 { /* Ne rien faire de plus */ } 16 16 17 ///-------------------------------------------------------------- 18 17 19 bool CAttributeMap::hasAttribute(const StdString & key) const 18 { return (this->find(key) != this->end()); } 19 20 { 21 return (this->find(key) != this->end()); 22 } 23 24 //--------------------------------------------------------------- 25 20 26 void CAttributeMap::setAttribute(const StdString & key, CAttribute * const attr) 21 27 { … … 28 34 this->find(key)->second->setAnyValue(attr->getAnyValue()); 29 35 } 30 36 37 //--------------------------------------------------------------- 38 31 39 CAttribute * CAttributeMap::operator[](const StdString & key) 32 40 { … … 36 44 return (SuperClassMap::operator[](key)); 37 45 } 38 46 47 //--------------------------------------------------------------- 48 39 49 StdString CAttributeMap::toString(void) const 40 50 { … … 51 61 return (oss.str()); 52 62 } 53 63 64 //--------------------------------------------------------------- 65 54 66 void CAttributeMap::fromString(const StdString & str) 55 { ERROR("CAttributeMap::fromString(const StdString & str)", 56 << "[ str = " << str << "] Not implemented yet !"); } 67 { 68 ERROR("CAttributeMap::fromString(const StdString & str)", 69 << "[ str = " << str << "] Not implemented yet !"); 70 } 71 72 //--------------------------------------------------------------- 57 73 58 74 //StdOStream & operator << (StdOStream & os, const CAttributeMap & attributmap) 59 75 //{ os << attributmap.toString(); return (os); } 60 76 77 //--------------------------------------------------------------- 78 61 79 void CAttributeMap::setAttributes(const xml::THashAttributes & attributes) 62 80 { … … 71 89 } 72 90 } 73 91 92 //--------------------------------------------------------------- 93 74 94 void CAttributeMap::setAttributes(const CAttributeMap * const _parent) 75 95 { … … 90 110 } 91 111 } 112 113 //--------------------------------------------------------------- 114 115 void CAttributeMap::toBinary(StdOStream & os) const 116 { 117 typedef std::pair<StdString, CAttribute*> StdStrAttPair; 118 SuperClassMap::const_iterator it = this->begin(), end = this->end(); 119 120 const StdSize nbatt = SuperClassMap::size(); 121 os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); 122 123 for (; it != end; it++) 124 { 125 const StdString & key = it->first; 126 const CAttribute* value = it->second; 127 const StdSize size = key.size(); 128 129 os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); 130 os.write (key.data(), size * sizeof(char)); 131 132 if (!value->isEmpty()) 133 { 134 bool b = true; 135 os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); 136 value->toBinary(os); 137 } 138 else 139 { 140 bool b = false; 141 os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); 142 } 143 } 144 } 145 146 //--------------------------------------------------------------- 147 148 void CAttributeMap::fromBinary(StdIStream & is) 149 { 150 StdSize nbatt = 0; 151 is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); 152 153 for (StdSize i = 0; i < nbatt; i++) 154 { 155 bool hasValue = false; 156 StdSize size = 0; 157 is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); 158 StdString key(size, ' '); 159 is.read (const_cast<char *>(key.data()), size * sizeof(char)); 160 161 if (!this->hasAttribute(key)) 162 ERROR("CAttributeMap::fromBinary(StdIStream & is)", 163 << "[ key = " << key << "] key not found !"); 164 165 is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); 166 167 if (hasValue) 168 this->operator[](key)->fromBinary(is); 169 } 170 } 171 172 ///-------------------------------------------------------------- 92 173 93 174 } // namespace tree -
XMLIO_V2/dev/dev_rv/src/xmlio/attribute_map.hpp
r152 r171 43 43 virtual StdString toString(void) const; 44 44 virtual void fromString(const StdString & str); 45 46 virtual void toBinary (StdOStream & os) const; 47 virtual void fromBinary(StdIStream & is); 45 48 46 49 protected : -
XMLIO_V2/dev/dev_rv/src/xmlio/attribute_template.cpp
r152 r171 10 10 11 11 /** Spécialisations des templates pour la fonction [toString] **/ 12 12 13 template <> 13 14 StdString CAttributeTemplate<bool>::toString(void) const -
XMLIO_V2/dev/dev_rv/src/xmlio/exception.hpp
r152 r171 47 47 48 48 #ifdef XIOS_DEBUG 49 #define DEBUG(x) std::clog << "> Debug " << INFO(x)49 # define DEBUG(x) std::clog << "> Debug " << INFO(x) 50 50 #else 51 #define DEBUG(x)51 # define DEBUG(x) 52 52 #endif 53 53 -
XMLIO_V2/dev/dev_rv/src/xmlio/main_server.cpp
r169 r171 80 80 CTreeManager::PrintTreeToFile("data/def/test.xml"); 81 81 82 83 ARRAY_CREATE(sarray, double, 1, [1]); 84 StdIFStream ifs("data/monfichierbinaire"); 85 sarray->fromBinary(ifs); 86 ifs.close(); 87 82 88 83 89 -
XMLIO_V2/dev/dev_rv/src/xmlio/xml_node.cpp
r152 r171 17 17 18 18 StdString CXMLNode::getElementName(void) const 19 { return (this->node->name()); } 19 { 20 return (this->node->name()); 21 } 20 22 21 23 bool CXMLNode::goToNextElement(void) … … 24 26 for(rapidxml::xml_node<char> * nextElement = this->node->next_sibling(); 25 27 ; nextElement = this->node->next_sibling()) 28 { 26 29 if (nextElement == NULL) break; 27 30 else if (nextElement->type() == rapidxml::node_element) 28 { node = nextElement; return (!retvalue); } 31 { 32 node = nextElement; 33 return (!retvalue); 34 } 35 } 29 36 return (retvalue); 30 37 } … … 37 44 { 38 45 for(;;nextElement = this->node->next_sibling()) 46 { 39 47 if (nextElement == NULL) break; 40 48 else if (nextElement->type() == rapidxml::node_element) 41 { node = nextElement; return (!retvalue); } 49 { 50 node = nextElement; 51 return (!retvalue); 52 } 53 } 42 54 } 43 55 return (retvalue); … … 54 66 55 67 const StdString & CXMLNode::GetRootName(void) 56 { return (CXMLNode::RootName); } 68 { 69 return (CXMLNode::RootName); 70 } 57 71 58 72 THashAttributes CXMLNode::getAttributes(void) const … … 62 76 63 77 if ((currentAttr = this->node->first_attribute()) != NULL) 64 do { 78 { 79 do 80 { 65 81 attributes.insert(std::pair<StdString, StdString> 66 82 (StdString(currentAttr->name()), 67 83 StdString(currentAttr->value()))); 68 84 } while ((currentAttr = currentAttr->next_attribute()) != NULL); 85 } 69 86 70 87 return (attributes) ;
Note: See TracChangeset
for help on using the changeset viewer.