XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
buffer_out_impl.hpp
Aller à la documentation de ce fichier.
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<uint>(const uint& data) { return put_template(data) ; }
14  template <> bool CBufferOut::put<ushort>(const ushort& data) { return put_template(data) ; }
15  template <> bool CBufferOut::put<ulong>(const ulong& data) { return put_template(data) ; }
16  template <> bool CBufferOut::put<float>(const float& data) { return put_template(data) ; }
17  template <> bool CBufferOut::put<double>(const double& data) { return put_template(data) ; }
18  template <> bool CBufferOut::put<long double>(const long double& data) { return put_template(data) ;}
19 
20  template <> bool CBufferOut::put<char>(const char* data, size_t n) { return put_template(data,n) ; }
21  template <> bool CBufferOut::put<bool>(const bool* data, size_t n) { return put_template(data,n) ; }
22  template <> bool CBufferOut::put<int>(const int* data, size_t n) { return put_template(data,n) ; }
23  template <> bool CBufferOut::put<short>(const short* data, size_t n) { return put_template(data,n) ; }
24  template <> bool CBufferOut::put<long>(const long* data, size_t n) { return put_template(data,n) ; }
25  template <> bool CBufferOut::put<uint>(const uint* data, size_t n) { return put_template(data,n) ; }
26  template <> bool CBufferOut::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; }
27  template <> bool CBufferOut::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; }
28  template <> bool CBufferOut::put<float>(const float* data, size_t n) { return put_template(data,n) ; }
29  template <> bool CBufferOut::put<double>(const double* data, size_t n) { return put_template(data,n) ; }
30  template <> bool CBufferOut::put<long double>(const long double* data, size_t n) { return put_template(data,n) ;}
31 
32 
33  template <> bool CBufferOut::advance<char>(size_t n) { return advance_template<char>(n) ; }
34  template <> bool CBufferOut::advance<bool>(size_t n) { return advance_template<bool>(n) ; }
35  template <> bool CBufferOut::advance<int>(size_t n) { return advance_template<int>(n) ; }
36  template <> bool CBufferOut::advance<short>(size_t n) { return advance_template<short>(n) ; }
37  template <> bool CBufferOut::advance<long>(size_t n) { return advance_template<long>(n) ; }
38  template <> bool CBufferOut::advance<uint>(size_t n) { return advance_template<uint>(n) ; }
39  template <> bool CBufferOut::advance<ushort>(size_t n) { return advance_template<ushort>(n) ; }
40  template <> bool CBufferOut::advance<ulong>(size_t n) { return advance_template<ulong>(n) ; }
41  template <> bool CBufferOut::advance<float>(size_t n) { return advance_template<float>(n) ; }
42  template <> bool CBufferOut::advance<double>(size_t n) { return advance_template<double>(n) ; }
43  template <> bool CBufferOut::advance<long double>(size_t n) { return advance_template<long double>(n) ;}
44 
45  template <class T>
46  bool CBufferOut::put_template(const T& data)
47  {
48  return put_template<T>(&data,1);
49  }
50 
51  template <class T>
52  bool CBufferOut::put_template(const 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++) current[i]=dataBuff[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>
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
unsigned short int ushort
Definition: xios_spl.hpp:51
unsigned int uint
Definition: xios_spl.hpp:52
#define xios(arg)
unsigned long int ulong
Definition: xios_spl.hpp:53
bool advance_template(size_t n)
bool put_template(const T &data)