Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main.cpp
- // Function and variable declarations and/or definitions, Preprocessor directives, etc...
- // among those the following lines, intended to be normal function declarations:
- template < class T > std::string GetMemory< T >( void *base );
- template < class T > void SetMemory< T >( std::string &value, void *base );
- // CODE
- // And now, as normally, their definitions:
- template < class T >
- std::string GetMemory< T >( void *base ) {
- std::string result;
- unsigned int i,
- length = sizeof( T ),
- beginning = ( unsigned int )( char* )base,
- end = beginning + length;
- for( i = beginning; i <= end; i++ ) {
- result += *( ( char* )i );
- }
- return result;
- }
- template < class T >
- void SetMemory< T >( std::string &value, void *base ) {
- unsigned int i,
- length = sizeof( T ),
- beginning = ( unsigned int )( char* )base,
- end = beginning + length;
- for( i = beginning; i <= end; i++ ) {
- *( ( char* )i ) = value[ start + i - beginning ];
- }
- value = value->substr( length, value->npos );
- }
Advertisement
Add Comment
Please, Sign In to add comment