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

Method _processChooseTag

plugins/esi/lib/EsiParser.cc:547–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547bool
548EsiParser::_processChooseTag(const string &data, size_t curr_pos, size_t end_pos, DocNodeList &node_list) const
549{
550 const char *data_start_ptr = data.data() + curr_pos;
551 size_t data_size = end_pos - curr_pos;
552 DocNode choose_node(DocNode::TYPE_CHOOSE);
553 if (!parse(choose_node.child_nodes, data_start_ptr, data_size)) {
554 TSError("[%s] Couldn't parse choose node content", __FUNCTION__);
555 return false;
556 }
557 DocNodeList::iterator end_node = choose_node.child_nodes.end();
558 DocNodeList::iterator otherwise_node = end_node, iter, temp_iter;
559 iter = choose_node.child_nodes.begin();
560 while (iter != end_node) {
561 if (iter->type == DocNode::TYPE_OTHERWISE) {
562 if (otherwise_node != end_node) {
563 TSError("[%s] Cannot have more than one esi:otherwise node in an esi:choose node", __FUNCTION__);
564 return false;
565 }
566 otherwise_node = iter;
567 } else if (iter->type == DocNode::TYPE_PRE) {
568 if (!_isWhitespace(iter->data, iter->data_len)) {
569 TSError("[%s] Cannot have non-whitespace raw text (%s) as top-level node in choose data", __FUNCTION__,
570 DocNode::type_names_[iter->type]);
571 return false;
572 }
573 Dbg(dbg_ctl, "[%s] Ignoring top-level whitespace raw text", __FUNCTION__);
574 temp_iter = iter;
575 ++temp_iter;
576 choose_node.child_nodes.erase(iter);
577 iter = temp_iter;
578 continue; // skip the increment
579 } else if (iter->type != DocNode::TYPE_WHEN) {
580 TSError("[%s] Cannot have %s as top-level node in choose data; only when/otherwise/whitespace-text "
581 "permitted",
582 __FUNCTION__, DocNode::type_names_[iter->type]);
583 return false;
584 }
585 ++iter;
586 }
587 node_list.push_back(choose_node);
588 return true;
589}
590
591void
592EsiParser::clear()

Callers

nothing calls this directly

Calls 7

parseFunction · 0.85
TSErrorFunction · 0.50
dataMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected