• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ xpath::NodeSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中arabica::xpath::NodeSet的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet类的具体用法?C++ NodeSet怎么用?C++ NodeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了NodeSet类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

Arabica::XPath::NodeSet<std::string> InterpreterDraft6::filterPreempted(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
	Arabica::XPath::NodeSet<std::string> filteredTransitions;
	for (unsigned int i = 0; i < enabledTransitions.size(); i++) {
		Node<std::string> t = enabledTransitions[i];
		if (!isTargetless(t)) {
			for (unsigned int j = 0; j < filteredTransitions.size(); j++) {
				if (j == i)
					continue;
				Node<std::string> t2 = filteredTransitions[j];
				if (isPreemptingTransition(t2, t)) {
#if 0
					std::cout << "#####" << std::endl << "Transition " << std::endl
					          << t2 << std::endl << " preempts " << std::endl << t << std::endl << "#####" << std::endl;
#endif
					goto LOOP;
				}
			}
		}
#if 0
		std::cout << "----" << "Enabling Transition " << std::endl << t << std::endl;
#endif

		filteredTransitions.push_back(t);
LOOP:
		;
	}
	return filteredTransitions;
}
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:28,代码来源:InterpreterDraft6.cpp


示例2: doEvaluate

  virtual Arabica::XPath::NodeSet<std::string> doEvaluate(const DOM::Node<std::string>& /* context */, 
							  const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
  {
    Arabica::XPath::NodeSet<std::string> set;
    set.push_back(executionContext.currentNode());
    return set;
  } // doEvaluate
开发者ID:alepharchives,项目名称:arabica,代码行数:7,代码来源:xslt_functions.hpp


示例3: execute

  virtual void execute(const DOM::Node<string_type, string_adaptor>& node, 
                       ExecutionContext<string_type, string_adaptor>& context) const
  {
    ParamPasser<string_type, string_adaptor> passer(*this, node, context);

    if(!SortableT::has_sort() && select_ == 0)
    {
      if(node.hasChildNodes())
        context.stylesheet().applyTemplates(node.getChildNodes(), context, mode_);
      return;
    }

    Arabica::XPath::NodeSet<string_type, string_adaptor> nodes;
    if(select_ == 0)
      for(DOM::Node<string_type, string_adaptor> n = node.getFirstChild(); n != 0; n = n.getNextSibling())
        nodes.push_back(n);
    else
    {
      Arabica::XPath::XPathValue<string_type, string_adaptor> value = select_->evaluate(node, context.xpathContext());
      if(value.type() != Arabica::XPath::NODE_SET)
        throw std::runtime_error("apply-templates select expression is not a node-set");
      nodes = value.asNodeSet();
    }
    this->sort(node, nodes, context);
    context.stylesheet().applyTemplates(nodes, context, mode_);
  } // execute
开发者ID:QuentinFiard,项目名称:arabica,代码行数:26,代码来源:xslt_apply_templates.hpp


示例4: getTargetStates

void InterpreterDraft6::microstep(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
#if VERBOSE
	std::cout << "Transitions: ";
	for (int i = 0; i < enabledTransitions.size(); i++) {
		std::cout << ((Element<std::string>)getSourceState(enabledTransitions[i])).getAttribute("id") << " -> " << std::endl;
		NodeSet<std::string> targetSet = getTargetStates(enabledTransitions[i]);
		for (int j = 0; j < targetSet.size(); j++) {
			std::cout << "    " << ((Element<std::string>)targetSet[j]).getAttribute("id") << std::endl;
		}
	}
	std::cout << std::endl;
#endif

	// --- MONITOR: beforeMicroStep ------------------------------
	for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
		try {
			(*monIter)->beforeMicroStep(shared_from_this());
		}
		USCXML_MONITOR_CATCH_BLOCK(beforeMicroStep)
	}

	exitStates(enabledTransitions);

	monIter_t monIter;
	for (int i = 0; i < enabledTransitions.size(); i++) {
		Element<std::string> transition(enabledTransitions[i]);

		// --- MONITOR: beforeTakingTransitions ------------------------------
		for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
			try {
				(*monIter)->beforeTakingTransition(shared_from_this(), transition, (i + 1 < enabledTransitions.size()));
			}
			USCXML_MONITOR_CATCH_BLOCK(beforeTakingTransitions)
		}

		executeContent(transition);

		// --- MONITOR: afterTakingTransitions ------------------------------
		for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
			try {
				(*monIter)->afterTakingTransition(shared_from_this(), transition, (i + 1 < enabledTransitions.size()));
			}
			USCXML_MONITOR_CATCH_BLOCK(afterTakingTransitions)
		}
	}

	enterStates(enabledTransitions);

	// --- MONITOR: afterMicroStep ------------------------------
	for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
		try {
			(*monIter)->afterMicroStep(shared_from_this());
		}
		USCXML_MONITOR_CATCH_BLOCK(afterMicroStep)
	}

}
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:57,代码来源:InterpreterDraft6.cpp


