Changeset 793
- Timestamp:
- 11/19/15 16:55:16 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/interface/c/icutil.hpp
r501 r793 8 8 9 9 #include <string> 10 #include <string.h> 10 #include <algorithm> 11 11 12 // ///////////////////////// Définitions/Déclarations /////////////////////// // 12 13 13 inline bool cstr2string(const char * cstr, int cstr_size, std::string& str)14 inline bool cstr2string(const char* cstr, int cstr_size, std::string& str) 14 15 { 15 std::string valtemp; 16 std::size_t d, f = 0; 17 if (cstr_size != -1) 16 if (cstr_size != -1) 18 17 { 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); 18 std::string valtemp; 19 std::size_t d, f = 0; 20 21 valtemp.append(cstr, cstr_size); 22 d = valtemp.find_first_not_of(' '); 23 f = valtemp.find_last_not_of (' '); 24 str = valtemp.substr(d, f - d + 1); 25 26 return true; 24 27 } 25 28 else 26 { 27 return (false); 28 } 29 return false; 29 30 } 30 31 31 inline bool string_copy(const st ring& str, char* cstr,int cstr_size)32 inline bool string_copy(const std::string& str, char* cstr, int cstr_size) 32 33 { 33 34 if (str.size()>cstr_size) return false;34 if (str.size() > cstr_size) 35 return false; 35 36 else 36 37 { 37 std:: memset (cstr,' ',cstr_size);38 str.copy(cstr, cstr_size);39 return true 38 std::fill(cstr, cstr + cstr_size, ' '); 39 str.copy(cstr, cstr_size); 40 return true; 40 41 } 41 42 } 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 43 68 44 #endif // __ICUTIL_HPP__
Note: See TracChangeset
for help on using the changeset viewer.