本文整理汇总了C++中PropertyMap::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyMap::contains方法的具体用法?C++ PropertyMap::contains怎么用?C++ PropertyMap::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyMap
的用法示例。
在下文中一共展示了PropertyMap::contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void testPropertyInterface2()
{
APE::Tag tag;
APE::Item item1 = APE::Item("TRACK", "17");
tag.setItem("TRACK", item1);
APE::Item item2 = APE::Item();
item2.setType(APE::Item::Binary);
tag.setItem("TESTBINARY", item2);
PropertyMap properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(1u, properties.unsupportedData().size());
CPPUNIT_ASSERT(properties.contains("TRACKNUMBER"));
CPPUNIT_ASSERT(!properties.contains("TRACK"));
CPPUNIT_ASSERT(tag.itemListMap().contains("TESTBINARY"));
tag.removeUnsupportedProperties(properties.unsupportedData());
CPPUNIT_ASSERT(!tag.itemListMap().contains("TESTBINARY"));
APE::Item item3 = APE::Item("TRACKNUMBER", "29");
tag.setItem("TRACKNUMBER", item3);
properties = tag.properties();
CPPUNIT_ASSERT_EQUAL((unsigned int)2, properties["TRACKNUMBER"].size());
CPPUNIT_ASSERT_EQUAL(String("17"), properties["TRACKNUMBER"][0]);
CPPUNIT_ASSERT_EQUAL(String("29"), properties["TRACKNUMBER"][1]);
}
示例2: testInvalidKeys
void testInvalidKeys()
{
PropertyMap properties;
properties["A"] = String("invalid key: one character");
properties["MP+"] = String("invalid key: forbidden string");
properties["A B~C"] = String("valid key: space and tilde");
properties["ARTIST"] = String("valid key: normal one");
APE::Tag tag;
PropertyMap unsuccessful = tag.setProperties(properties);
CPPUNIT_ASSERT_EQUAL((unsigned int)2, unsuccessful.size());
CPPUNIT_ASSERT(unsuccessful.contains("A"));
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
}
示例3: testPropertyInterface
void testPropertyInterface()
{
Mod::Tag t;
PropertyMap properties;
properties["BLA"] = String("bla");
properties["ARTIST"] = String("artist1");
properties["ARTIST"].append("artist2");
properties["TITLE"] = String("title");
PropertyMap unsupported = t.setProperties(properties);
CPPUNIT_ASSERT(unsupported.contains("BLA"));
CPPUNIT_ASSERT(unsupported.contains("ARTIST"));
CPPUNIT_ASSERT_EQUAL(properties["ARTIST"], unsupported["ARTIST"]);
CPPUNIT_ASSERT(!unsupported.contains("TITLE"));
}
示例4: if
PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties)
{
// check which keys are to be deleted
StringList toRemove;
for(FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
if (!properties.contains(it->first))
toRemove.append(it->first);
for(StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it)
removeField(*it);
// now go through keys in \a properties and check that the values match those in the xiph comment
PropertyMap invalid;
PropertyMap::ConstIterator it = properties.begin();
for(; it != properties.end(); ++it)
{
if(!checkKey(it->first))
invalid.insert(it->first, it->second);
else if(!d->fieldListMap.contains(it->first) || !(it->second == d->fieldListMap[it->first])) {
const StringList &sl = it->second;
if(sl.size() == 0)
// zero size string list -> remove the tag with all values
removeField(it->first);
else {
// replace all strings in the list for the tag
StringList::ConstIterator valueIterator = sl.begin();
addField(it->first, *valueIterator, true);
++valueIterator;
for(; valueIterator != sl.end(); ++valueIterator)
addField(it->first, *valueIterator, false);
}
}
}
return invalid;
}
示例5: testInvalidKeys
void testInvalidKeys()
{
PropertyMap properties;
properties["A"] = String("invalid key: one character");
properties["MP+"] = String("invalid key: forbidden string");
properties["A B~C"] = String("valid key: space and tilde");
properties["ARTIST"] = String("valid key: normal one");
APE::Tag tag;
PropertyMap unsuccessful = tag.setProperties(properties);
CPPUNIT_ASSERT_EQUAL((unsigned int)2, unsuccessful.size());
CPPUNIT_ASSERT(unsuccessful.contains("A"));
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
CPPUNIT_ASSERT_EQUAL((unsigned int)2, tag.itemListMap().size());
tag.addValue("VALID KEY", "Test Value 1");
tag.addValue("INVALID KEY \x7f", "Test Value 2");
CPPUNIT_ASSERT_EQUAL((unsigned int)3, tag.itemListMap().size());
}
示例6: initialise
void FileDialog::initialise(const Root* r, const PropertyMap& p) {
Window::initialise(r, p);
if(m_client->getWidgetCount()==0) return; // Nothing
// Cache sub widgets
m_list = getWidget<Listbox>("filelist");
m_file = getWidget<Textbox>("filename");
m_dir = getWidget<Textbox>("path");
m_confirm = getWidget<Button>("confirm");
// Set up callbacks
m_list->eventSelected.bind(this, &FileDialog::selectFile);
m_list->eventMouseDown.bind(this, &FileDialog::clickFile);
m_confirm->eventPressed.bind(this, &FileDialog::pressConfirm);
m_file->eventChanged.bind(this, &FileDialog::changedFileName);
m_file->eventSubmit.bind(this, &FileDialog::submitFileName);
m_dir->eventSubmit.bind(this, &FileDialog::changedDirectory);
Button* btn = getWidget<Button>("up");
if(btn) btn->eventPressed.bind(this, &FileDialog::pressUp);
btn = getWidget<Button>("back");
if(btn) btn->eventPressed.bind(this, &FileDialog::pressBack);
btn = getWidget<Button>("fwd");
if(btn) btn->eventPressed.bind(this, &FileDialog::pressForward);
// Cache icons
m_folderIcon = m_list->getIconList()->getIconIndex("folder");
m_fileIcon = m_list->getIconList()->getIconIndex("file");
// Load properties
const char* initialPath = ".";
if(p.contains("filter")) setFilter( p["filter"] );
if(p.contains("dir")) initialPath = p["dir"];
// Initial directory
char buffer[FILENAME_MAX];
Directory::getFullPath(initialPath, buffer);
setDirectory(buffer);
}
示例7: if
PropertyMap MP4::Tag::setProperties(const PropertyMap &props)
{
static Map<String, String> reverseKeyMap;
if(reverseKeyMap.isEmpty()) {
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
for(int i = 0; i < numKeys; i++) {
reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
}
}
PropertyMap origProps = properties();
PropertyMap::ConstIterator it = origProps.begin();
for(; it != origProps.end(); ++it) {
if(!props.contains(it->first) || props[it->first].isEmpty()) {
d->items.erase(reverseKeyMap[it->first]);
}
}
PropertyMap ignoredProps;
it = props.begin();
for(; it != props.end(); ++it) {
if(reverseKeyMap.contains(it->first)) {
String name = reverseKeyMap[it->first];
if((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && !it->second.isEmpty()) {
int first = 0, second = 0;
StringList parts = StringList::split(it->second.front(), "/");
if(parts.size() > 0) {
first = parts[0].toInt();
if(parts.size() > 1) {
second = parts[1].toInt();
}
d->items[name] = MP4::Item(first, second);
}
}
else if(it->first == "BPM" && !it->second.isEmpty()) {
int value = it->second.front().toInt();
d->items[name] = MP4::Item(value);
}
else if(it->first == "COMPILATION" && !it->second.isEmpty()) {
bool value = (it->second.front().toInt() != 0);
d->items[name] = MP4::Item(value);
}
else {
d->items[name] = it->second;
}
}
else {
ignoredProps.insert(it->first, it->second);
}
}
return ignoredProps;
}
示例8: if
PropertyMap ASF::Tag::setProperties(const PropertyMap &props)
{
static Map<String, String> reverseKeyMap;
if(reverseKeyMap.isEmpty()) {
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
for(int i = 0; i < numKeys; i++) {
reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
}
}
PropertyMap origProps = properties();
PropertyMap::ConstIterator it = origProps.begin();
for(; it != origProps.end(); ++it) {
if(!props.contains(it->first) || props[it->first].isEmpty()) {
if(it->first == "TITLE") {
d->title = String::null;
}
else if(it->first == "ARTIST") {
d->artist = String::null;
}
else if(it->first == "COMMENT") {
d->comment = String::null;
}
else if(it->first == "COPYRIGHT") {
d->copyright = String::null;
}
else {
d->attributeListMap.erase(reverseKeyMap[it->first]);
}
}
}
PropertyMap ignoredProps;
it = props.begin();
for(; it != props.end(); ++it) {
if(reverseKeyMap.contains(it->first)) {
String name = reverseKeyMap[it->first];
removeItem(name);
StringList::ConstIterator it2 = it->second.begin();
for(; it2 != it->second.end(); ++it2) {
addAttribute(name, *it2);
}
}
else if(it->first == "TITLE") {
d->title = it->second.toString();
}
else if(it->first == "ARTIST") {
d->artist = it->second.toString();
}
else if(it->first == "COMMENT") {
d->comment = it->second.toString();
}
else if(it->first == "COPYRIGHT") {
d->copyright = it->second.toString();
}
else {
ignoredProps.insert(it->first, it->second);
}
}
return ignoredProps;
}