示例5: beforeCompletion

	void beforeCompletion(uscxml::Interpreter interpreter) {
		Arabica::XPath::NodeSet<std::string> config = interpreter.getConfiguration();
		if (config.size() == 1 && boost::iequals(ATTR(config[0], "id"), "pass")) {
			std::cout << "TEST SUCCEEDED" << std::endl;
			exit(EXIT_SUCCESS);
		}
		std::cout << "TEST FAILED" << std::endl;
		exit(EXIT_FAILURE);
	}
开发者ID:bjqiwei,项目名称:uscxml,代码行数:9,代码来源:test-w3c.cpp


示例6: ATTR

// setup / fetch the documents initial transitions
NodeSet<std::string> InterpreterDraft6::getDocumentInitialTransitions() {
	NodeSet<std::string> initialTransitions;
	
	if (_userDefinedStartConfiguration.size() > 0) {
		// we emulate entering a given configuration by creating a pseudo deep history
		Element<std::string> initHistory = _document.createElementNS(_nsInfo.nsURL, "history");
		_nsInfo.setPrefix(initHistory);
		
		initHistory.setAttribute("id", UUID::getUUID());
		initHistory.setAttribute("type", "deep");
		_scxml.insertBefore(initHistory, _scxml.getFirstChild());
		
		std::string histId = ATTR(initHistory, "id");
		NodeSet<std::string> histStates;
		for (int i = 0; i < _userDefinedStartConfiguration.size(); i++) {
			histStates.push_back(getState(_userDefinedStartConfiguration[i]));
		}
		_historyValue[histId] = histStates;
		
		Element<std::string> initialElem = _document.createElementNS(_nsInfo.nsURL, "initial");
		_nsInfo.setPrefix(initialElem);
		
		initialElem.setAttribute("generated", "true");
		Element<std::string> transitionElem = _document.createElementNS(_nsInfo.nsURL, "transition");
		_nsInfo.setPrefix(transitionElem);
		
		transitionElem.setAttribute("target", histId);
		initialElem.appendChild(transitionElem);
		_scxml.appendChild(initialElem);
		initialTransitions.push_back(transitionElem);
		
	} else {
		// try to get initial transition from initial element
		initialTransitions = _xpath.evaluate("/" + _nsInfo.xpathPrefix + "initial/" + _nsInfo.xpathPrefix + "transition", _scxml).asNodeSet();
		if (initialTransitions.size() == 0) {
			Arabica::XPath::NodeSet<std::string> initialStates;
			// fetch per draft
			initialStates = getInitialStates();
			assert(initialStates.size() > 0);
			for (int i = 0; i < initialStates.size(); i++) {
				Element<std::string> initialElem = _document.createElementNS(_nsInfo.nsURL, "initial");
				_nsInfo.setPrefix(initialElem);
				
				initialElem.setAttribute("generated", "true");
				Element<std::string> transitionElem = _document.createElementNS(_nsInfo.nsURL, "transition");
				_nsInfo.setPrefix(transitionElem);
				
				transitionElem.setAttribute("target", ATTR(initialStates[i], "id"));
				initialElem.appendChild(transitionElem);
				_scxml.appendChild(initialElem);
				initialTransitions.push_back(transitionElem);
			}
		}
	}
	return initialTransitions;
}
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:57,代码来源:InterpreterDraft6.cpp


示例7: sort

  void sort(const DOM::Node<std::string>& node, Arabica::XPath::NodeSet<std::string>& nodes, ExecutionContext& context) const
  {
    if(!sort_)
    {
      if(!nodes.forward())
        nodes.to_document_order();
      return;
    }

    sort_->set_context(node, context);
    std::stable_sort(nodes.begin(), nodes.end(), SortP(*sort_));
  } // sort
