copying CObject-derived-classes to shared memory (created using Memory-Mapped file) 
Author Message
 copying CObject-derived-classes to shared memory (created using Memory-Mapped file)

I was wonder how to easily and efficiently copy MFC's
CObject-derived-classes (CString, CArray, and my own CObject derived
classes) to a shared memory (created with pagefile-backed-memory mapped
file).
What I can think right now is just do the right memcpy one-by-one,
keeping track the right pointer for each member variable.
So, for CDWordArray, it something like this:

LPVOID * lpMemoryMappedFile = .... (pointer we received from mapview
funciton).
CDWordArray dataArray;

*lpMemoryMappedFile = dataArray.GetSize();
for (i = 0; i < dataArray.GetSize(); i++) {
   ( *(lpMemoryMappedFile + sizeof(int) + (i * sizeof (DWORD)))) =
dataArray.GetAt(i);

Quote:
}

Is my assumption correct that I have to do the pointer arithmetic and
memcpy myself, or there are easier ways of doing that.

thanks,
tim.



Fri, 01 Mar 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. IPC: Shared memory via dll vs memory map file

2. How to derive a class from CObject using the class wizard

3. Problem with copy/ paste of CObject derived class

4. Copy constructor for CObject derived class

5. Creating CObject-derived classes in VC++5.0

6. Deriving a class from CObject using the ClassWizard

7. Using CObArray with CObject-derived classes

8. using new on a class derived by CObject

9. Deriving a class from CObject and using new

10. Help: Mapping complex data structs into shared memory.

11. Sharing C++ object with memory mapping on Windows NT4.0

12. map in shared memory

 

 
Powered by phpBB® Forum Software