本文整理汇总了C++中VariableList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableList::insert方法的具体用法?C++ VariableList::insert怎么用?C++ VariableList::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableList
的用法示例。
在下文中一共展示了VariableList::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toString
std::string ResultSet::toString (NamespaceMap* namespaces) const {
std::stringstream s;
if (resultType == RESULT_Boolean)
return size() > 0 ? "true\n" : "false\n" ;
else if (resultType == RESULT_Graphs)
return std::string("<RdfDB result>\n") + db->toString() + "\n</RdfDB result>";
/* Get column widths and fill namespace declarations. */
std::vector< const POS* > vars;
std::vector< size_t > widths;
unsigned count = 0;
unsigned lastInKnownVars = 0;
{
std::map< const POS*, unsigned > pos2col;
const VariableVector cols = getOrderedVars();
// vars = getOrderedVars();
for (VariableVectorConstIterator varIt = cols.begin() ; varIt != cols.end(); ++varIt) {
const POS* var = *varIt;
pos2col[var] = count++;
widths.push_back(var->toString().size());
vars.push_back(var);
}
VariableList intruders;
lastInKnownVars = count;
for (ResultSetConstIterator row = results.begin() ; row != results.end(); ++row)
for (BindingSetIterator b = (*row)->begin(); b != (*row)->end(); ++b) {
const POS* var = b->first;
if (pos2col.find(var) == pos2col.end()) {
/* Error: a variable not listed in knownVars. */
pos2col[var] = count++;
std::string rendered(render(var, namespaces));
widths.push_back(rendered.size());
vars.push_back(var);
intruders.insert(var);
}
std::string rendered(render(b->second.pos, namespaces));
size_t width = rendered.size();
if (width > widths[pos2col[var]])
widths[pos2col[var]] = width;
}
}
/* Generate ResultSet string. */
/* Top Border */
unsigned i;
for (i = 0; i < count; i++) {
s << (i == 0 ? (ordered == true ? BoxChars::GBoxChars->ordered : BoxChars::GBoxChars->ul) : BoxChars::GBoxChars->us);
s << STRING(widths[i]+2, BoxChars::GBoxChars->ub);
}
s << BoxChars::GBoxChars->ur << std::endl;
/* Column Headings */
for (i = 0; i < count; i++) {
const POS* var = vars[i];
s << (i == 0 ? BoxChars::GBoxChars->rl : i < lastInKnownVars ? BoxChars::GBoxChars->rs : BoxChars::GBoxChars->unlistedVar) << ' ';
size_t width = var->toString().length();
s << var->toString() << STRING(widths[i] - width, BoxChars::GBoxChars->rb) << ' '; // left justified.
}
s << BoxChars::GBoxChars->rr << std::endl;
/* Rows */
for (ResultSetConstIterator row = results.begin() ; row != results.end(); row++) {
#if (INTRA_ROW_SEPARATORS)
/* Intra-row Border */
for (i = 0; i < count; i++) {
s << (i == 0 ? BoxChars::GBoxChars->sl : BoxChars::GBoxChars->ss);
s << std::string(widths[i]+2, BoxChars::GBoxChars->sb);
}
s << BoxChars::GBoxChars->sr << std::endl;
#endif
/* Values */
for (i = 0; i < count; ++i) {
const POS* var = vars[i];
const POS* val = (*row)->get(var);
const std::string str = render(val, namespaces);
s << (i == 0 ? BoxChars::GBoxChars->rl : BoxChars::GBoxChars->rs) << ' ';
size_t width = str.length();
s << STRING(widths[i] - width, BoxChars::GBoxChars->rb) << str << ' '; // right justified.
}
s << BoxChars::GBoxChars->rr << std::endl;
}
/* Bottom Border */
for (i = 0; i < count; i++) {
s << (i == 0 ? BoxChars::GBoxChars->ll : BoxChars::GBoxChars->ls);
s << STRING(widths[i]+2, BoxChars::GBoxChars->lb);
}
s << BoxChars::GBoxChars->lr << std::endl;
return s.str();
}
示例2: variable
virtual void variable (const Variable* const self, std::string lexicalValue) {
vars.insert(self);
SWObjectDuplicator::variable(self, lexicalValue);
}