开发者ID:alepharchives,项目名称:arabica,代码行数:12,代码来源:xslt_sort.hpp


示例8: execute

  virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
  {
    Arabica::XPath::XPathValue<std::string> value = select_->evaluate(node, context.xpathContext());
    if(value.type() != Arabica::XPath::NODE_SET)
    {
      context.sink().characters(value.asString());
      return;
    } 

    Arabica::XPath::NodeSet<std::string> nodes = value.asNodeSet();
    for(Arabica::XPath::NodeSet<std::string>::const_iterator n = nodes.begin(), e = nodes.end(); n != e; ++n)
      copy(*n, context);
  } // execute
开发者ID:KITSVictorGubin,项目名称:jornal,代码行数:13,代码来源:xslt_copy.hpp


示例9: nodeSetUnion

  Arabica::XPath::NodeSet<std::string> nodeSetUnion(const std::string& keyClarkName, 
							     const Arabica::XPath::NodeSet<std::string> nodes,
							     const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
  {
    Arabica::XPath::NodeSet<std::string> results;
    for(Arabica::XPath::NodeSet<std::string>::const_iterator n = nodes.begin(), ne = nodes.end(); n != ne; ++n)
    {
      std::string id = Arabica::XPath::impl::nodeStringValue<std::string, Arabica::default_string_adaptor<std::string> >(*n);
      results.push_back(keys_.lookup(keyClarkName, id, executionContext));
    } // for ...
    results.to_document_order();
    return results;
  } // nodeSetUnion
开发者ID:alepharchives,项目名称:arabica,代码行数:13,代码来源:xslt_functions.hpp


示例10: filterChildElements

Arabica::XPath::NodeSet<std::string> InterpreterDraft6::selectTransitions(const std::string& event) {
	Arabica::XPath::NodeSet<std::string> enabledTransitions;

	NodeSet<std::string> states;
	for (unsigned int i = 0; i < _configuration.size(); i++) {
		if (isAtomic(_configuration[i]))
			states.push_back(_configuration[i]);
	}
	states.to_document_order();

#if 0
	std::cout << "Atomic states: " << std::endl;
	for (int i = 0; i < states.size(); i++) {
		std::cout << states[i] << std::endl << "----" << std::endl;
	}
	std::cout << std::endl;
#endif

	unsigned int index = 0;
	while(states.size() > index) {
		bool foundTransition = false;
		NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
		for (unsigned int k = 0; k < transitions.size(); k++) {
			if (isEnabledTransition(transitions[k], event)) {
				enabledTransitions.push_back(transitions[k]);
				foundTransition = true;
				goto LOOP;
			}
		}
		if (!foundTransition) {
			Node<std::string> parent = states[index].getParentNode();
			if (parent) {
				states.push_back(parent);
			}
		}
LOOP:
		index++;
	}

	enabledTransitions = filterPreempted(enabledTransitions);

#if 0
	std::cout << "Enabled transitions: " << std::endl;
	for (int i = 0; i < enabledTransitions.size(); i++) {
		std::cout << DOMUtils::xPathForNode(enabledTransitions[i]) << std::endl;
	}
	std::cout << std::endl;
#endif

	return enabledTransitions;
}
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:51,代码来源:InterpreterDraft6.cpp


示例11: is

NistXmlTestset::NistXmlTestset(const std::string &file)
		: logger_(logkw::channel = "NistXmlTestset") {
	Arabica::SAX2DOM::Parser<std::string> domParser;
	Arabica::SAX::InputSource<std::string> is(file);
	Arabica::SAX::CatchErrorHandler<std::string> errh;
	domParser.setErrorHandler(errh);
	domParser.parse(is);
	if(errh.errorsReported())
		BOOST_LOG_SEV(logger_, error) << errh.errors();

	Arabica::DOM::Document<std::string> doc = domParser.getDocument();
	if(doc == 0) {
		BOOST_LOG_SEV(logger_, error) << "Error parsing input file: " << file;
		exit(1);
	}

	doc.getDocumentElement().normalize();

	Arabica::XPath::XPath<std::string> xp;

	Arabica::XPath::NodeSet<std::string> docnodes =
		xp.compile("/mteval/srcset/doc").evaluateAsNodeSet(doc.getDocumentElement());
	docnodes.to_document_order();
	BOOST_FOREACH(Arabica::DOM::Node<std::string> n, docnodes)
		documents_.push_back(boost::make_shared<NistXmlDocument>(n));

	outdoc_ = static_cast<Arabica::DOM::Document<std::string> >(doc.cloneNode(true));
	Arabica::DOM::Element<std::string> srcset =
		static_cast<Arabica::DOM::Element<std::string> >(
			xp.compile("/mteval/srcset").evaluateAsNodeSet(outdoc_.getDocumentElement())[0]);

	Arabica::DOM::Element<std::string> tstset = outdoc_.createElement("tstset");
	int docno = 0;
	while(srcset.hasChildNodes()) {
		Arabica::DOM::Node<std::string> n = srcset.removeChild(srcset.getFirstChild());
		tstset.appendChild(n);
		if(n.getNodeType() == Arabica::DOM::Node<std::string>::ELEMENT_NODE &&
				n.getNodeName() == "doc")
			documents_[docno++]->setOutputNode(n);
	}
	tstset.setAttribute("setid", srcset.getAttribute("setid"));
	tstset.setAttribute("srclang", srcset.getAttribute("srclang"));
	tstset.setAttribute("trglang", "TRGLANG");
	tstset.setAttribute("sysid", "SYSID");

	srcset.getParentNode().replaceChild(tstset, srcset);
}
开发者ID:mtfelix,项目名称:docent,代码行数:47,代码来源:NistXmlTestset.cpp


示例12: getProperAncestors

Node<std::string> InterpreterDraft6::findLCPA(const Arabica::XPath::NodeSet<std::string>& states) {
	Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Node<std::string>());
	Node<std::string> ancestor;
	for (int i = 0; i < ancestors.size(); i++) {
		if (!isParallel(ancestors[i]))
			continue;
		for (int j = 0; j < states.size(); j++) {
			if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i]))
				goto NEXT_ANCESTOR;
		}
		ancestor = ancestors[i];
		break;
