cwPianoScore.h : Added test().

This commit is contained in:
kevin 2021-12-25 22:12:56 -05:00
parent 02311b3305
commit 55b860b34c
2 changed files with 33 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include "cwObject.h"
#include "cwPianoScore.h"
#include "cwMidi.h"
#include "cwTime.h"
namespace cw
{
@ -46,15 +47,16 @@ namespace cw
rc = cwLogError( rc, "Unable to locate the 'evtL' configuration tag.");
else
{
unsigned eventN = eventL->child_count();
//unsigned eventN = eventL->child_count();
const object_t* evt_cfg = eventL->next_child_ele(nullptr);
for(unsigned i=0; i<eventN; ++i)
for(unsigned i=0; evt_cfg != nullptr; evt_cfg = eventL->next_child_ele(evt_cfg),++i)
{
const char* sci_pitch = nullptr;
const char* dmark = nullptr;
const char* grace_mark = nullptr;
const object_t* evt_cfg = eventL->child_ele(i);
//const object_t* evt_cfg = eventL->next_child_ele(i);
event_t* e = mem::allocZ<event_t>();
@ -248,3 +250,30 @@ bool cw::score::is_loc_valid( handle_t h, unsigned locId )
score_t* p = _handleToPtr(h);
return locId < p->maxLocId;
}
cw::rc_t cw::score::test( const object_t* cfg )
{
handle_t h;
rc_t rc = kOkRC;
const char* fname = nullptr;
if((rc = cfg->getv( "filename", fname )) != kOkRC )
{
rc = cwLogError(rc,"Arg. parsing failed.");
goto errLabel;
}
if((rc = create( h, fname )) != kOkRC )
{
rc = cwLogError(rc,"Score create failed.");
goto errLabel;
}
cwLogInfo("Score created from '%s'.",cwStringNullGuard(fname));
errLabel:
destroy(h);
return rc;
}

View File

@ -43,7 +43,7 @@ namespace cw
// Format the event as a string for printing.
rc_t event_to_string( handle_t h, unsigned uid, char* buf, unsigned buf_byte_cnt );
rc_t test( const object_t* cfg );
}
}