当前位置: 首页>>代码示例>>C++>>正文


C++ Filter::inputfilter方法代码示例

本文整理汇总了C++中Filter::inputfilter方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::inputfilter方法的具体用法?C++ Filter::inputfilter怎么用?C++ Filter::inputfilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filter的用法示例。


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

示例1: iostreamfilter

void langbind::iostreamfilter( proc::ExecContext* execContext, const std::string& protocol, const std::string& proc, const std::string& ifl, std::size_t ib, const std::string& ofl, std::size_t ob, std::istream& is, std::ostream& os)
{
	BufferStruct buf( ib, ob);
	const proc::ProcessorProviderInterface* provider = execContext->provider();
		
	if (proc.size() == 0 || proc == "-")
	{
		LOG_TRACE << "Start executing filter";
		Filter flt = getFilter( provider, ifl, ofl);
		if (!flt.inputfilter().get()) throw std::runtime_error( "input filter not found");
		if (!flt.outputfilter().get()) throw std::runtime_error( "output filter not found");
		flt.outputfilter()->setOutputChunkSize( buf.outsize);

		// ... no command specified -> we simply map the input through the
		//	input/output filters specified:
		if (ifl.empty() && ofl.empty()) throw std::runtime_error( "argument for command, form or function not defined and no filter for processing specified");

		const void* elem;
		int taglevel = 0;
		std::size_t elemsize;
		FilterBase::ElementType etype;

		while (taglevel >= 0)
		{
			if (!flt.inputfilter().get()->getNext( etype, elem, elemsize))
			{
				if (flt.inputfilter()->state() == InputFilter::Open || flt.inputfilter()->state() == InputFilter::Start)
				{
					throw std::runtime_error( "filter not delivering final close tag");
				}
				processIO( buf, flt.inputfilter().get(), flt.outputfilter().get(), is, os);
				continue;
			}
			if (etype == FilterBase::OpenTag)
			{
				taglevel++;
			}
			else if (etype == FilterBase::CloseTag)
			{
				taglevel--;
			}
			while (!flt.outputfilter().get()->print( etype, elem, elemsize))
			{
				processIO( buf, flt.inputfilter().get(), flt.outputfilter().get(), is, os);
			}
			LOG_DATA << "[iostream filter] print " << FilterBase::elementTypeName(etype) << " '" << std::string( (const char*)elem, elemsize) << "'"; 
		}
		while (!flt.outputfilter().get()->close())
		{
			processIO( buf, flt.inputfilter().get(), flt.outputfilter().get(), is, os);
		}
		checkUnconsumedInput( is);
		writeOutput( os, *flt.outputfilter());
		if (taglevel != -1) throw std::runtime_error( "tags not balanced");
		return;
	}
	{
		if (proc[ proc.size()-1] == '~' || provider->hasCommand( proc))
		{
			LOG_TRACE << "Start executing command '" << proc << "'";

			cmdbind::ProtocolHandlerR protocolhnd;
			if (protocol.empty())
			{
				protocolhnd.reset( new cmdbind::ContentOnlyProtocolHandler());
			}
			else
			{
				protocolhnd.reset( provider->protocolHandler( protocol));
				if (!protocolhnd.get()) throw std::runtime_error( std::string("protocol '") + protocol + "' is not defined");
			}
			protocolhnd->setExecContext( execContext);
			if (proc[ proc.size()-1] == '~')
			{
				protocolhnd->setArgumentString( std::string( proc.c_str(), proc.size()-1));
			}
			else
			{
				protocolhnd->setArgumentString( proc + "!");
			}
			protocolhnd->setOutputBuffer( buf.outbuf, buf.outsize, 0);

			std::string lasterr;
			if (!processProtocolHandler( buf, protocolhnd.get(), is, os, lasterr))
			{
				throw std::runtime_error( lasterr);
			}
			// Check if there is unconsumed input left (must not happen):
			checkUnconsumedInput( is);
			return;
		}
	}
	{
		const FormFunction* func = provider->formFunction( proc);
		if (func)
		{
			LOG_TRACE << "Start executing form function '" << proc << "'";

			// ... command is the name of a form function we call directly
			//	with the filter specified:
//.........这里部分代码省略.........
开发者ID:Wolframe,项目名称:Wolframe,代码行数:101,代码来源:wolfilterIostreamFilter.cpp


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