Skip to content

Commit

Permalink
use Child helpers in test00
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Mar 2, 2024
1 parent 330af6b commit ac630fd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/ebml/test00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,37 @@ int main(void)
// size is unknown and will always be, we can render it right away
FirstSegment.Render(Ebml_file);

KaxAttachments * pAllAttachments = static_cast<KaxAttachments *>(FirstSegment.FindFirstElt(EBML_INFO(KaxAttachments), true));
KaxAttachments * pAllAttachments = &GetChild<KaxAttachments>(FirstSegment);
if (pAllAttachments == NULL)
return -1;
pAllAttachments->SetSizeInfinite();
// size is unknown and will always be, we can render it right away
pAllAttachments->Render(Ebml_file);

KaxAttached * pAttachment1 = static_cast<KaxAttached *>(pAllAttachments->FindFirstElt(EBML_INFO(KaxAttached), true));
KaxAttached * pAttachment1 = &GetChild<KaxAttached>(*pAllAttachments);
if (pAttachment1 == NULL)
return -1;
KaxFileName * pFileName1 = static_cast<KaxFileName *>(pAttachment1->FindFirstElt(EBML_INFO(KaxFileName), true));
KaxFileName * pFileName1 = &GetChild<KaxFileName>(*pAttachment1);
if (pFileName1 == NULL)
return -1;
pFileName1->SetValue(UTFstring{L"file1.txt"});
KaxFileData * pFileData1 = static_cast<KaxFileData *>(pAttachment1->FindFirstElt(EBML_INFO(KaxFileData), true));
KaxFileData * pFileData1 = &GetChild<KaxFileData>(*pAttachment1);
if (pFileData1 == NULL)
return -1;
char Buffer1[] = "Ah ah ah !";
static_cast<EbmlBinary *>(pFileData1)->SetBuffer((const binary*) Buffer1, countof(Buffer1));
// should produce an error if the size is not infinite and the data has been rendered
pAttachment1->Render(Ebml_file);

KaxAttached * pAttachment2 = static_cast<KaxAttached *>(pAllAttachments->AddNewElt(EBML_INFO(KaxAttached)));
KaxAttached * pAttachment2 = &AddNewChild<KaxAttached>(*pAllAttachments);
if (pAttachment2 == NULL)
return -1;
KaxFileName * pFileName2 = static_cast<KaxFileName *>(pAttachment2->FindFirstElt(EBML_INFO(KaxFileName), true));
KaxFileName * pFileName2 = &GetChild<KaxFileName>(*pAttachment2);
if (pFileName2 == NULL)
return -1;
pFileName2->SetValue(UTFstring{L"file2.txt"});
// Add a void element (data is discarded)
EbmlVoid * pVoid = static_cast<EbmlVoid *>(pAttachment2->FindFirstElt(EBML_INFO(EbmlVoid), true));
EbmlVoid * pVoid = &GetChild<EbmlVoid>(*pAttachment2);
if (pVoid == NULL)
return -1;
static_cast<EbmlBinary *>(pVoid)->SetBuffer((const binary*) Buffer1, countof(Buffer1));
Expand Down

0 comments on commit ac630fd

Please sign in to comment.