Changeset 300 for XMLIO_V2/dev/common/src/attribute_template_impl.hpp
- Timestamp:
- 02/13/12 19:35:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/common/src/attribute_template_impl.hpp
r274 r300 3 3 4 4 #include "array.hpp" 5 #include "type.hpp" 6 #include "buffer_in.hpp" 7 #include "buffer_out.hpp" 5 8 6 9 namespace xmlioserver … … 69 72 70 73 template <class T> 74 T* CAttributeTemplate<T>::getRef(void) 75 { 76 if (SuperClass::isEmpty()) 77 { 78 ERROR("T CAttributeTemplate<T>::getValue(void) const", 79 << "[ id = " << this->getId() << "]" 80 << " L'attribut est requis mais n'est pas défini !"); 81 } 82 return (SuperClass::getRef<T>()); 83 } 84 85 template <class T> 71 86 void CAttributeTemplate<T>::setValue(const T & value) 72 87 { … … 115 130 FromBinary(is, value); 116 131 this->setValue(value); 132 } 133 134 template <class T> 135 bool CAttributeTemplate<T>::toBuffer (CBufferOut& buffer) const 136 { 137 if (isEmpty()) return buffer.put(true) ; 138 else 139 { 140 bool ret=true ; 141 CType<T> val(*boost::any_cast<T>(&value)) ; 142 ret&=buffer.put(false) ; 143 ret&=val.toBuffer(buffer) ; 144 return ret ; 145 } 146 } 147 148 template <class T> 149 bool CAttributeTemplate<T>::fromBuffer(CBufferIn& buffer) 150 { 151 bool empty ; 152 bool ret=true ; 153 ret&=buffer.get(empty) ; 154 if (empty) 155 { 156 clear() ; 157 return ret ; 158 } 159 else 160 { 161 if (isEmpty()) 162 { 163 T val ; 164 setValue(val) ; 165 } 166 T* V=const_cast<T*>(boost::any_cast<T>(&value)) ; 167 CType<T> val(*V) ; 168 return val.fromBuffer(buffer) ; 169 } 170 } 171 172 template <class T> 173 size_t CAttributeTemplate<T>::size(void) const 174 { 175 if (isEmpty()) return sizeof(bool) ; 176 else 177 { 178 CType<T> val(*const_cast<T*>(boost::any_cast<T>(&value))) ; 179 return val.size()+sizeof(bool) ; 180 } 117 181 } 118 182
Note: See TracChangeset
for help on using the changeset viewer.