本文整理汇总了C++中RuleSet类的典型用法代码示例。如果您正苦于以下问题:C++ RuleSet类的具体用法?C++ RuleSet怎么用?C++ RuleSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RuleSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderTarget
void Builder::build() {
engine3D->setDisabled(true);
Rendering::OpenGLRenderer renderTarget(engine3D);
renderTarget.begin(); // we clear before parsing...
Preprocessor pp;
QString out = pp.Process(loadedSystem);
Tokenizer tokenizer(out);
EisenParser e(&tokenizer);
RuleSet* rs = e.parseRuleset();
rs->resolveNames();
Model::Builder b(&renderTarget, rs, false);
b.build();
if (b.wasCancelled()) throw Exception("User cancelled");
renderTarget.end();
engine3D->setRaytracerCommands(b.getRaytracerCommands());
//INFO(QString("Setting %1 raytracer commands.").arg(raytracerCommands.count()));
delete(rs);
rs = 0;
engine3D->setDisabled(false);
engine3D->requireRedraw();
}
示例2: getEstimateValue
float Value::getEstimateValue(float size, const RuleSet& ruleSet, const boost::shared_ptr<Shape>& shape) const {
if (type == Value::TYPE_ABSOLUTE) {
return ruleSet.evalFloat(value, shape);
} else if (type == Value::TYPE_RELATIVE) {
return ruleSet.evalFloat(value, shape) * size;
} else {
return ruleSet.evalFloat(value, shape);
}
}
示例3: toString
//---------------------------------------------------------------------------------------------------------------------
std::string StyleSheet::toString() const
{
RuleSet set;
for (auto const& i : styles_)
{
set.rules.push_back(i.getRule());
}
return set.toCss();
}
示例4: makeRuleSet
static RuleSet* makeRuleSet(const HeapVector<RuleFeature>& ruleFeatures) {
if (ruleFeatures.isEmpty())
return nullptr;
RuleSet* ruleSet = RuleSet::create();
for (auto ruleFeature : ruleFeatures)
ruleSet->addRule(ruleFeature.rule, ruleFeature.selectorIndex,
RuleHasNoSpecialState);
return ruleSet;
}
示例5: removeRules
int CategoryManager::removeRules(const RuleSet& ruleSet)
{
int count = 0;
for (int i = 0; i < ruleSet.maxNumRules(); ++i) {
const Rule *rule = ruleSet.getRuleById(i);
if (rule) {
count += removeRule(*rule);
}
}
return count;
}
示例6: makeRuleSet
static RuleSet* makeRuleSet(const HeapVector<RuleFeature>& rules) {
size_t size = rules.size();
if (!size)
return nullptr;
RuleSet* ruleSet = RuleSet::create();
for (size_t i = 0; i < size; ++i) {
ruleSet->addRule(rules[i].rule, rules[i].selectorIndex,
rules[i].hasDocumentSecurityOrigin
? RuleHasDocumentSecurityOrigin
: RuleHasNoSpecialState);
}
return ruleSet;
}
示例7: collectRulesFromUserStyleSheets
void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium, StyleResolver& resolver)
{
for (unsigned i = 0; i < userSheets.size(); ++i) {
ASSERT(userSheets[i]->contents().isUserStyleSheet());
userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver);
}
}
示例8: init_io
bool
Forest::
init_io(RuleSet& ruleSet)
{
clock_t sec=clock();
for(int i=0;(size_t)i<_sentence.size();i++)
{
Node& node=(*this)[i][i];
string wrd=_sentence[i];
pair<RuleSet::RSIter,RuleSet::RSIter> iterPair=ruleSet.query(wrd);
for(RuleSet::RSIter iter=iterPair.first;iter!=iterPair.second;iter++)
{
double ruleScore=iter->second.prob; //when io, we use the original prob, not log
Label label;
label.init(iter->second.left,i,i,wrd);
//label.word()=wrd;
//jout<<wrd<<endl;
label.addPreTermScore_io(ruleScore);
if(node.find(label.nt())==node.end())
node[label.nt()]=label;
}
genUnaryNode_io(ruleSet,(*this)[i][i]);
}
initime+=clock()-sec;
//exit(1);
return true;
}
示例9: genUnaryNode_io
bool genUnaryNode_io(RuleSet& ruleSet,Node& node)
{
bool mark=false;
vector<string> ntPool;
ntPool.clear();
node.setUnaryInOrder(ruleSet,ntPool);
for(int i=0;(size_t)i<ntPool.size();i++)
{
string rightPart=ntPool[i];
Label& oldLb=node[rightPart];
pair<RuleSet::RSIter,RuleSet::RSIter> iterPair=ruleSet.query(rightPart);
for(RuleSet::RSIter iter=iterPair.first;iter!=iterPair.second;iter++)
{
string leftPart=iter->second.left;
if(node.find(leftPart)==node.end())
{
ntPool.push_back(leftPart);
Label newLabel;
newLabel.init(leftPart,oldLb.start(),oldLb.stop());
node[leftPart]=newLabel;
}
double ruleScore=iter->second.prob;
//cerr<<"\n"<<leftPart<<"--->add Child: "<<rightPart<<endl;
node[leftPart].addChild_io(&oldLb,ruleScore);
mark=true;
}
}
return mark;
}
示例10: addRules
void TreeBoundaryCrossingRules::addTreeBoundaryCrossingRules(const RuleSet& authorRules, ContainerNode& scopingNode, CSSStyleSheet* parentStyleSheet)
{
if (authorRules.treeBoundaryCrossingRules().isEmpty() && (scopingNode.isDocumentNode() || authorRules.shadowDistributedRules().isEmpty()))
return;
OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create();
addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules());
if (!scopingNode.isDocumentNode())
addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules());
if (!m_treeBoundaryCrossingRuleSetMap.contains(&scopingNode)) {
m_treeBoundaryCrossingRuleSetMap.add(&scopingNode, adoptPtrWillBeNoop(new CSSStyleSheetRuleSubSet()));
m_scopingNodes.add(&scopingNode);
}
CSSStyleSheetRuleSubSet* ruleSubSet = m_treeBoundaryCrossingRuleSetMap.get(&scopingNode);
ruleSubSet->append(std::make_pair(parentStyleSheet, ruleSetForScope.release()));
}
示例11: apply_and_gather
void RuleSet:: apply_and_gather (const Nodes_t& n, RuleSet& use, strings_t& into) {
for (auto i : n) {
stringstream ss;
RedirectStream (cout, ss);
use.apply_to (*i);
into .push_back (ss.str());
}
}
示例12: fputs
int RuleSet::checkRuleFile(const QString &rulefile) {
if(rulefile.isEmpty()) {
fputs(i18n("kppp: no rulefile specified\n").toLocal8Bit(), stderr);
return 1;
}
QFile fl(rulefile);
if(!fl.exists()) {
fprintf(stderr, i18n("kppp: rulefile \"%s\" not found\n").toLocal8Bit(), rulefile.toLocal8Bit().data());
return 1;
}
if(rulefile.right(4) != ".rst") {
fputs(i18n("kppp: rulefiles must have the extension \".rst\"\n").toLocal8Bit(), stderr);
return 1;
}
RuleSet r;
int err = r.load(rulefile);
fl.close();
if(err == -1) {
fputs(i18n("kppp: error parsing the ruleset\n").toLocal8Bit(), stderr);
return 1;
}
if(err > 0) {
fprintf(stderr, i18n("kppp: parse error in line %d\n").toLocal8Bit(), err);
return 1;
}
// check for the existence of a default rule
if((r.default_costs < 0) || (r.default_len < 0)) {
fputs(i18n("kppp: rulefile does not contain a default rule\n").toLocal8Bit(), stderr);
return 1;
}
if(r.name().length() == 0) {
fputs(i18n("kppp: rulefile does not contain a \"name=...\" line\n").toLocal8Bit(), stderr);
return 1;
}
fputs(i18n("kppp: rulefile is ok\n").toLocal8Bit(), stderr);
return 0;
}
示例13: treeScope
void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRules, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex)
{
bool isDocumentScope = treeScope().rootNode().isDocumentNode();
if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()
&& (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty() && authorRules.slottedPseudoElementRules().isEmpty())))
return;
if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty())
m_hasDeepOrShadowSelector = true;
OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create();
addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRules());
if (!isDocumentScope) {
addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules());
addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules());
}
if (!m_treeBoundaryCrossingRuleSet) {
m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRuleSubSet());
treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(treeScope().rootNode());
}
m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope.release()));
}
示例14: treeScope
void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRules, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex)
{
bool isDocumentScope = treeScope().rootNode().isDocumentNode();
if (authorRules.treeBoundaryCrossingRules().isEmpty() && (isDocumentScope || authorRules.shadowDistributedRules().isEmpty()))
return;
OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create();
addRules(ruleSetForScope.get(), authorRules.treeBoundaryCrossingRules());
if (!isDocumentScope)
addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules());
if (!m_treeBoundaryCrossingRuleSet) {
m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRuleSubSet());
treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(treeScope().rootNode());
}
m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope.release()));
}
示例15: ensureAtHostRuleSetFor
void ScopedStyleResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentSecurityOrigin, const ContainerNode* scopingNode)
{
if (!scopingNode)
return;
ShadowRoot* shadowRoot = scopingNode->containingShadowRoot();
if (!shadowRoot || !shadowRoot->host())
return;
RuleSet* rule = ensureAtHostRuleSetFor(shadowRoot);
const Vector<RefPtr<StyleRuleBase> >& childRules = hostRule->childRules();
AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>(hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState);
for (unsigned i = 0; i < childRules.size(); ++i) {
StyleRuleBase* hostStylingRule = childRules[i].get();
if (hostStylingRule->isStyleRule())
rule->addStyleRule(static_cast<StyleRule*>(hostStylingRule), addRuleFlags);
}
}