bool GetMarkerRegionDesc(const char* _name, bool _isrgn, int _num, double _pos, double _end, int _flags, bool _wantNum, bool _wantName, bool _wantTime, char* _descOut, int _outSz) { if (_descOut && _outSz && ((_isrgn && _flags&SNM_REGION_MASK) || (!_isrgn && _flags&SNM_MARKER_MASK))) { WDL_FastString desc; bool comma = !_wantNum; if (_wantNum) desc.SetFormatted(64, "%d", _num); if (_wantName && _name && *_name) { if (!comma) { desc.Append(": "); comma = true; } desc.Append(_name); } if (_wantTime) { if (!comma) { desc.Append(": "); comma = true; } char timeStr[64] = ""; format_timestr_pos(_pos, timeStr, sizeof(timeStr), -1); desc.Append(" ["); desc.Append(timeStr); if (_isrgn) { desc.Append(" -> "); format_timestr_pos(_end, timeStr, sizeof(timeStr), -1); desc.Append(timeStr); } desc.Append("]"); } lstrcpyn(_descOut, desc.Get(), _outSz); return true; } return false; }
char* MarkerList::GetFormattedList(const char* format) // Must delete [] returned string { SWS_SectionLock lock(&m_mutex); int iLen = ApproxSize()*2; char* str = new char[iLen]; str[0] = 0; double dEnd = SNM_GetProjectLength(); char* s = str; int count = 1; for (int i = 0; i < m_items.GetSize(); i++) { if (format[0] == 'a' || (format[0] == 'r' && m_items.Get(i)->IsRegion()) || (format[0] == 'm' && !m_items.Get(i)->IsRegion())) { // Cheat a bit and use the region end variable for markers as "location of next marker or eop" if (!m_items.Get(i)->IsRegion()) { if (i < m_items.GetSize() - 1) m_items.Get(i)->SetRegEnd(m_items.Get(i+1)->GetPos()); else m_items.Get(i)->SetRegEnd(dEnd); } for (unsigned int j = 1; j < strlen(format); j++) { switch(format[j]) { case 'n': s += sprintf(s, "%d", count++); break; case 'i': s += sprintf(s, "%d", m_items.Get(i)->GetNum()); break; case 'l': { double len = m_items.Get(i)->GetRegEnd() - m_items.Get(i)->GetPos(); if (len < 0.0) len = 0.0; format_timestr_pos(len, s, (int)(iLen-(s-str)), 5); s += strlen(s)-3; s[0] = 0; break; } case 'd': s += sprintf(s, "%s", m_items.Get(i)->GetName()); break; case 't': format_timestr_pos(m_items.Get(i)->GetPos(), s, (int)(iLen-(s-str)), 5); s += strlen(s)-3; s[0] = 0; break; case 'T': format_timestr_pos(m_items.Get(i)->GetPos(), s, (int)(iLen-(s-str)), 5); s += strlen(s); // Change the final : to a . s[-3] = '.'; break; case 's': format_timestr_pos(m_items.Get(i)->GetPos(), s, (int)(iLen-(s-str)), 4); s += strlen(s); break; case 'p': format_timestr_pos(m_items.Get(i)->GetPos(), s, (int)(iLen-(s-str)), -1); s += strlen(s); break; case '\\': j++; s[0] = format[j]; s++; break; default: s[0] = format[j]; s[1] = 0; s++; } } strcpy(s, "\r\n"); s += 2; } } return str; }