1 | #ifndef __BUFFER_OUT_IMPL_HPP__ |
---|
2 | #define __BUFFER_OUT_IMPL_HPP__ |
---|
3 | |
---|
4 | namespace xios |
---|
5 | { |
---|
6 | |
---|
7 | // template spectialisation : CBufferIn::put |
---|
8 | template <> bool CBufferOut::put<char>(const char& data) { return put_template(data) ; } |
---|
9 | template <> bool CBufferOut::put<bool>(const bool& data) { return put_template(data) ; } |
---|
10 | template <> bool CBufferOut::put<int>(const int& data) { return put_template(data) ; } |
---|
11 | template <> bool CBufferOut::put<short>(const short& data) { return put_template(data) ; } |
---|
12 | template <> bool CBufferOut::put<long>(const long& data) { return put_template(data) ; } |
---|
13 | template <> bool CBufferOut::put<longlong>(const longlong& data) { return put_template(data) ; } |
---|
14 | template <> bool CBufferOut::put<uint>(const uint& data) { return put_template(data) ; } |
---|
15 | template <> bool CBufferOut::put<ushort>(const ushort& data) { return put_template(data) ; } |
---|
16 | template <> bool CBufferOut::put<ulong>(const ulong& data) { return put_template(data) ; } |
---|
17 | template <> bool CBufferOut::put<ulonglong>(const ulonglong& data) { return put_template(data) ; } |
---|
18 | template <> bool CBufferOut::put<float>(const float& data) { return put_template(data) ; } |
---|
19 | template <> bool CBufferOut::put<double>(const double& data) { return put_template(data) ; } |
---|
20 | template <> bool CBufferOut::put<long double>(const long double& data) { return put_template(data) ;} |
---|
21 | |
---|
22 | template <> bool CBufferOut::put<char>(const char* data, size_t n) { return put_template(data,n) ; } |
---|
23 | template <> bool CBufferOut::put<bool>(const bool* data, size_t n) { return put_template(data,n) ; } |
---|
24 | template <> bool CBufferOut::put<int>(const int* data, size_t n) { return put_template(data,n) ; } |
---|
25 | template <> bool CBufferOut::put<short>(const short* data, size_t n) { return put_template(data,n) ; } |
---|
26 | template <> bool CBufferOut::put<long>(const long* data, size_t n) { return put_template(data,n) ; } |
---|
27 | template <> bool CBufferOut::put<longlong>(const longlong* data, size_t n) { return put_template(data,n) ; } |
---|
28 | template <> bool CBufferOut::put<uint>(const uint* data, size_t n) { return put_template(data,n) ; } |
---|
29 | template <> bool CBufferOut::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; } |
---|
30 | template <> bool CBufferOut::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; } |
---|
31 | template <> bool CBufferOut::put<ulonglong>(const ulonglong* data, size_t n) { return put_template(data,n) ; } |
---|
32 | template <> bool CBufferOut::put<float>(const float* data, size_t n) { return put_template(data,n) ; } |
---|
33 | template <> bool CBufferOut::put<double>(const double* data, size_t n) { return put_template(data,n) ; } |
---|
34 | template <> bool CBufferOut::put<long double>(const long double* data, size_t n) { return put_template(data,n) ;} |
---|
35 | |
---|
36 | |
---|
37 | template <> bool CBufferOut::advance<char>(size_t n) { return advance_template<char>(n) ; } |
---|
38 | template <> bool CBufferOut::advance<bool>(size_t n) { return advance_template<bool>(n) ; } |
---|
39 | template <> bool CBufferOut::advance<int>(size_t n) { return advance_template<int>(n) ; } |
---|
40 | template <> bool CBufferOut::advance<short>(size_t n) { return advance_template<short>(n) ; } |
---|
41 | template <> bool CBufferOut::advance<long>(size_t n) { return advance_template<long>(n) ; } |
---|
42 | template <> bool CBufferOut::advance<longlong>(size_t n) { return advance_template<longlong>(n) ; } |
---|
43 | template <> bool CBufferOut::advance<uint>(size_t n) { return advance_template<uint>(n) ; } |
---|
44 | template <> bool CBufferOut::advance<ushort>(size_t n) { return advance_template<ushort>(n) ; } |
---|
45 | template <> bool CBufferOut::advance<ulong>(size_t n) { return advance_template<ulong>(n) ; } |
---|
46 | template <> bool CBufferOut::advance<ulonglong>(size_t n) { return advance_template<ulonglong>(n) ; } |
---|
47 | template <> bool CBufferOut::advance<float>(size_t n) { return advance_template<float>(n) ; } |
---|
48 | template <> bool CBufferOut::advance<double>(size_t n) { return advance_template<double>(n) ; } |
---|
49 | template <> bool CBufferOut::advance<long double>(size_t n) { return advance_template<long double>(n) ;} |
---|
50 | |
---|
51 | template <class T> |
---|
52 | bool CBufferOut::put_template(const T& data) |
---|
53 | { |
---|
54 | return put_template<T>(&data,1); |
---|
55 | } |
---|
56 | |
---|
57 | template <class T> |
---|
58 | bool CBufferOut::put_template(const 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++) current[i]=dataBuff[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 CBufferOut::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 |
---|