NEXT_ANCESTOR:
		;
	}
	return ancestor;
}
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:17,代码来源:InterpreterDraft6.cpp


示例13: printConfig

	void printConfig(const Arabica::XPath::NodeSet<std::string>& config) {
		std::string seperator;
		std::cerr << "Config: {";
		for (int i = 0; i < config.size(); i++) {
			std::cerr << seperator << ATTR_CAST(config[i], "id");
			seperator = ", ";
		}
		std::cerr << "}" << std::endl;
	}
开发者ID:vogelsgesang,项目名称:uscxml,代码行数:9,代码来源:uscxml-transform.cpp


示例14: getQualifiedTransBreakpoints

std::list<Breakpoint> getQualifiedTransBreakpoints(Interpreter interpreter, const Arabica::DOM::Element<std::string>& transition, Breakpoint breakpointTemplate) {
	std::list<Breakpoint> breakpoints;

	Arabica::DOM::Element<std::string> source(interpreter.getImpl()->getSourceState(transition));
	Arabica::XPath::NodeSet<std::string> targets = interpreter.getImpl()->getTargetStates(transition);

	for (size_t j = 0; j < targets.size(); j++) {
		Arabica::DOM::Element<std::string> target(targets[j]);

		Breakpoint bp = breakpointTemplate; // copy base as template
		bp.element = transition;
		bp.transSourceId = ATTR(source, "id");
		bp.transTargetId = ATTR(target, "id");
		bp.subject = Breakpoint::TRANSITION;

		breakpoints.push_back(bp);
	}

	return breakpoints;
}
开发者ID:juehv,项目名称:uscxml,代码行数:20,代码来源:Debugger.cpp


示例15: load_document

  void load_document(const std::string& location,
                     Arabica::XPath::NodeSet<std::string>& nodes) const
  {
    SAX2DOM::Parser<std::string> domParser;
    SAX::CatchErrorHandler<std::string> eh;
    domParser.setErrorHandler(eh);

    Arabica::io::URI base(baseURI_);
    Arabica::io::URI absolute(base, location);

    SAX::InputSource<std::string> is(absolute.as_string());
    domParser.parse(is);

    if(!eh.errorsReported())
        nodes.push_back(domParser.getDocument());
    else
        std::cerr << eh.errors() << std::endl;
  } // load_document
