本文整理汇总了C++中Tags类的典型用法代码示例。如果您正苦于以下问题:C++ Tags类的具体用法?C++ Tags怎么用?C++ Tags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uni
void PertyRemoveTagVisitor::visit(const shared_ptr<Element>& e)
{
boost::uniform_real<> uni(0.0, 1.0);
Tags t = e->getTags();
for (Tags::const_iterator it = t.constBegin(); it != t.constEnd(); ++it)
{
const QString tagKey = it.key();
if (uni(*_rng) <= _p && !_exemptTagKeys.contains(tagKey))
{
if (!_replacementTagKeys.contains(tagKey))
{
LOG_DEBUG("Removing tag with key: " << tagKey << " ...");
e->getTags().remove(tagKey);
}
else
{
const int tagIndex = _replacementTagKeys.indexOf(tagKey);
const QString tagValue = _replacementTagValues.at(tagIndex);
LOG_DEBUG("Substituting value: " << tagValue << " for tag with key: " << tagKey);
e->getTags().set(tagKey, tagValue);
}
}
}
}
示例2: writeElement
void OgrWriter::writeElement(ElementPtr &element, bool debug)
{
//Unfortunately, this check also has to happen in addition to checking hasMoreElements. See
//explanation in ServicesDbReader::readNextElement.
if (element.get())
{
Tags sourceTags = element->getTags();
Tags destTags;
for (Tags::const_iterator it = element->getTags().begin();
it != element->getTags().end(); ++it)
{
if (sourceTags[it.key()] != "")
{
destTags.appendValue(it.key(), it.value());
}
}
// Now that all the empties are gone, update our element
element->setTags(destTags);
if ( debug == true )
{
LOG_DEBUG(element->toString());
}
PartialOsmMapWriter::writePartial(element);
}
}
示例3: GetOutputBuffer
//------------------------------------------------------------------------------------------------------------------------------------
// Helper for ErrorMessenger.
//------------------------------------------------------------------------------------------------------------------------------------
LogMgr::ErrorDialogResult LogMgr::Error(const std::string& errorMessage, bool isFatal, const char* funcName, const char* sourceFile, unsigned int lineNum)
{
string tag = ((isFatal) ? ("FATAL") : ("ERROR"));
// buffer for our final output string
string buffer;
GetOutputBuffer(buffer, tag, errorMessage, funcName, sourceFile, lineNum);
// write the final buffer to all the various logs
m_tagCriticalSection.Lock();
Tags::iterator findIt = m_tags.find(tag);
if (findIt != m_tags.end())
OutputFinalBufferToLogs(buffer, findIt->second);
m_tagCriticalSection.Unlock();
// show the dialog box
int result = ::MessageBoxA(NULL, buffer.c_str(), tag.c_str(), MB_ABORTRETRYIGNORE|MB_ICONERROR|MB_DEFBUTTON3);
// act upon the choice
switch (result)
{
case IDIGNORE : return LogMgr::LOGMGR_ERROR_IGNORE;
case IDABORT : __debugbreak(); return LogMgr::LOGMGR_ERROR_RETRY; // assembly language instruction to break into the debugger
case IDRETRY : return LogMgr::LOGMGR_ERROR_RETRY;
default : return LogMgr::LOGMGR_ERROR_RETRY;
}
}
示例4: toTags
ItemTagsLoader::Tags ItemTagsLoader::toTags(const QStringList &tagList)
{
Tags tags;
for (const auto &tagText : tagList) {
QString tagName = tagText.trimmed();
Tag tag = findMatchingTag(tagName, m_tags);
if (isTagValid(tag)) {
if (tag.match.isEmpty()) {
tag.name = tagName;
} else {
const QRegExp re(tag.match);
tag.name = QString(tagName).replace(re, tag.name);
}
} else {
tag.name = tagName;
// Get default tag style from theme.
const QSettings settings;
tag.color = settings.value("Theme/num_fg").toString();
}
tags.append(tag);
}
return tags;
}
示例5: runEscapeTags
void runEscapeTags()
{
OsmMapPtr map(new OsmMap());
Coordinate coords[] = { Coordinate(0, 0), Coordinate(0, 1), Coordinate(1, 1), Coordinate(1, 0), Coordinate::getNull() };
Tags tags;
tags.set("note", "<2>");
tags.set("aerialway", "t-bar");
tags.set("first name", "first name goes here");
tags.set("full_name", "\"Hacksaw\" Jim Duggan");
WayPtr way = TestUtils::createWay(map, Status::Unknown1, coords);
way->setTags(tags);
QList<ElementPtr> nodes;
NodePtr node1(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.0, 0.1), 15));
node1->getTags().appendValue("name", "test1");
nodes.append(node1);
NodePtr node2(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.1, 0.0), 15));
node2->getTags().appendValue("name", "test2");
nodes.append(node2);
RelationPtr relation = TestUtils::createRelation(map, nodes);
relation->setType("review");
relation->getTags().appendValue("name", "Test Review");
std::vector<RelationData::Entry> members = relation->getMembers();
members[0].role = "reviewee";
members[1].role = "reviewee";
relation->setMembers(members);
QString output = OsmPgCsvWriter::toString(map);
// Compare the results
HOOT_STR_EQUALS(expected_runEscapeTags, output);
}
示例6: _addNonConflictingTags
void TagComparator::_addNonConflictingTags(Tags& t1, const Tags& t2, Tags& result)
{
OsmSchema& schema = OsmSchema::getInstance();
// we're deleting as we iterate so be careful making changes.
for (Tags::iterator it1 = t1.begin(); it1 != t1.end(); )
{
QString kvp1 = it1.key() + "=" + it1.value();
bool conflict = false;
for (Tags::const_iterator it2 = t2.begin(); it2 != t2.end(); ++it2)
{
QString kvp2 = it2.key() + "=" + it2.value();
if (schema.score(kvp1, kvp2) > 0.0)
{
conflict = true;
break;
}
}
if (conflict)
{
++it1;
}
else
{
result[it1.key()] = it1.value();
t1.erase(it1++);
}
}
}
示例7: _overwriteUnrecognizedTags
void TagComparator::_overwriteUnrecognizedTags(Tags& t1, Tags& t2, Tags& result)
{
OsmSchema& schema = OsmSchema::getInstance();
const Tags t1Copy = t1;
for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1)
{
// if this is an unknown type
if (schema.getTagVertex(it1.key() + "=" + it1.value()).isEmpty() &&
schema.getTagVertex(it1.key()).isEmpty())
{
// if this is also in t2.
if (t2.contains(it1.key()))
{
result[it1.key()] = it1.value();
t1.remove(it1.key());
t2.remove(it1.key());
}
}
}
// go through any remaining tags in t2
const Tags t2Copy = t2;
for (Tags::ConstIterator it2 = t2Copy.begin(); it2 != t2Copy.end(); ++it2)
{
// if this is an unknown type
if (schema.getTagVertex(it2.key() + "=" + it2.value()).isEmpty())
{
// we know it isn't in t1, or it would have been handled in the above loop so just deal with
// t2
t2.remove(it2.key());
result[it2.key()] = it2.value();
}
}
}
示例8: fn
bool ExportMultiple::DoExport(bool stereo,
wxString name,
bool selectedOnly,
double t0,
double t1,
int trackNumber)
{
wxFileName fn(mDir->GetValue(), name, mPlugins[mFormatIndex]->GetExtension());
// Generate a unique name if we're not allowed to overwrite
if (!mOverwrite->GetValue()) {
int i = 2;
while (fn.FileExists()) {
fn.SetName(wxString::Format(wxT("%s-%d"), name.c_str(), i++));
}
}
// If the format supports tags, then set the name and track number
if (mPlugins[mFormatIndex]->GetCanMetaData()) {
Tags *tags = mProject->GetTags();
tags->SetTitle(name);
tags->SetTrackNumber(trackNumber);
}
// Call the format export routine
return mPlugins[mFormatIndex]->Export(mProject,
stereo ? 2 : 1,
fn.GetFullPath(),
selectedOnly,
t0,
t1);
}
示例9: getMostEnglishName
QString MostEnglishName::getMostEnglishName(const Tags& tags)
{
if (tags.contains("name:en") && tags.get("name:en").isEmpty() == false)
{
return tags.get("name:en");
}
QStringList names = tags.getNames();
double bestScore = -numeric_limits<double>::max();
QString bestName;
for (int i = 0; i < names.size(); i++)
{
double score = scoreName(names[i]);
if (score > bestScore)
{
bestScore = score;
bestName = names[i];
}
}
return bestName;
}
示例10: ElementConverter
void TranslatedTagCountVisitor::visit(ElementType type, long id)
{
shared_ptr<const Element> e = _map->getElement(type, id);
if (e->getTags().getInformationCount() > 0)
{
shared_ptr<Geometry> g = ElementConverter(_map->shared_from_this()).convertToGeometry(e);
Tags t = e->getTags();
t["error:circular"] = QString::number(e->getCircularError());
t["hoot:status"] = e->getStatusString();
// remove all the empty tags.
for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it)
{
if (t[it.key()] == "")
{
t.remove(it.key());
}
}
QString layerName;
vector<ScriptToOgrTranslator::TranslatedFeature> f = _translator->translateToOgr(t,
e->getElementType(), g->getGeometryTypeId());
// only write the feature if it wasn't filtered by the translation script.
for (size_t i = 0; i < f.size(); i++)
{
_countTags(f[i].feature);
}
}
}
示例11: person_ref
void TestTags::test_item_tags_model() {
Tags tags;
tags.append("Work");
tags.append("Home");
Person *person = new Person;
person->setName("Moe stein");
person->save();
RelationalObjectRef person_ref(person);
RelationalObjectRef tag1 = tags.getObjectRef(0);
RelationalObjectRef tag2 = tags.getObjectRef(1);
ItemTags *item_tags = tags.itemTagsModelFactory(person_ref);
item_tags->tag(tag1);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->untag(tag2);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->tag(tag2);
QCOMPARE(item_tags->rowCount(), 2);
item_tags->untag(tag1);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->untag(tag2);
QCOMPARE(item_tags->rowCount(), 0);
delete item_tags;
delete person;
}
示例12: parseTags
inline Tags parseTags(DBFHandle dbfFile, int k) const
{
char title[12];
int fieldCount = DBFGetFieldCount(dbfFile);
Tags tags;
tags.reserve(fieldCount);
for (int i = 0; i < fieldCount; i++)
{
if (DBFIsAttributeNULL(dbfFile, k, i))
continue;
utymap::formats::Tag tag;
int width, decimals;
DBFFieldType eType = DBFGetFieldInfo(dbfFile, i, title, &width, &decimals);
tag.key = std::string(title);
{
switch (eType)
{
case FTString:
tag.value = DBFReadStringAttribute(dbfFile, k, i);
break;
case FTInteger:
tag.value = to_string(DBFReadIntegerAttribute(dbfFile, k, i));
break;
case FTDouble:
tag.value = to_string(DBFReadDoubleAttribute(dbfFile, k, i));
break;
default:
break;
}
}
tags.push_back(tag);
}
return std::move(tags);
}
示例13: _addExtraNames
void SplitNameVisitor::_addExtraNames(Tags& t, const QStringList& extraNames)
{
int lastNameId = -1;
int size = 0;
QStringList names;
for (int i = 0; i < extraNames.size(); i++)
{
int thisSize = extraNames[i].size();
if (size + thisSize > _maxSize)
{
lastNameId = _getNextNameId(t, lastNameId);
QString k = QString("name:%1").arg(lastNameId);
t.setList(k, names);
names.clear();
size = 0;
}
names.append(extraNames[i]);
size += thisSize + 1;
}
if (names.size() > 0)
{
lastNameId = _getNextNameId(t, lastNameId);
QString k = QString("name:%1").arg(lastNameId);
t.setList(k, names);
}
}
示例14: SelectedItems
Tags List::SelectedItems(int group) const {
Tags selItems;
for (ListItems::const_iterator i = items.begin(); i != items.end(); ++i)
if ((i->state == litPressed) && (i->group & group))
selItems.push_back(i->tag);
return selItems;
}
示例15: _mergeText
void TagComparator::_mergeText(Tags& t1, Tags& t2, Tags& result)
{
OsmSchema& schema = OsmSchema::getInstance();
const Tags t1Copy = t1;
for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1)
{
const SchemaVertex& tv = schema.getTagVertex(it1.key());
// if this is a text field and it exists in both tag sets.
if (tv.valueType == Text && t2.contains(it1.key()))
{
// only keep the unique text fields
QStringList values = t1.getList(it1.key());
values.append(t2.getList(it1.key()));
// append all unique values in the existing order.
for (int i = 0; i < values.size(); i++)
{
if (values[i].isEmpty() == false)
{
result.appendValueIfUnique(it1.key(), values[i]);
}
}
t1.remove(it1.key());
t2.remove(it1.key());
}
}
}