Changeset 532 for XIOS/trunk/src/type/type_specialisation.hpp
- Timestamp:
- 12/10/14 14:27:09 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/type/type_specialisation.hpp
r501 r532 9 9 #include <string> 10 10 #include <boost/algorithm/string.hpp> 11 #include "date.hpp" 11 12 12 13 namespace xios … … 165 166 return ret ; 166 167 } 168 169 // template specializations for CDate 170 171 template <> 172 size_t CType<CDate>::_size() const 173 { 174 return 6 * sizeof(int); 175 } 176 177 template <> 178 size_t CType_ref<CDate>::_size() const 179 { 180 return 6 * sizeof(int); 181 } 182 183 /*template <> 184 void CType<CDate>::_fromString(const string& str) 185 { 186 allocate() ; 187 *ptrValue=str ; 188 } 189 190 template <> 191 void CType_ref<CDate>::_fromString(const string& str) 192 { 193 checkEmpty() ; 194 *ptrValue=str ; 195 } 196 197 template <> 198 void CType_ref<CDate>::_fromString(const string& str) const 199 { 200 checkEmpty() ; 201 *ptrValue=str ; 202 }*/ 203 204 template <> 205 bool CType<CDate>::_toBuffer(CBufferOut& buffer) const 206 { 207 if (buffer.remain() < size()) return false; 208 else 209 { 210 bool ret = true; 211 if (ret) ret &= buffer.put(ptrValue->getYear()); 212 if (ret) ret &= buffer.put(ptrValue->getMonth()); 213 if (ret) ret &= buffer.put(ptrValue->getDay()); 214 if (ret) ret &= buffer.put(ptrValue->getHour()); 215 if (ret) ret &= buffer.put(ptrValue->getMinute()); 216 if (ret) ret &= buffer.put(ptrValue->getSecond()); 217 return ret; 218 } 219 } 220 221 template <> 222 bool CType_ref<CDate>::_toBuffer(CBufferOut& buffer) const 223 { 224 if (buffer.remain() < size()) return false; 225 else 226 { 227 bool ret = true; 228 if (ret) ret &= buffer.put(ptrValue->getYear()); 229 if (ret) ret &= buffer.put(ptrValue->getMonth()); 230 if (ret) ret &= buffer.put(ptrValue->getDay()); 231 if (ret) ret &= buffer.put(ptrValue->getHour()); 232 if (ret) ret &= buffer.put(ptrValue->getMinute()); 233 if (ret) ret &= buffer.put(ptrValue->getSecond()); 234 return ret; 235 } 236 } 237 238 template <> 239 bool CType<CDate>::_fromBuffer(CBufferIn& buffer) 240 { 241 allocate(); 242 bool ret = true; 243 244 int year, month, day, hour, min, sec; 245 if (ret) ret &= buffer.get(year); 246 if (ret) ret &= buffer.get(month); 247 if (ret) ret &= buffer.get(day); 248 if (ret) ret &= buffer.get(hour); 249 if (ret) ret &= buffer.get(min); 250 if (ret) ret &= buffer.get(sec); 251 if (ret) 252 { 253 ptrValue->setYear(year); 254 ptrValue->setMonth(month); 255 ptrValue->setDay(day); 256 ptrValue->setHour(hour); 257 ptrValue->setMinute(min); 258 ptrValue->setSecond(sec); 259 } 260 261 return ret; 262 } 263 264 template <> 265 bool CType_ref<CDate>::_fromBuffer(CBufferIn& buffer) const 266 { 267 bool ret = true; 268 269 int year, month, day, hour, min, sec; 270 if (ret) ret &= buffer.get(year); 271 if (ret) ret &= buffer.get(month); 272 if (ret) ret &= buffer.get(day); 273 if (ret) ret &= buffer.get(hour); 274 if (ret) ret &= buffer.get(min); 275 if (ret) ret &= buffer.get(sec); 276 if (ret) 277 { 278 ptrValue->setYear(year); 279 ptrValue->setMonth(month); 280 ptrValue->setDay(day); 281 ptrValue->setHour(hour); 282 ptrValue->setMinute(min); 283 ptrValue->setSecond(sec); 284 } 285 286 return ret; 287 } 288 289 template <> 290 bool CType_ref<CDate>::_fromBuffer(CBufferIn& buffer) 291 { 292 bool ret = true; 293 294 int year, month, day, hour, min, sec; 295 if (ret) ret &= buffer.get(year); 296 if (ret) ret &= buffer.get(month); 297 if (ret) ret &= buffer.get(day); 298 if (ret) ret &= buffer.get(hour); 299 if (ret) ret &= buffer.get(min); 300 if (ret) ret &= buffer.get(sec); 301 if (ret) 302 { 303 ptrValue->setYear(year); 304 ptrValue->setMonth(month); 305 ptrValue->setDay(day); 306 ptrValue->setHour(hour); 307 ptrValue->setMinute(min); 308 ptrValue->setSecond(sec); 309 } 310 311 return ret; 312 } 313 167 314 // template specialisation for CArray 168 315 /*
Note: See TracChangeset
for help on using the changeset viewer.