Esempio n. 1
0
Definition& Definition::operator[](LPCWSTR type)
{
    Definition* pRetDef = NULL;
    if(m_type2def.Lookup(type, pRetDef))
        return *pRetDef;

    pRetDef = DNew Definition(m_pnf, L"");
    pRetDef->m_priority = PLow;
    pRetDef->m_type = type;
    m_type2def[type] = pRetDef;

    CAtlList<Definition*> l;
    GetChildDefs(l, type);

    while(!l.IsEmpty())
    {
        Definition* pDef = l.RemoveHead();

        pRetDef->m_priority = pDef->m_priority;
        pRetDef->m_parent = pDef->m_parent;

        if(pDef->IsValue())
        {
            pRetDef->SetAsValue(pDef->m_status, pDef->m_value, pDef->m_unit);
        }
        else
        {
            pRetDef->m_status = node;
            pRetDef->m_nodes.AddTailList(&pDef->m_nodes);
        }
    }

    return *pRetDef;
}
Esempio n. 2
0
Definition* Definition::SetChildAsValue(CStringW path, status_t s, CStringW v, CStringW u)
{
    Definition* pDef = this;

    Split split('.', path);

    for(size_t i = 0, j = split - 1; i <= j; i++)
    {
        CStringW type = split[i];

        if(pDef->m_nodes.IsEmpty() || !dynamic_cast<Reference*>(pDef->m_nodes.GetTail()))
        {
            EXECUTE_ASSERT(m_pnf->CreateRef(pDef) != NULL);
        }

        if(Reference* pRef = dynamic_cast<Reference*>(pDef->m_nodes.GetTail()))
        {
            pDef = NULL;

            POSITION pos = pRef->m_nodes.GetTailPosition();
            while(pos)
            {
                Definition* pChildDef = dynamic_cast<Definition*>(pRef->m_nodes.GetPrev(pos));

                if(pChildDef->IsType(type))
                {
                    if(pChildDef->IsNameUnknown()) pDef = pChildDef;
                    break;
                }
            }

            if(!pDef)
            {
                pDef = m_pnf->CreateDef(pRef, type);
            }

            if(i == j)
            {
                pDef->SetAsValue(s, v, u);
                return pDef;
            }
        }
    }

    return NULL;
}