cwPianoScore.h/cpp : Add uid_to_event().
This commit is contained in:
parent
1a186ebbad
commit
d52f20c8ce
@ -17,6 +17,11 @@ namespace cw
|
|||||||
event_t* base;
|
event_t* base;
|
||||||
event_t* end;
|
event_t* end;
|
||||||
unsigned maxLocId;
|
unsigned maxLocId;
|
||||||
|
|
||||||
|
event_t** uid_mapA;
|
||||||
|
unsigned uid_mapN;
|
||||||
|
unsigned min_uid;
|
||||||
|
|
||||||
} score_t;
|
} score_t;
|
||||||
|
|
||||||
score_t* _handleToPtr(handle_t h)
|
score_t* _handleToPtr(handle_t h)
|
||||||
@ -165,6 +170,7 @@ namespace cw
|
|||||||
unsigned line_count = 0;
|
unsigned line_count = 0;
|
||||||
char* lineBufPtr = nullptr;
|
char* lineBufPtr = nullptr;
|
||||||
unsigned lineBufCharCnt = 0;
|
unsigned lineBufCharCnt = 0;
|
||||||
|
event_t* e = nullptr;
|
||||||
|
|
||||||
if((rc = file::open( fH, fn, file::kReadFl )) != kOkRC )
|
if((rc = file::open( fH, fn, file::kReadFl )) != kOkRC )
|
||||||
{
|
{
|
||||||
@ -178,11 +184,12 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->min_uid = kInvalidId;
|
||||||
|
p->uid_mapN = 0;
|
||||||
|
|
||||||
for(unsigned line=0; line<line_count; ++line)
|
for(unsigned line=0; line<line_count; ++line)
|
||||||
if( line > 0 ) // skip column title line
|
if( line > 0 ) // skip column title line
|
||||||
{
|
{
|
||||||
event_t* e = mem::allocZ<event_t>();
|
|
||||||
|
|
||||||
if((rc = getLineAuto( fH, &lineBufPtr, &lineBufCharCnt )) != kOkRC )
|
if((rc = getLineAuto( fH, &lineBufPtr, &lineBufCharCnt )) != kOkRC )
|
||||||
{
|
{
|
||||||
@ -190,8 +197,11 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e = mem::allocZ<event_t>();
|
||||||
|
|
||||||
if((rc = _parse_csv_line( p, e, lineBufPtr, lineBufCharCnt )) != kOkRC )
|
if((rc = _parse_csv_line( p, e, lineBufPtr, lineBufCharCnt )) != kOkRC )
|
||||||
{
|
{
|
||||||
|
mem::release(e);
|
||||||
rc = cwLogError( rc, "Line parse failed on '%s' line number '%i'.",cwStringNullGuard(fn),line+1);
|
rc = cwLogError( rc, "Line parse failed on '%s' line number '%i'.",cwStringNullGuard(fn),line+1);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
@ -211,6 +221,10 @@ namespace cw
|
|||||||
if( e->loc > p->maxLocId )
|
if( e->loc > p->maxLocId )
|
||||||
p->maxLocId = e->loc;
|
p->maxLocId = e->loc;
|
||||||
|
|
||||||
|
if( p->min_uid == kInvalidId || e->uid < p->min_uid )
|
||||||
|
p->min_uid = e->uid;
|
||||||
|
|
||||||
|
p->uid_mapN += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,6 +354,8 @@ cw::rc_t cw::score::create( handle_t& hRef, const char* fn )
|
|||||||
|
|
||||||
rc = _parse_csv(p,fn);
|
rc = _parse_csv(p,fn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hRef.set(p);
|
hRef.set(p);
|
||||||
|
|
||||||
//errLabel:
|
//errLabel:
|
||||||
@ -451,6 +467,13 @@ bool cw::score::is_loc_valid( handle_t h, unsigned locId )
|
|||||||
return locId < p->maxLocId;
|
return locId < p->maxLocId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cw::score::event_t* cw::score::uid_to_event( handle_t h, unsigned uid )
|
||||||
|
{
|
||||||
|
|
||||||
|
score_t* p = _handleToPtr(h);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cw::rc_t cw::score::test( const object_t* cfg )
|
cw::rc_t cw::score::test( const object_t* cfg )
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,8 @@ namespace cw
|
|||||||
unsigned loc_count( handle_t h );
|
unsigned loc_count( handle_t h );
|
||||||
bool is_loc_valid( handle_t h, unsigned locId );
|
bool is_loc_valid( handle_t h, unsigned locId );
|
||||||
|
|
||||||
|
const event_t* uid_to_event( handle_t h, unsigned uid );
|
||||||
|
|
||||||
// Format the event as a string for printing.
|
// 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 event_to_string( handle_t h, unsigned uid, char* buf, unsigned buf_byte_cnt );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user