BugInTheSYS

Untitled

Oct 4th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. // main.cpp
  2.  
  3. // Function and variable declarations and/or definitions, Preprocessor directives, etc...
  4.  
  5. template < class T > std::string< T > GetMemory( void *base );
  6. template < class T > void< T > SetMemory( std::string &value, void *base );
  7.  
  8. // CODE
  9.  
  10. template < class T >
  11. std::string< T > GetMemory( void *base ) {
  12.   std::string result;
  13.   unsigned int i,
  14.                length = sizeof( T ),
  15.                beginning = ( unsigned int )( char* )base,
  16.                end = beginning + length;
  17.   for( i = beginning; i <= end; i++ ) {
  18.     result += *( ( char* )i );
  19.   }
  20.   return result;
  21. }
  22.  
  23. template < class T >
  24. void SetMemory< T >( std::string &value, void *base ) {
  25.   unsigned int i,
  26.                length = sizeof( T ),
  27.                beginning = ( unsigned int )( char* )base,
  28.                end = beginning + length;
  29.   for( i = beginning; i <= end; i++ ) {
  30.     *( ( char* )i ) = value[ start + i - beginning ];
  31.   }
  32.   value = value->substr( length, value->npos );
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment