[timing] Some progress...I think.

This commit is contained in:
Jason Felds
2011-07-15 19:04:54 -04:00
parent c454bb9c14
commit a785bcf905
2 changed files with 31 additions and 8 deletions
+13
View File
@@ -149,6 +149,19 @@ namespace JsonUtil
fn(*v[i], root[i]);
}
}
template<class T>
static void DeserializeVectorPointers(vector<T*> &v, void fn(T *, const Json::Value &), const Json::Value &root)
{
for(unsigned i=0; i<v.size(); i++)
SAFE_DELETE(v[i]);
v.resize(root.size());
for(unsigned i=0; i<v.size(); i++)
{
v[i] = new T;
fn(*v[i], root[i]);
}
}
template<class T>
static void DeserializeArrayValues(vector<T> &v, const Json::Value &root)
+18 -8
View File
@@ -15,16 +15,26 @@ void NotesLoaderJson::GetApplicableFiles( const RString &sPath, vector<RString>
GetDirListing( sPath + RString("*.json"), out );
}
static void Deserialize(TimingSegment &seg, const Json::Value &root)
static void Deserialize(TimingSegment &seg_, const Json::Value &root)
{
seg.SetBeat((float)(root["Beat"].asDouble()));
if (seg.GetType() == SEGMENT_BPM)
TimingSegment *seg = &seg_;
float fBeat = root["Beat"].asDouble();
seg->SetBeat(fBeat);
switch (seg->GetType())
{
static_cast<BPMSegment &>(seg).SetBPM((float)(root["BPM"].asDouble()));
}
else
{
static_cast<StopSegment &>(seg).SetPause((float)(root["Seconds"].asDouble()));
case SEGMENT_BPM:
{
float fBPM = root["BPM"].asDouble();
static_cast<BPMSegment *>(seg)->SetBPM(fBPM);
break;
}
case SEGMENT_STOP_DELAY:
{
float fStop = root["Seconds"].asDouble();
static_cast<StopSegment *>(seg)->SetPause(fStop);
break;
}
}
}