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