예제 #1
0
	void Renderer::NextSegment(const CAutoPtrList<Subtitle>& subs)
	{
		StringMapW<bool> names;
		POSITION pos = subs.GetHeadPosition();
		while(pos) names[subs.GetNext(pos)->m_name] = true;

		pos = m_sra.GetStartPosition();
		while(pos)
		{
			POSITION cur = pos;
			const CStringW& name = m_sra.GetNextKey(pos);
			if(!names.Lookup(name)) m_sra.RemoveAtPos(cur);
		}
	}
예제 #2
0
bool Definition::GetAsTime(Time& t, StringMapW<float>& offset, StringMapW<float>* n2n, int default_id)
{
    Definition& time = (*this)[L"time"];

    CStringW id;
    if(time[L"id"].IsValue()) id = time[L"id"];
    else id.Format(L"%d", default_id);

    float scale = time[L"scale"].IsValue() ? time[L"scale"] : 1.0f;

    if(time[L"start"].IsValue() && time[L"stop"].IsValue())
    {
        time[L"start"].GetAsNumber(t.start, n2n);
        time[L"stop"].GetAsNumber(t.stop, n2n);

        if(t.start.unit.IsEmpty()) t.start.value *= scale;
        if(t.stop.unit.IsEmpty()) t.stop.value *= scale;

        float o = 0;
        offset.Lookup(id, o);

        if(t.start.sign != 0) t.start.value = o + t.start.value;
        if(t.stop.sign != 0) t.stop.value = t.start.value + t.stop.value;

        offset[id] = t.stop.value;

        return true;
    }

    return false;
}
예제 #3
0
void Definition::GetAsBoolean(bool& b)
{
    static StringMapW<bool> s2b;

    if(s2b.IsEmpty())
    {
        s2b[L"true"] = true;
        s2b[L"on"] = true;
        s2b[L"yes"] = true;
        s2b[L"1"] = true;
        s2b[L"false"] = false;
        s2b[L"off"] = false;
        s2b[L"no"] = false;
        s2b[L"0"] = false;
    }

    if(!s2b.Lookup(m_value, b)) // m_status != boolean && m_status != number ||
    {
        throw Exception(_T("expected boolean"));
    }
}