开发者ID:alepharchives,项目名称:arabica,代码行数:18,代码来源:xslt_functions.hpp


示例16: getSourceState

void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
	NodeSet<std::string> statesToExit;
	monIter_t monIter;

#if VERBOSE
	std::cout << _name << ": Enabled exit transitions: " << std::endl;
	for (int i = 0; i < enabledTransitions.size(); i++) {
		std::cout << enabledTransitions[i] << std::endl;
	}
	std::cout << std::endl;
#endif

	for (int i = 0; i < enabledTransitions.size(); i++) {
		Element<std::string> t = ((Element<std::string>)enabledTransitions[i]);
		if (!isTargetless(t)) {
			Node<std::string> ancestor;
			Node<std::string> source = getSourceState(t);
//			std::cout << t << std::endl << TAGNAME(t) << std::endl;
			NodeSet<std::string> tStates = getTargetStates(t);
			bool isInternal = (HAS_ATTR(t, "type") && iequals(ATTR(t, "type"), "internal")); // external is default
			bool allDescendants = true;
			for (int j = 0; j < tStates.size(); j++) {
				if (!isDescendant(tStates[j], source)) {
					allDescendants = false;
					break;
				}
			}
			if (isInternal && allDescendants && isCompound(source)) {
				ancestor = source;
			} else {
				NodeSet<std::string> tmpStates;
				tmpStates.push_back(source);
				tmpStates.insert(tmpStates.end(), tStates.begin(), tStates.end());
#if VERBOSE
				std::cout << _name << ": tmpStates: ";
				for (int i = 0; i < tmpStates.size(); i++) {
					std::cout << ATTR(tmpStates[i], "id") << ", ";
				}
				std::cout << std::endl;
#endif
				ancestor = findLCCA(tmpStates);
			}
#if VERBOSE
			std::cout << _name << ": Ancestor: " << ATTR(ancestor, "id") << std::endl;;
#endif
			for (int j = 0; j < _configuration.size(); j++) {
				if (isDescendant(_configuration[j], ancestor))
					statesToExit.push_back(_configuration[j]);
			}
		}
	}
	// remove statesToExit from _statesToInvoke
	std::list<Node<std::string> > tmp;
	for (int i = 0; i < _statesToInvoke.size(); i++) {
		if (!isMember(_statesToInvoke[i], statesToExit)) {
			tmp.push_back(_statesToInvoke[i]);
		}
	}
	_statesToInvoke = NodeSet<std::string>();
	_statesToInvoke.insert(_statesToInvoke.end(), tmp.begin(), tmp.end());

	statesToExit.forward(false);
	statesToExit.sort();

#if VERBOSE
	std::cout << _name << ": States to exit: ";
	for (int i = 0; i < statesToExit.size(); i++) {
		std::cout << LOCALNAME(statesToExit[i]) << ":" << ATTR(statesToExit[i], "id") << ", ";
	}
	std::cout << std::endl;
