本文整理汇总了C++中Alternative类的典型用法代码示例。如果您正苦于以下问题:C++ Alternative类的具体用法?C++ Alternative怎么用?C++ Alternative使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Alternative类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
static void serialize(storage_type& s, const Alternative<T1, T2>& in)
{
s.serialize(in.isLeft());
if (in.isLeft())
s.serialize(in.left());
else
s.serialize(in.right());
}
示例2: addItem
void ControlList::addItem(const Alternative<String, const XBMCAddon::xbmcgui::ListItem* > & item, bool sendMessage)
{
XBMC_TRACE;
if (item.which() == first)
internAddListItem(ListItem::fromString(item.former()),sendMessage);
else
internAddListItem(item.later(),sendMessage);
}
示例3: Alternative
void AddAlternativeDefinitionImpl::operator()( boost::ptr_vector<Alternative> & alts, boost::ptr_vector<Matcher> & matchers, boost::ptr_map<AttributeKey,Expression> & bindings, const std::string & source, const std::string & transformSource ) const {
Alternative * alternative = new Alternative( source, transformSource ); // Добавляем новую альтернативу к шаблону
alternative->addMatchers( matchers ); // Добавляем сопоставители
alternative->addBindings( bindings ); // Добавляем связывания
alternative->updateDependencies(); // Обновляем зависимости альтернативы
alts.push_back( alternative );
}
示例4: left
bool operator==(const Alternative& in) const
{
if (isLeft() != in.isLeft())
return false;
if (isLeft())
return in.left() == left();
else
return in.right() == right();
}
示例5: play
void Player::play(const Alternative<String, const PlayList* > & item,
const XBMCAddon::xbmcgui::ListItem* listitem, bool windowed, int startpos)
{
XBMC_TRACE;
if (&item == &defaultPlayParameter)
playCurrent(windowed);
else if (item.which() == XBMCAddon::first)
playStream(item.former(), listitem, windowed);
else // item is a PlayListItem
playPlaylist(item.later(),windowed,startpos);
}
示例6: play
void Player::play(const Alternative<String, const PlayList* > & item,
const XBMCAddon::xbmcgui::ListItem* listitem, bool windowed, int startpos)
{
TRACE;
if (Alternative<String, const PlayList*>::isNullReference(item))
playCurrent(windowed);
else if (item.which() == XBMCAddon::first)
playStream(item.former(), listitem, windowed);
else // item is a PlayListItem
playPlaylist(item.later(),windowed,startpos);
}
示例7:
void EpsilonNFA::NFAGenerator::visit(Alternative& node)
{
NFAGenerator left, right;
node.left()->accept(left);
node.right()->accept(right);
adopt_pool(left._pool);
adopt_pool(right._pool);
right.start->edges.push_back(Edge{ '\0', left.start });
left.end->edges.push_back(Edge{ '\0', right.end });
start = right.start;
end = right.end;
end->stateInfo = _info;
}
示例8: ParseAtom
// Atom ::= "(" Expression ")" | "[" [^] Range "]" | Characters
Instruction* ParseAtom(const char **ppc, ParseInfo &info)
{
Instruction *i = 0;
const char *pc = *ppc;
switch (*pc)
{
case '(':
{
Group::TriState dnl = Group::Inherit;
Group::TriState nc = Group::Inherit;
Group::TriState ml = Group::Inherit;
bool capture = true;
bool consume = true;
bool invert = false;
bool reverse = false;
std::string name = "";
++pc;
if (*pc == '?')
{
++pc;
if (*pc == '#')
{
// skip everything until ) and from behave as if ParseAtom was
// called starting next character
++pc;
while (*pc != ')')
{
if (*pc == '\0')
{
return 0;
}
++pc;
}
*ppc = ++pc;
return ParseAtom(ppc, info);
}
if (*pc == ':')
{
capture = false;
++pc;
}
else if (*pc == '(')
{
// conditional
++pc;
std::string cond;
while (*pc != ')')
{
if (*pc == '\0')
{
return 0;
}
cond.push_back(*pc);
++pc;
}
++pc;
Instruction *ci = ParseExpression(&pc, info);
if (!ci || *pc != ')')
{
if (ci)
{
delete ci;
}
return 0;
}
++pc;
Alternative *alt = dynamic_cast<Alternative*>(ci);
Instruction *ifTrue, *ifFalse;
if (alt == 0)
{
ifTrue = ci;
ifFalse = 0;
}
else
{
ifTrue = alt->first()->clone();
ifFalse = alt->second()->clone();
delete alt;
}
*ppc = pc;
int index = 0;
if (sscanf(cond.c_str(), "%d", &index) != 1)
{
return new Conditional(cond, ifTrue, ifFalse);
}
else
{
return new Conditional(index, ifTrue, ifFalse);
}
}
else if (*pc == 'P')
{
//.........这里部分代码省略.........
示例9:
bool operator | (const Alternative<T1, T2>& alt, const Match<TMatch>& m)
{
return (alt.isLeft() ? (alt.left() | m) : (alt.right() | m));
}
示例10: handle_read
virtual ParserResult handle_read(sip0x::utils::InputTokenStream& iss, FactoryContext* ctx) const override {
return _alternative.read(iss, ctx);
}