本文整理汇总了C++中UnicodeSet::none方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeSet::none方法的具体用法?C++ UnicodeSet::none怎么用?C++ UnicodeSet::none使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeSet
的用法示例。
在下文中一共展示了UnicodeSet::none方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: charClass
void NFABuilder::charClass(const ParseNode& n) {
const UnicodeSet uset(n.Set.CodePoints & Enc->validCodePoints());
if (uset.none()) {
if (!n.Set.Breakout.Additive || n.Set.Breakout.Bytes.none()) {
THROW_RUNTIME_ERROR_WITH_CLEAN_OUTPUT(
"intersection of character class with " << Enc->name() << " is empty"
);
}
// the breakout bytes are the entire character class
NFA::VertexDescriptor v = Fsm->addVertex();
(*Fsm)[v].Trans = Fsm->TransFac->getSmallest(n.Set.Breakout.Bytes);
TempFrag.initFull(v, n);
}
else {
// convert the code point set into collapsed encoding ranges
TempEncRanges.clear();
Enc->write(uset, TempEncRanges);
// handle the breakout bytes
if (n.Set.Breakout.Bytes.any()) {
if (n.Set.Breakout.Additive) {
// add breakout bytes to encodings
if (TempEncRanges[0].size() == 1) {
TempEncRanges[0][0] |= n.Set.Breakout.Bytes;
}
else {
TempEncRanges.emplace_back(1);
TempEncRanges.back()[0] = n.Set.Breakout.Bytes;
}
}
else {
// subtract breakout bytes from encodings
if (TempEncRanges[0].size() == 1) {
TempEncRanges[0][0] &= ~n.Set.Breakout.Bytes;
if (TempEncRanges[0][0].none()) {
TempEncRanges.erase(TempEncRanges.begin());
// ensure that at least one initial byte remains
if (TempEncRanges.empty()) {
THROW_RUNTIME_ERROR_WITH_CLEAN_OUTPUT(
"intersection of character class with " << Enc->name()
<< " is empty"
);
}
}
}
}
}
ByteSet bs;
TempFrag.reset(n);
// create a graph from the collapsed ranges
for (const std::vector<ByteSet>& enc : TempEncRanges) {
NFA::VertexDescriptor head, tail;
//
// find a suffix of enc in this fragment
//
int32_t b = enc.size()-1;
// find a match for the last transition
const auto oi = std::find_if(
TempFrag.OutList.begin(), TempFrag.OutList.end(),
[&](const std::pair<NFA::VertexDescriptor,uint32_t>& p) {
return (*Fsm)[p.first].Trans->getBytes(bs) == enc[b];
}
);
if (oi != TempFrag.OutList.end()) {
// match, use this tail
tail = oi->first;
// walk backwards until a transition mismatch
for (--b; b >= 0; --b) {
head = 0;
for (const NFA::VertexDescriptor h : Fsm->inVertices(tail)) {
(*Fsm)[h].Trans->getBytes(bs);
if (bs == enc[b]) {
tail = head = h;
break;
}
head = 0;
}
if (!head) {
// tail is as far back as we can go
break;
}
}
}
else {
// no match, build a new tail
tail = Fsm->addVertex();
(*Fsm)[tail].Trans = Fsm->TransFac->getSmallest(enc[b--]);
TempFrag.OutList.emplace_back(tail, 0);
}
//.........这里部分代码省略.........