Read a whole array of objects !

greetings ppl,

I am using Visual studio 2008 and I write to the serial port an array of objects via WriteFile API function.The problem I am facing is "how I can read this array in my arduinoBT for further process ?" ... I give you a simple example so you can undestand me :

I have the follow class :

class ValueClass
{
private:
  int Value;
public:
  void setValue(int aNumber){Value = aNumber}
  int getValue(){return Value;}
}

I am filling an array of objects :

ValueClass allValues = new ValueClass [3];

and finally I am sending the array as follows :

hSerial = CreateFile("COM1",
                  GENERIC_WRITE,
                  0,
                  0,
                  OPEN_EXISTING,
                  FILE_ATTRIBUTE_NORMAL,
                  0);

ok = WriteFile(hSerial,allValues, 3 * sizeof(ValueClass), &dwBytesWritten, NULL);

Now, I have to read the array(allValues) in my board...
any suggestion ?

As far as the Arduino is concerned, there's nothing to read: "Value" is private, and "setValue" and "getValue" are methods which would make no sense to Arduino.

I am filling an array of objects :

You're just instantiating an array of objects, surely?

Otherwise, the way you read an array is the same way you eat an elephant: one bite at a time.

I mean, how I can reconstruct my original array?..
I know that I can read 1 byte at a time and I wrote a simple sketch trying to read the whole array.

class ValueClass
{
private:
  int Value;
public:
  void setValue(int aNumber){Value = aNumber}
  int getValue(){return Value;}
} 

byte buffer[3*sizeof(ValueClass)];

void setup()
{
Serial.begin(115200);
}
void loop()
{
while (Serial.available() < 3*sizeof(ValueClass) ){}

for(int i=0; i<3*sizeof(ValueClass); i++)
   buffer[i] = Serial.read(); 
}

So I remake my question..How I can reconstruct the buffer into an array of ValueClass Objects ?

How I can reconstruct the buffer into an array of ValueClass Objects ?

You can't. You are trying to marshal and unmarshal a object across completely different operating systems.

How would you expect the getValue function to operate on the Arduino?

First you need to make sure you know what the endianess of both parts of the transfer is.
If it's the same, then it's dead easy; if they're different, then it's very slightly less dead easy.
And make sure an "int" is the same size on both platforms...