本文整理汇总了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:
//.........这里部分代码省略.........