[300] | 1 | #ifndef __BUFFER_IN_IMPL_HPP__ |
---|
| 2 | #define __BUFFER_IN_IMPL_HPP__ |
---|
| 3 | |
---|
[335] | 4 | namespace xios |
---|
[300] | 5 | { |
---|
| 6 | |
---|
| 7 | // template spectialisation : CBufferIn::get |
---|
| 8 | |
---|
| 9 | template <> bool CBufferIn::get<char>(char& data) { return get_template(data) ; } |
---|
| 10 | template <> bool CBufferIn::get<bool>(bool& data) { return get_template(data) ; } |
---|
| 11 | template <> bool CBufferIn::get<int>(int& data) { return get_template(data) ; } |
---|
| 12 | template <> bool CBufferIn::get<short>(short& data) { return get_template(data) ; } |
---|
| 13 | template <> bool CBufferIn::get<long>(long& data) { return get_template(data) ; } |
---|
| 14 | template <> bool CBufferIn::get<uint>(uint& data) { return get_template(data) ; } |
---|
| 15 | template <> bool CBufferIn::get<ushort>(ushort& data) { return get_template(data) ; } |
---|
| 16 | template <> bool CBufferIn::get<ulong>(ulong& data) { return get_template(data) ; } |
---|
| 17 | template <> bool CBufferIn::get<float>(float& data) { return get_template(data) ; } |
---|
| 18 | template <> bool CBufferIn::get<double>(double& data) { return get_template(data) ; } |
---|
| 19 | template <> bool CBufferIn::get<long double>(long double& data) { return get_template(data) ;} |
---|
| 20 | |
---|
| 21 | template <> bool CBufferIn::get<char>(char* data, size_t n) { return get_template(data,n) ; } |
---|
| 22 | template <> bool CBufferIn::get<bool>(bool* data, size_t n) { return get_template(data,n) ; } |
---|
| 23 | template <> bool CBufferIn::get<int>(int* data, size_t n) { return get_template(data,n) ; } |
---|
| 24 | template <> bool CBufferIn::get<short>(short* data, size_t n) { return get_template(data,n) ; } |
---|
| 25 | template <> bool CBufferIn::get<long>(long* data, size_t n) { return get_template(data,n) ; } |
---|
| 26 | template <> bool CBufferIn::get<uint>(uint* data, size_t n) { return get_template(data,n) ; } |
---|
| 27 | template <> bool CBufferIn::get<ushort>(ushort* data, size_t n) { return get_template(data,n) ; } |
---|
| 28 | template <> bool CBufferIn::get<ulong>(ulong* data, size_t n) { return get_template(data,n) ; } |
---|
| 29 | template <> bool CBufferIn::get<float>(float* data, size_t n) { return get_template(data,n) ; } |
---|
| 30 | template <> bool CBufferIn::get<double>(double* data, size_t n) { return get_template(data,n) ; } |
---|
| 31 | template <> bool CBufferIn::get<long double>(long double* data, size_t n) { return get_template(data,n) ;} |
---|
| 32 | |
---|
| 33 | template <> bool CBufferIn::advance<char>(size_t n) { return advance_template<char>(n) ; } |
---|
| 34 | template <> bool CBufferIn::advance<bool>(size_t n) { return advance_template<bool>(n) ; } |
---|
| 35 | template <> bool CBufferIn::advance<int>(size_t n) { return advance_template<int>(n) ; } |
---|
| 36 | template <> bool CBufferIn::advance<short>(size_t n) { return advance_template<short>(n) ; } |
---|
| 37 | template <> bool CBufferIn::advance<long>(size_t n) { return advance_template<long>(n) ; } |
---|
| 38 | template <> bool CBufferIn::advance<uint>(size_t n) { return advance_template<uint>(n) ; } |
---|
| 39 | template <> bool CBufferIn::advance<ushort>(size_t n) { return advance_template<ushort>(n) ; } |
---|
| 40 | template <> bool CBufferIn::advance<ulong>(size_t n) { return advance_template<ulong>(n) ; } |
---|
| 41 | template <> bool CBufferIn::advance<float>(size_t n) { return advance_template<float>(n) ; } |
---|
| 42 | template <> bool CBufferIn::advance<double>(size_t n) { return advance_template<double>(n) ; } |
---|
| 43 | template <> bool CBufferIn::advance<long double>(size_t n) { return advance_template<long double>(n) ;} |
---|
| 44 | |
---|
| 45 | template <class T> |
---|
| 46 | bool CBufferIn::get_template(T& data) |
---|
| 47 | { |
---|
| 48 | return get_template<T>(&data,1) ; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | template <class T> |
---|
| 52 | bool CBufferIn::get_template(T* data, size_t n) |
---|
| 53 | { |
---|
| 54 | bool ret; |
---|
| 55 | char* dataBuff ; |
---|
| 56 | |
---|
| 57 | size_t dataSize=sizeof(T)*n ; |
---|
| 58 | |
---|
| 59 | if (count_+dataSize<=size_) |
---|
| 60 | { |
---|
| 61 | dataBuff=(char*) data ; |
---|
| 62 | for(size_t i=0;i<dataSize;i++) dataBuff[i]=current[i] ; |
---|
| 63 | current+=dataSize ; |
---|
| 64 | count_+=dataSize ; |
---|
| 65 | ret=true ; |
---|
| 66 | } |
---|
| 67 | else ret=false ; |
---|
| 68 | |
---|
| 69 | return ret ; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | template <class T> |
---|
| 73 | bool CBufferIn::advance_template(size_t n) |
---|
| 74 | { |
---|
| 75 | bool ret; |
---|
| 76 | char* dataBuff ; |
---|
| 77 | |
---|
| 78 | size_t dataSize=sizeof(T)*n ; |
---|
| 79 | |
---|
| 80 | if (count_+dataSize<=size_) |
---|
| 81 | { |
---|
| 82 | current+=dataSize ; |
---|
| 83 | count_+=dataSize ; |
---|
| 84 | ret=true ; |
---|
| 85 | } |
---|
| 86 | else ret=false ; |
---|
| 87 | |
---|
| 88 | return ret ; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | #endif |
---|