Example #1
0
bool CLogThread::FlattenTree(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& tree,StringBuffer& RootName)
{
    StringBuffer Value,Name;
    if (tree.hasChildren() == true)
    {

        Owned<IPropertyTreeIterator> itr =  tree.getElements("*");
        itr->first();
        while(itr->isValid())
        {
            IPropertyTree &node = itr->query();
            if(RootName.length() > 0)
                Name.appendf("%s_",RootName.str());
            Name.appendf("%s",node.queryName());

            if (node.hasChildren() == true)
            {
                if(IsArray(node)==true)
                    FlattenArray(valueArray,node,Name);
                else
                    FlattenTree(valueArray,node,Name);
            }
            else
            {
                const char* _value = tree.queryProp(node.queryName());
                if(tree.hasProp(node.queryName())==true && _value!=0 && _value!='\0')
                {
                    Value.appendf("%s",tree.queryProp(node.queryName()));
                    IClientLogInfo& logElement = addLogInfoElement(valueArray);
                    logElement.setName(Name.str());
                    logElement.setValue(Value.str());
                    //DBGLOG("Add log element: %s, %s", Name.str(), Value.str());
                    Value.clear();
                }
            }
            Name.clear();
            itr->next();
        }

    }
    else
    {
        return false;
    }
    return true;
}
Example #2
0
bool CLogThread::FlattenArray(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& tree,StringBuffer& RootName)
{
    StringBuffer Value,Name;
    if (tree.hasChildren() == true)
    {
        Name.appendf("%s",tree.queryName());
        Owned<IPropertyTreeIterator> itrItem =  tree.getElements("./*");
        itrItem->first();
        while(itrItem->isValid()==true)
        {
            IPropertyTree &node = itrItem->query();
            if(Value.length()!=0)
                Value.append(",");
            Value.appendf("%s",node.queryProp(""));
            itrItem->next();
        }
        IClientLogInfo& logElement = addLogInfoElement(valueArray);
        logElement.setName(Name.str());
        logElement.setValue(Value.str());

    }
    return true;
}