MCPcopy Create free account
hub / github.com/apache/trafficserver / _handleChoose

Method _handleChoose

plugins/esi/lib/EsiProcessor.cc:541–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541bool
542EsiProcessor::_handleChoose(DocNodeList::iterator &curr_node)
543{
544 DocNodeList::iterator iter, otherwise_node, winning_node, end_node;
545 end_node = curr_node->child_nodes.end();
546 otherwise_node = end_node;
547 for (iter = curr_node->child_nodes.begin(); iter != end_node; ++iter) {
548 if (iter->type == DocNode::TYPE_OTHERWISE) {
549 otherwise_node = iter;
550 break;
551 }
552 }
553 winning_node = end_node;
554 for (iter = curr_node->child_nodes.begin(); iter != end_node; ++iter) {
555 if (iter->type == DocNode::TYPE_WHEN) {
556 const Attribute &test_expr = iter->attr_list.front();
557 if (_expression.evaluate(test_expr.value, test_expr.value_len)) {
558 winning_node = iter;
559 break;
560 }
561 }
562 }
563 if (winning_node == end_node) {
564 DBG("[%s] All when nodes failed to evaluate to true", __FUNCTION__);
565 if (otherwise_node != end_node) {
566 DBG("[%s] Using otherwise node...", __FUNCTION__);
567 winning_node = otherwise_node;
568 } else {
569 DBG("[%s] No otherwise node, nothing to do...", __FUNCTION__);
570 return true;
571 }
572 }
573 // splice() inserts elements *before* given position, but we need to
574 // insert new nodes after the choose node for them to be seen by
575 // preprocess(); hence...
576 DocNodeList::iterator next_node = curr_node;
577 ++next_node;
578 _node_list.splice(next_node, winning_node->child_nodes);
579 return true;
580}
581
582bool
583EsiProcessor::_handleTry(DocNodeList::iterator &curr_node)

Callers

nothing calls this directly

Calls 3

endMethod · 0.45
beginMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected