source: XIOS/trunk/src/buffer_out_impl.hpp @ 1704

Last change on this file since 1704 was 501, checked in by ymipsl, 9 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 4.3 KB
Line 
1#ifndef __BUFFER_OUT_IMPL_HPP__
2#define __BUFFER_OUT_IMPL_HPP__
3
4namespace 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>
73    bool CBufferOut::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
Note: See TracBrowser for help on using the repository browser.