source: XIOS/trunk/src/interface/c/icutil.hpp @ 501

Last change on this file since 501 was 501, checked in by ymipsl, 10 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: 1.9 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5
6#ifndef __ICUTIL_HPP__
7#define __ICUTIL_HPP__
8
9#include <string>
10#include <string.h>
11// ///////////////////////// Définitions/Déclarations /////////////////////// //
12
13inline bool cstr2string(const char * cstr, int cstr_size, std::string & str)
14{
15  std::string valtemp;
16  std::size_t d, f = 0;
17  if (cstr_size != -1) 
18  { 
19     valtemp.append (cstr, cstr_size);
20     d = valtemp.find_first_not_of(' ');
21     f = valtemp.find_last_not_of (' ');
22     str = valtemp.substr(d, f-d+1); 
23     return (true);
24  }
25  else
26  {
27     return (false);
28  } 
29}
30
31inline bool string_copy(const string& str, char* cstr,int cstr_size)
32{
33 
34  if (str.size()>cstr_size) return false ;
35  else
36  {
37    std::memset (cstr,' ',cstr_size);
38    str.copy(cstr,cstr_size) ;
39    return true ;
40  }
41}
42/*
43  template<class T>
44  inline  bool array_copy(ARRAY(T,1) array_in, T* array_out, size_t extent1)
45  {
46    if (array_in->num_elements() != extent1) return false ;
47    std::copy(array_in->data(), array_in->data() + array_in->num_elements(), array_out);
48    return true ;
49  }
50
51  template<class T>
52  inline  bool array_copy(ARRAY(T,2) array_in, T* array_out, size_t extent1, size_t extent2)
53  {
54    if (array_in->num_elements() != extent1*extent2) return false ;
55    std::copy(array_in->data(), array_in->data() + array_in->num_elements(), array_out);
56    return true ;
57  }
58
59  template<class T>
60  inline  bool array_copy(ARRAY(T,3) array_in, T* array_out, size_t extent1, size_t extent2, size_t extent3)
61  {
62    if (array_in->num_elements() != extent1*extent2*extent3) return false ;
63    std::copy(array_in->data(), array_in->data() + array_in->num_elements(), array_out);
64    return true ;
65  }       
66*/
67
68#endif // __ICUTIL_HPP__
Note: See TracBrowser for help on using the repository browser.