#endif

	for (int i = 0; i < statesToExit.size(); i++) {
		NodeSet<std::string> histories = filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]);
		for (int j = 0; j < histories.size(); j++) {
			Element<std::string> historyElem = (Element<std::string>)histories[j];
			std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow");
			NodeSet<std::string> historyNodes;
			for (int k = 0; k < _configuration.size(); k++) {
				if (iequals(historyType, "deep")) {
					if (isAtomic(_configuration[k]) && isDescendant(_configuration[k], statesToExit[i]))
						historyNodes.push_back(_configuration[k]);
				} else {
					if (_configuration[k].getParentNode() == statesToExit[i])
						historyNodes.push_back(_configuration[k]);
				}
			}
			_historyValue[historyElem.getAttribute("id")] = historyNodes;
#if VERBOSE
			std::cout << _name << ": History node " << ATTR(historyElem, "id") << " contains: ";
			for (int i = 0; i < historyNodes.size(); i++) {
				std::cout << ATTR(historyNodes[i], "id") << ", ";
			}
			std::cout << std::endl;
#endif

		}
	}

	for (int i = 0; i < statesToExit.size(); i++) {
//.........这里部分代码省略.........
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:101,代码来源:InterpreterDraft6.cpp


示例17: writeTex

void ChartToTex::writeTex(std::ostream& stream) {
	_keepInvalidTransitions = true;
	if (_start == NULL) {
		interpret();
	}

	bool wroteRowStart = false;
	std::string seperator;

	for (std::map<std::string, GlobalState*>::iterator stateIter = _globalConf.begin(); stateIter != _globalConf.end(); stateIter++) {
		assert(_indexToState.find(stateIter->second->index) == _indexToState.end());
		_indexToState[stateIter->second->index] = stateIter->second;
	}

	stream << "% " << _sourceURL.asString() << std::endl;

	stream << "%<*provideCommand>" << std::endl;
	stream << "\\providecommand{\\globalStateListCell}[2][c]{%" << std::endl;
	stream << "  \\begin{tabular}[#1]{@{}[email protected]{}}#2\\end{tabular}}" << std::endl;
	stream << "%</provideCommand>" << std::endl;


	stream << std::endl;

//	stream << "\\begin{table}[H]" << std::endl;
//	stream << "\\centering" << std::endl;
//	stream << "\\begin{tabular}{r | l | L{12em} | l}" << std::endl;

	stream << "\\begin{longtable}{| r | l | l | l |}" << std::endl;

	for (std::map<unsigned long, GlobalState*>::iterator stateIter = _indexToState.begin(); stateIter != _indexToState.end(); stateIter++) {
		GlobalState* currState = stateIter->second;

		stream << "\\hline" << std::endl;

		if (!wroteRowStart) {
			stream << "%<*tableRows>" << std::endl;
			wroteRowStart = true;
		}

		stream << "%<*globalState" << currState->index << ">" << std::endl;

		// state index
		stream << "\\tikzmark{statename_" << currState->index << "}" << "$\\widetilde{s}(" << currState->index << ")$ & ";

		// members in active configuration
		FlatStateIdentifier flatId(currState->stateId);
		stream << "\\globalStateListCell[t]{";
		stream << "\\tikzmark{active_" << currState->index << "}";
		stream << "$\\widetilde{s}_a(" << currState->index << ")$: " << stateListToTex(flatId.getFlatActive(), flatId.getActive().size() == 0) << "\\\\";

		// already visited states
		stream << "\\tikzmark{visited_" << currState->index << "}";
		stream << "$\\widetilde{s}_d(" << currState->index << ")$: " << stateListToTex(flatId.getFlatVisited(), flatId.getVisited().size() == 0) << "\\\\";

		// history assignments
		stream << "\\tikzmark{history_" << currState->index << "}";
		stream << "$\\widetilde{s}_h(" << currState->index << ")$: " << stateListToTex(flatId.getFlatHistory(), flatId.getHistory().size() == 0) << "} & ";

		// all transitions
		std::set<std::string> origTransitions;
		for (std::list<GlobalTransition*>::iterator transIter = stateIter->second->sortedOutgoing.begin(); transIter != stateIter->second->sortedOutgoing.end(); transIter++) {
			GlobalTransition* currTrans = *transIter;
			Arabica::XPath::NodeSet<std::string> members = currTrans->getTransitions();
			for (size_t i = 0; i < members.size(); i++) {
				Element<std::string> transElem(members[i]);
				if (HAS_ATTR(transElem, "priority")) {
					origTransitions.insert(ATTR(transElem, "priority"));
				} else {
					origTransitions.insert("initial");
				}
			}
		}

		if (origTransitions.size() > 0) {
			stream << "$\\{ ";
			seperator = "";
			for (std::set<std::string>::reverse_iterator transIter = origTransitions.rbegin(); transIter != origTransitions.rend(); transIter++) {
				stream << seperator << "t_{" << *transIter << "}";
				seperator = ", ";
			}
			stream << " \\}$";
		} else {
			stream << "$\\emptyset$";
		}
		stream << "\\tikzmark{transitions_" << currState->index << "}";
		stream << "  & \\\\ \\hline" << std::endl;

		if (stateIter->second->sortedOutgoing.size() > 0) {
			stream << "$\\widetilde{\\mathcal{T}}(" << currState->index << ")$" << std::endl;

			size_t ecIndex = 0;
			for (std::list<GlobalTransition*>::iterator transIter = stateIter->second->sortedOutgoing.begin(); transIter != stateIter->second->sortedOutgoing.end(); transIter++, ecIndex++) {
				GlobalTransition* currTrans = *transIter;
				stream << "& ";
				stream << "\\tikzmark{trans_set" << currState->index << "_" << ecIndex << "}";

				if (!currTrans->isValid)
					stream << "\\sout{";

//.........这里部分代码省略.........
开发者ID:juehv,项目名称:uscxml,代码行数:101,代码来源:ChartToTex.cpp


示例18: catch

// a macrostep
InterpreterState InterpreterDraft6::step(bool blocking) {
	try {

		monIter_t monIter;
		NodeSet<std::string> enabledTransitions;
		
		// setup document and interpreter
		if (!_isInitialized)
			init();
		
		// if we failed return false
		if (!_isInitialized)
			return INIT_FAILED;
		
		// run initial transitions
		if (!_stable) {
			stabilize();
			// we might only need a single step
			if (!_running)
				goto EXIT_INTERPRETER;
			return INITIALIZED;
		}
		
		if (!_running)
			return FINISHED;
		
		// read an external event and react
		if (blocking) {
			// wait until an event becomes available
			while(_externalQueue.isEmpty()) {
				_condVar.wait(_mutex);
			}
		} else {
			// return immediately if external queue is empty
			if (_externalQueue.isEmpty())
				return NOTHING_TODO;
		}
		_currEvent = _externalQueue.pop();

	#if VERBOSE
		std::cout << "Received externalEvent event " << _currEvent.name << std::endl;
		if (_running && _currEvent.name == "unblock.and.die") {
			std::cout << "Still running " << this << std::endl;
		} else {
			std::cout << "Aborting " << this << std::endl;
		}
	#endif
		_currEvent.eventType = Event::EXTERNAL; // make sure it is set to external

		// when we were blocking on destructor invocation
		if (!_running) {
			goto EXIT_INTERPRETER;
			return INTERRUPTED;
		}
		// --- MONITOR: beforeProcessingEvent ------------------------------
		for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
			try {
				(*monIter)->beforeProcessingEvent(shared_from_this(), _currEvent);
			}
			USCXML_MONITOR_CATCH_BLOCK(beforeProcessingEvent)
		}
		
		if (iequals(_currEvent.name, "cancel.invoke." + _sessionId))
			return INTERRUPTED;
		
		try {
			_dataModel.setEvent(_currEvent);
		} catch (Event e) {
			LOG(ERROR) << "Syntax error while setting external event:" << std::endl << e << std::endl << _currEvent;
		}

		for (std::map<std::string, Invoker>::iterator invokeIter = _invokers.begin();
				 invokeIter != _invokers.end();
				 invokeIter++) {
			if (iequals(invokeIter->first, _currEvent.invokeid)) {
				Arabica::XPath::NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement());
				for (int k = 0; k < finalizes.size(); k++) {
					Element<std::string> finalizeElem = Element<std::string>(finalizes[k]);
					executeContent(finalizeElem);
				}
			}
			if (HAS_ATTR(invokeIter->second.getElement(), "autoforward") && DOMUtils::attributeIsTrue(ATTR(invokeIter->second.getElement(), "autoforward"))) {
				try {
					// do not autoforward to invokers that send to #_parent from the SCXML IO Processor!
					// Yes do so, see test229!
					// if (!boost::equals(_currEvent.getOriginType(), "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"))
					invokeIter->second.send(_currEvent);
				} catch(...) {
					LOG(ERROR) << "Exception caught while sending event to invoker " << invokeIter->first;
				}
			}
		}

		
		// run internal processing until we reach a stable configuration again
		enabledTransitions = selectTransitions(_currEvent.name);
		if (!enabledTransitions.empty()) {
			// test 403b
			enabledTransitions.to_document_order();
//.........这里部分代码省略.........
开发者ID:mathiasjohanson,项目名称:uscxml,代码行数:101,代码来源:InterpreterDraft6.cpp


示例19: enterElement

void RespondElement::enterElement(const Arabica::DOM::Element<std::string>& node) {
	// try to get the request id
	if (!HAS_ATTR(node, "to")) {
		LOG(ERROR) << "Respond element requires to attribute";
		return;
	}
	if (HAS_ATTR(node, "to") && !_interpreter->getDataModel()) {
		LOG(ERROR) << "Respond element with to requires datamodel";
		return;
	}
	std::string requestId = _interpreter->getDataModel().evalAsString(ATTR(node, "to"));

	// try to get the request object
	InterpreterHTTPServlet* servlet = _interpreter->getHTTPServlet();
	tthread::lock_guard<tthread::recursive_mutex> lock(servlet->getMutex());

	if (servlet->getRequests().find(requestId) == servlet->getRequests().end()) {
		LOG(ERROR) << "No matching HTTP request for respond element";
		return;
	}

	assert(servlet->getRequests().find(requestId) != servlet->getRequests().end());
	HTTPServer::Request httpReq = servlet->getRequests()[requestId];
	assert(httpReq.evhttpReq != NULL);
	HTTPServer::Reply httpReply(httpReq);
	servlet->getRequests().erase(requestId);

	// get the status or default to 200
	std::string statusStr = (HAS_ATTR(node, "status") ? ATTR(node, "status") : "200");
	if (!isNumeric(statusStr.c_str(), 10)) {
		LOG(ERROR) << "Respond element with non-numeric status " << statusStr;
		return;
	}
	httpReply.status = strTo<int>(statusStr);;

	// extract the content
	Arabica::XPath::NodeSet<std::string> contents = InterpreterImpl::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "content", node);
	if (contents.size() > 0) {
		Arabica::DOM::Element<std::string> contentElem = Arabica::DOM::Element<std::string>(contents[0]);
		if (HAS_ATTR(contentElem, "expr")) { // -- content is evaluated string from datamodel ------
			if (_interpreter->getDataModel()) {
				try {
					Data contentData = _interpreter->getDataModel().getStringAsData(ATTR(contentElem, "expr"));
					if (contentData.atom.length() > 0) {
						httpReply.content = contentData.atom;
						httpReply.headers["Content-Type"] = "text/plain";
					} else if (contentData.binary) {
						httpReply.content = std::string(contentData.binary.getData(), contentData.binary.getSize());
						httpReply.headers["Content-Type"] = contentData.binary.getMimeType();
					} else if (contentData.node) {
						std::stringstream ss;
						ss << contentData.node;
						httpReply.content = ss.str();;
						httpReply.headers["Content-Type"] = "application/xml";
					} else {
						httpReply.content = Data::toJSON(contentData);
						httpReply.headers["Content-Type"] = "application/json";
					}
				} catch (Event e) {
					LOG(ERROR) << "Syntax error with expr in content child of Respond element:" << std::endl << e << std::endl;
					return;
				}
			} else {
				LOG(ERROR) << "content element has expr attribute but no datamodel is specified.";
				return;
			}
		} else if (HAS_ATTR(contentElem, "file") || HAS_ATTR(contentElem, "fileexpr")) { // -- content is from file ------
			URL file;
			if (HAS_ATTR(contentElem, "fileexpr")) {
				if (_interpreter->getDataModel()) {
					try {
						file = "file://" + _interpreter->getDataModel().evalAsString(ATTR(contentElem, "fileexpr"));
					} catch (Event e) {
						LOG(ERROR) << "Syntax error with fileexpr in content child of Respond element:" << std::endl << e << std::endl;
						return;
					}
				}
			} else {
				file = "file://" + ATTR(contentElem, "fileexpr");
			}
			if (file) {
				httpReply.content = file.getInContent();
				size_t lastDot;
				if ((lastDot = file.path().find_last_of(".")) != std::string::npos) {
					std::string extension = file.path().substr(lastDot + 1);
					std::string mimeType = URL::getMimeType(extension);
					if (mimeType.length() > 0) {
						httpReply.headers["Content-Type"] = mimeType;
					}
				}
			}
		} else if (contents[0].hasChildNodes()) {  // -- content embedded as child nodes ------
			httpReply.content = contents[0].getFirstChild().getNodeValue();
		} else {
			LOG(ERROR) << "content element does not specify any content.";
			return;
		}
	}

	// process headers
//.........这里部分代码省略.........
开发者ID:sradomski,项目名称:uscxml,代码行数:101,代码来源:RespondElement.cpp



注:本文中的arabica::xpath::NodeSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ xpath::XPath类代码示例发布时间:2022-05-31
下一篇:
C++ xml::XmlDocument类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap