freeMXF.org
http://freemxf.org/forum/

Transferring between MDOObjects
http://freemxf.org/forum/viewtopic.php?f=2&t=239
Page 1 of 1

Author:  enpingado [ Fri Mar 18, 2011 9:15 pm ]
Post subject:  Transferring between MDOObjects

I am trying to write read klv to/from a buffer.

I create an MDObject, set its value, then write out the klv form to a datachunk.

then i make a new MDObject of same type,and without setting values i write to data chunk to get a pointer to the dataachunk.

then i make the new data chunk pointer 'point' to the original data chunk.

When i do a get string of the new datachunk i see the correct bytes.


but if i try to access the value via the new MDObject it still appears empty.


How can i load an MDObject from a buffer that contains the klv formatted data?

Is this not the correct approach?

Can i not gofrom MDObject to KLV format(in a buffer) back to an MDObject?


I guess i am confused as to how the datachunk relates to the MDObject. Does each MDObject store data in a datachunk that it creates?

thanks
jorge

Author:  Matt Beard [ Wed Mar 23, 2011 10:52 am ]
Post subject: 

I am not entirely sure that I understand what you are asking, but hopefully the following will help:

MDObject::PutData() will build a DataChunk containing the value of the object formatted for the V part of the KLV.

MDObject::ReadValue() will set the value of an MDObject from a DataChunk of the format written by PutData().

So:
Code:
// Build an MDObject suitable for LastModifiedDate property of the Preface (of data type TimeStamp)
MDObjectPtr First = new MDObjectPtr(LastModifiedDate_UL);

// Set a value of noon on November the first 2010
First->SetString("2010-11-01T12:00:00.00");

// Write this into a buffer
DataChunkPtr Val = First->PutData();

// Val now contains the following bytes: 0x07, 0xda, 0x0b, 0x01, 0x0c, 0x00, 0x00, 0x00
// This is the year (0x07da == 2010), month (0x0b = 11), day (0x01 = 1), hour (0x0c = 12) etc.

// Make another object of the same type
MDObjectPtr Second = new MDObjectPtr(LastModifiedDate_UL);

// Set the second object from the data chunk
Second->ReadValue(Val);

// Print "2010-11-01T12:00:00.00"
cout << Second->GetString();

Author:  enpingado [ Wed Mar 30, 2011 7:17 pm ]
Post subject:  works for me

That is what i am looking for. I appreciate the help.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/