void GCGVCallgraph_ReqGraph::AddNode(NodePtr node, size_t node_depth) {
    if (node_depth == request.Get<depth>()) {
       // The top-level node lives in the top-level JSON, so does not need an
       // object wrapper
    } else {
        builder.StartAnonymousObject();
    }

    builder.Add("name",node->Name());
    if (node->Name().length() > 50) {
        builder.Add("shortName",node->Name().substr(0,50));
    } else  {
        builder.Add("shortName",node->Name());
    }
    builder.Add("cost",node->Costs()[0]);

    if (node_depth>0 && node->NumChildren() > 0)
    {
        builder.StartArray("children");
        node-> ForEach([&] (NodePtr child) -> void {
            this->AddNode(child,node_depth-1);
        });
        builder.EndArray();

    }

    if (node_depth == request.Get<depth>()) {
       // The top-level node lives in the top-level JSON, so does not need an
       // object wrapper
    } else {
        builder.EndObject();
    }

}
void RegSearch::AddTree(NodePtr& node, int depth) {
    if ( regPattern && regPattern->Search(node->Name()) ) {
        this->AddNode(node);
    } else {
        SLOG_FROM(LOG_VERBOSE,"RegSearch::Search",
           "Rejected Node: " << node->Name() )
    }

    --depth;
    if ( depth != 0 ) {
        node->ForEach([=] ( NodePtr&& node ) -> void {
            this->AddTree(node, depth);
        });
    }
}
Esempio n. 3
0
std::string NodeUserApp::PrintPopdStack() {
    std::string lines;

    NodePtr pwd = application.ActiveNode();
    if ( pwd->Parent().IsNull() ) {
        lines += pwd->Name();
    } else {
        lines += pwd->Parent()->Name() + "/" + pwd->Name();
    }

    for ( const NodePtr& node: popdstack ) {
        lines += "\n";
        if ( node->Parent().IsNull() ) {
            lines += node->Name();
        } else {
            lines += node->Parent()->Name() + "/" + node->Name();
        }
    }
    lines += "\n";
    return lines;
}
void GCGV_ReqGetNodes::SortedNodes::AddTree(
    NodePtr root,
    SORT_BY sort,
    const std::string& filter,
    int depth)
{
    if (root->Name() == filter) {
        AddNode(root,sort);
    }

    --depth;
    if (depth != -1) {
        root->ForEach([=] (NodePtr&& node) -> void {
            this->AddTree(node,sort,filter,depth);
        });
    }
}