- Timestamp:
- 03/20/15 15:57:29 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h
r19198 r19215 8 8 enum marshall_directions{ 9 9 MARSHALLING_FORWARD, 10 MARSHALLING_BACKWARDS 10 MARSHALLING_BACKWARD, 11 MARSHALLING_SIZE 11 12 }; 12 13 13 #define MARSHALLING_ENUM(EN) 14 int enum_type=EN; 14 #define MARSHALLING_ENUM(EN)\ 15 int enum_type=EN;\ 15 16 if(marshall_direction==MARSHALLING_FORWARD){\ 16 if(pmarshalled_data){\ 17 memcpy(*pmarshalled_data,&enum_type,sizeof(int));\ 18 *pmarshalled_data+=sizeof(int);\ 19 }\ 17 memcpy(*pmarshalled_data,&enum_type,sizeof(int));\ 18 *pmarshalled_data+=sizeof(int);\ 20 19 *pmarshalled_data_size+=sizeof(int);\ 21 } 20 }\ 21 else if(marshall_direction==MARSHALLING_SIZE){\ 22 *pmarshalled_data_size+=sizeof(int);\ 23 }\ 24 else if(marshall_direction==MARSHALLING_BACKWARD){\ 25 }\ 26 else _error_("Wrong direction during the Marshall process");\ 22 27 23 #define MARSHALLING(FIELD) \ 24 \ 28 29 #define MARSHALLING(FIELD)\ 30 \ 25 31 if(marshall_direction==MARSHALLING_FORWARD){\ 26 if(pmarshalled_data){\ 27 memcpy(*pmarshalled_data,&FIELD,sizeof(FIELD));\ 28 *pmarshalled_data+=sizeof(FIELD);\ 29 }\ 32 memcpy(*pmarshalled_data,&FIELD,sizeof(FIELD));\ 33 *pmarshalled_data+=sizeof(FIELD);\ 30 34 *pmarshalled_data_size+=sizeof(FIELD);\ 31 35 }\ 32 else{\ 36 else if(marshall_direction==MARSHALLING_SIZE){\ 37 *pmarshalled_data_size+=sizeof(FIELD);\ 38 }\ 39 else if(marshall_direction==MARSHALLING_BACKWARD){\ 33 40 memcpy(&FIELD,*pmarshalled_data,sizeof(FIELD));\ 34 41 *pmarshalled_data+=sizeof(FIELD);\ 35 } 42 }\ 43 else _error_("Wrong direction during the Marshall process"); 44 36 45 37 46 #define MARSHALLING_ARRAY(FIELD,TYPE,SIZE) \ 38 \47 \ 39 48 if(marshall_direction==MARSHALLING_FORWARD){\ 40 if(pmarshalled_data){\ 41 memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\ 42 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 43 }\ 49 memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\ 50 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 44 51 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\ 45 52 }\ 46 else{\ 53 else if(marshall_direction==MARSHALLING_SIZE){\ 54 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\ 55 }\ 56 else if(marshall_direction==MARSHALLING_BACKWARD){\ 47 57 memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\ 48 58 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 49 } 59 }\ 60 else _error_("Wrong direction during the Marshall process"); 61 50 62 51 63 #define MARSHALLING_DYNAMIC(FIELD,TYPE,SIZE) \ 52 \64 \ 53 65 if(marshall_direction==MARSHALLING_FORWARD){\ 54 if(pmarshalled_data){\ 55 memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\ 56 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 57 }\ 66 memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\ 67 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 58 68 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\ 59 69 }\ 60 else{\ 70 else if(marshall_direction==MARSHALLING_SIZE){\ 71 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\ 72 }\ 73 else if(marshall_direction==MARSHALLING_BACKWARD){\ 61 74 FIELD=xNew<TYPE>(SIZE);\ 62 75 memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\ 63 76 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 64 } 77 }\ 78 else _error_("Wrong direction during the Marshall process"); 65 79 66 80 #endif
Note:
See TracChangeset
for help on using the changeset viewer.