C/C++ map binary data to struct members
Lets say, I have the following text file:

**Listing 1:**

    Endianess=little
    AddressModel=32

    typedef struct{
      int    x;
      int    y;
      float  f;
      double d;
    } A;

    instance1:0x0000000100000002000048C19A99999999993C40
    instance2:0x00100257000000090000000FBA99359976992397

Where instance1 corresponds to an instance of struct A, such as:

**Listing 2:**

    A->x = 0x00000001         = 1
    A->y = 0x00000002         = 2
    A->f = 0x000048C1         = -12.5
    A->d = 0x9A99999999993C40 = 28.6

**The Task:**

Write an application that takes as a text file, an arbitrary C data structure, and an arbitrary memory dump, and print out in an easy-to-read format, a reconstruction of the instance of that struct (such as what is seen in Listing 2).

**The Questions:**

 1. What is the best way to do this?
 2. Rather than re-invent the wheel, is(are) there any Open-source solutions that this problem might benefit from?

**Things to consider:**

The solution will have to

 1. take into account the length of the datatype.
 2. handle different address models and endianness.
 3. display both hex, and a native display for that particular data type.
 4. take C structs that were NOT linked into the program you are writing.

**Bonus Question:**

Handle a case with embedded structs:

    typedef struct{
      int    q;
      int    p;
      A      a;  //embedded struct of type A defined in listing 1
    } B;

Thanks in advance everyone!
C/C++ map binary data to struct members
===

Lets say, I have the following text file:

**Listing 1:**

    Endianess=little
    AddressModel=32

    typedef struct{
      int    x;
      int    y;
      float  f;
      double d;
    } A;

    instance1:0x0000000100000002000048C19A99999999993C40
    instance2:0x00100257000000090000000FBA99359976992397

Where instance1 corresponds to an instance of struct A, such as:

**Listing 2:**

    A->x = 0x00000001         = 1
    A->y = 0x00000002         = 2
    A->f = 0x000048C1         = -12.5
    A->d = 0x9A99999999993C40 = 28.6

**The Task:**

Write an application that takes as a text file, an arbitrary C data structure, and an arbitrary memory dump, and print out in an easy-to-read format, a reconstruction of the instance of that struct (such as what is seen in Listing 2).

**The Questions:**

 1. What is the best way to do this?
 2. Rather than re-invent the wheel, is(are) there any Open-source solutions that this problem might benefit from?

**Things to consider:**

The solution will have to

 1. take into account the length of the datatype.
 2. handle different address models and endianness.
 3. display both hex, and a native display for that particular data type.
 4. take C structs that were NOT linked into the program you are writing.

**Bonus Question:**

Handle a case with embedded structs:

    typedef struct{
      int    q;
      int    p;
      A      a;  //embedded struct of type A defined in listing 1
    } B;

Thanks in advance everyone!