本文整理汇总了C++中KeyValuePair类的典型用法代码示例。如果您正苦于以下问题:C++ KeyValuePair类的具体用法?C++ KeyValuePair怎么用?C++ KeyValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyValuePair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setItemStatus
/**
* Fill a key value pair object and set into the partialModification array list.
* This is used to set the changes in the cache or in the listener based sync source.
* If there is an error this error is reported in the saving procedure and there
* it is decided how procede
*/
void CacheSyncSource::setItemStatus(const WCHAR* key, int status, const char* command) {
KeyValuePair vp;
switch (status) {
case 200:
case 201:
case 418:
{
LOG.info("[%s], Received success status code from server for %s on item with key %s - code: %d", getName(), command, key, status);
char* k = toMultibyte(key);
vp.setKey(k);
StringBuffer v(k);
StringBuffer sb = getItemSignature(v);
vp.setValue(sb);
delete [] k;
}
break;
case 500:
default:
LOG.info("[%s], Received failed status code from server for %s on item with key %s - code: %d", getName(), command, key, status);
// error. it doesn't update the cache
break;
}
if (vp.getKey()) {
updateInCache(vp, command);
}
}
开发者ID:ruphy,项目名称:kfunambol,代码行数:35,代码来源:CacheSyncSource.cpp
示例2: insert
void
QcOfflineCacheDatabase::init_version()
{
KeyValuePair kwargs;
kwargs.insert(QStringLiteral("version"), 1);
insert(QStringLiteral("metadata"), kwargs);
}
开发者ID:FabriceSalvaire,项目名称:qtcarto,代码行数:7,代码来源:offline_cache_database.cpp
示例3: QStringLiteral
QSqlQuery
QcOfflineCacheDatabase::insert(const QString & table, const KeyValuePair & kwargs, bool commit_request)
{
QSqlQuery query = new_query();
QStringList fields = kwargs.keys();
QString sql_query =
QStringLiteral("INSERT INTO ") + table +
QStringLiteral(" (") + fields.join(',') + QStringLiteral(") VALUES (");
for (int i = 0; i < fields.size(); i++) {
if (i > 0)
sql_query += ',';
sql_query += '?';
}
sql_query += ')';
qInfo() << sql_query << kwargs;
query.prepare(sql_query);
for (const auto & value : kwargs.values())
query.addBindValue(value);
if (!query.exec())
qWarning() << query.lastError().text();
if (commit_request)
commit();
return query;
}
开发者ID:FabriceSalvaire,项目名称:qtcarto,代码行数:28,代码来源:offline_cache_database.cpp
示例4: while
/**
* The way to calculate the cache is the follow:
* loop on the current element against an array list
* that has the cache. It is the copy of the original cache.
* When an current element is found in the cache, it is removed
* from the cache copy. At the end the remained element
* in the cache are the deleted ones.
*/
bool CacheSyncSource::fillItemModifications() {
// all the current items keys list
Enumeration* items = (Enumeration*)getAllItemList();
if (!items) {
LOG.error("Error in fillItemModification");
return false;
}
// all the action are done on the copy so we can delete
// the element found. The remained are the deleted by the user.
Enumeration& e = cache->getProperties();
ArrayList cacheCopy;
while(e.hasMoreElement()) {
cacheCopy.add(*e.getNextElement());
}
//if (e) {
// delete e;
//}
StringBuffer* key;
KeyValuePair* kvp;
ArrayListEnumeration *newitems = new ArrayListEnumeration(),
*moditems = new ArrayListEnumeration();
if (items) {
while(items->hasMoreElement()) {
key = (StringBuffer*)items->getNextElement();
int size = cacheCopy.size();
bool foundnew = true;
for (int i = 0; i < size; i++) {
kvp = (KeyValuePair*)(cacheCopy[i]);
if (strcmp(kvp->getKey(), key->c_str()) == 0) {
foundnew = false;
// see if it is updated.
StringBuffer sign = getItemSignature(*key);
if (sign != kvp->getValue()) {
// there is an update. if equal nothing to do...
moditems->add(*key);
}
cacheCopy.removeElementAt(i);
break;
}
}
if (foundnew) {
newitems->add(*key);
}
}
}
newKeys = newitems;
updatedKeys = moditems;
deletedKeys = new ArrayListEnumeration(cacheCopy);
delete items;
return true;
}
开发者ID:ruphy,项目名称:kfunambol,代码行数:68,代码来源:CacheSyncSource.cpp
示例5: formattedExportedServices
StringBuffer MHSyncItemInfo::formatExportedServices()
{
StringBuffer formattedExportedServices("");
KeyValuePair kvp = exportedServices.front();
while (kvp.null() == false) {
StringBuffer serviceName = kvp.getKey();
StringBuffer serviceExportTime = kvp.getValue();
if (serviceName.empty() == false) {
StringBuffer formattedService;
formattedService.sprintf("%s:%s", serviceName.c_str(),
serviceExportTime.c_str());
if (formattedExportedServices.empty() == false) {
formattedExportedServices.append(",");
}
formattedExportedServices.append(formattedService.c_str());
}
kvp = exportedServices.next();
}
return formattedExportedServices;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:27,代码来源:MHSyncItemInfo.cpp
示例6: testGetProperties
void testGetProperties() {
// Add three properties
propFile->setPropertyValue("property1", "value1");
propFile->setPropertyValue("property2", "value2");
propFile->setPropertyValue("property3", "value3");
propFile->setPropertyValue(" property5 ", " value5 ");
// Now iterate on them
Enumeration& enumeration = propFile->getProperties();
bool prop1 = false, prop2 = false, prop3 = false, prop4 = false;
while (enumeration.hasMoreElement()) {
KeyValuePair* item = (KeyValuePair*)enumeration.getNextElement();
const char* key = item->getKey();
const char* value = item->getValue();
CPPUNIT_ASSERT(value != NULL && strlen(value) > 0);
if (strcmp(key, "property1") == 0) {
prop1 = true;
} else if (strcmp(key, "property2") == 0) {
prop2 = true;
} else if (strcmp(key, "property3") == 0) {
prop3 = true;
} else if (strcmp(key, "property5") == 0) {
prop4 = true;
}
}
propFile->close();
CPPUNIT_ASSERT(prop1 && prop2 && prop3 && prop4);
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:27,代码来源:PropertyFileTest.cpp
示例7: findKey
std::list<Node*>::iterator findKey(std::string key) {
for (auto it = _children.begin(); it != _children.end(); ++it) {
if ((*it)->_type == Node::NodeType::Key) {
KeyValuePair *kv = static_cast<KeyValuePair*>(*it);
if (kv->key() == key) return it;
}
}
return _children.end();
}
开发者ID:comkieffer,项目名称:Utils,代码行数:10,代码来源:Ini_dataStructures.hpp
示例8: updateInCache
int CacheSyncSource::updateInCache(KeyValuePair& k, const char* action) {
if (strcmp(action, ADD ) == 0 ||
strcmp(action, REPLACE) == 0) {
cache->setPropertyValue(k.getKey(), k.getValue());
} else if (strcmp(action, DEL) == 0) {
cache->removeProperty(k.getKey());
}
return 0;
}
开发者ID:ruphy,项目名称:kfunambol,代码行数:10,代码来源:CacheSyncSource.cpp
示例9: get_map_level_id
QString
QcOfflineCacheDatabase::tile_where_clause(const QcTileSpec & tile_spec)
{
int map_level_id = get_map_level_id(tile_spec);
KeyValuePair kwargs;
kwargs.insert(MAP_LEVEL_ID, map_level_id);
kwargs.insert(ROW, tile_spec.x());
kwargs.insert(COLUMN, tile_spec.y());
return format_simple_where(kwargs);
}
开发者ID:FabriceSalvaire,项目名称:qtcarto,代码行数:10,代码来源:offline_cache_database.cpp
示例10: printStringMap
void CustomConfig::printStringMap() {
if (extraProps.empty()) {
LOG.debug("config StringMap is empty");
}
KeyValuePair kvp = (KeyValuePair)extraProps.front();
while (kvp.null() == false) {
LOG.debug("config key: %s, value: %s", kvp.getKey().c_str(), kvp.getValue().c_str());
kvp = extraProps.next();
}
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:10,代码来源:CustomConfig.cpp
示例11: getKeyAndSignature
void CacheSyncSource::getKeyAndSignature(SyncItem& item, KeyValuePair& kvp) {
char* t = toMultibyte(item.getKey());
StringBuffer s(t);
StringBuffer sign = getItemSignature(s);
kvp.setKey(t);
kvp.setValue(sign);
delete [] t;
}
开发者ID:ruphy,项目名称:kfunambol,代码行数:10,代码来源:CacheSyncSource.cpp
示例12: testGetPropertiesFromStorage
void testGetPropertiesFromStorage() {
// Now iterate on them
Enumeration& enumeration = propFile->getProperties();
bool prop1 = false, prop2 = false, prop3 = false, prop4 = false, prop5 = false,
prop6 = false, prop7 = false, prop8 = false, prop9 = false, prop10 = false,
prop11 = false, prop12 = false, prop13 = false, prop14 = false, prop15 = false,
prop16 = false;
while (enumeration.hasMoreElement()) {
KeyValuePair* item = (KeyValuePair*)enumeration.getNextElement();
const char* key = item->getKey();
const char* value = item->getValue();
CPPUNIT_ASSERT(value != NULL && strlen(value) > 0);
if (strcmp(key, "property1") == 0 && strcmp(value, "valueNew") == 0 ) {
prop1 = true;
} else if (strcmp(key, "property2") == 0 && strcmp(value, "value2") == 0 ) {
prop2 = true;
} else if (strcmp(key, "1234") == 0 && strcmp(value, "5678") == 0 ) {
prop3 = true;
} else if (strcmp(key, "123=4") == 0 && strcmp(value, "567=8") == 0 ) {
prop4 = true;
} else if (strcmp(key, "1234=") == 0 && strcmp(value, "567=8") == 0 ) {
prop5 = true;
} else if (strcmp(key, "1=234=") == 0 && strcmp(value, "5=67=8") == 0 ) {
prop6 = true;
} else if (strcmp(key, "678=") == 0 && strcmp(value, "9=10=11") == 0 ) {
prop7 = true;
} else if (strcmp(key, "6\\") == 0 && strcmp(value, "11") == 0 ) {
prop8 = true;
} else if (strcmp(key, "\\") == 0 && strcmp(value, "11") == 0 ) {
prop9 = true;
} else if (strcmp(key, "=") == 0 && strcmp(value, "11") == 0 ) {
prop10 = true;
} else if (strcmp(key, "6=\\") == 0 && strcmp(value, "\\11") == 0 ) {
prop11 = true;
} else if (strcmp(key, "6\\\\") == 0 && strcmp(value, "\\11") == 0 ) {
prop12 = true;
} else if (strcmp(key, "6\\\\=") == 0 && strcmp(value, "\\11") == 0 ) {
prop13 = true;
} else if (strcmp(key, "6\\=") == 0 && strcmp(value, "\\11") == 0 ) {
prop14 = true;
} else if (strcmp(key, "6\\\\\\=\\") == 0 && strcmp(value, "\\11") == 0 ) {
prop15 = true;
} else if (strcmp(key, "6\\\\\\=\\=") == 0 && strcmp(value, "=\\11") == 0 ) {
prop16 = true;
}
}
propFile->close();
CPPUNIT_ASSERT(prop1 && prop2 && prop3 && prop4 && prop5 &&
prop6 && prop7 && prop8 && prop9 && prop10 && prop11 &&
prop12 && prop13 && prop14 && prop15 && prop16);
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:53,代码来源:PropertyFileTest.cpp
示例13: get
std::string get(std::string key) {
auto res = findKey(key);
if (res == _children.end()) {
//std::cerr << "GET failure : invalid key\n";
//std::cerr << "dump : \n" << dump();
throw InvalidKeyException();
}
KeyValuePair *k = static_cast<KeyValuePair*>(*res);
return k->value();
}
开发者ID:comkieffer,项目名称:Utils,代码行数:12,代码来源:Ini_dataStructures.hpp
示例14: sqlGetPropertyString
/*
* Returns the value of the given property
*
*@param prop - the property name
*
*@return A NULL StringBuffer in the returned implies that
* the property was not set. Otherwise the value it was
* set to is returned (which can be "", the empty string).
*/
StringBuffer SQLKeyValueStore::readPropertyValue(const char *prop) const
{
StringBuffer sqlQuery = sqlGetPropertyString(StringBuffer(prop));
Enumeration& en = query(sqlQuery);
if (en.hasMoreElement())
{
KeyValuePair * kvp = (KeyValuePair*)(en.getNextElement());
return kvp->getValue();
}
return StringBuffer(NULL);
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:22,代码来源:SQLKeyValueStore.cpp
示例15: findElement
// Find the element in the StringMap with the given key.
int StringMap::findElement(const char *key) {
KeyValuePair *e;
int i=0;
for (e=(KeyValuePair*)c.front(); e; e=(KeyValuePair*)c.next()) {
if ( e->getKey() == key ) {
return i; // item found
}
i++;
}
return -1;
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:15,代码来源:StringMap.cpp
示例16: testRemoveAll
void testRemoveAll() {
// Iterate on all properties
Enumeration& enumeration = propFile->getProperties();
while (enumeration.hasMoreElement()) {
KeyValuePair* item = (KeyValuePair*)enumeration.getNextElement();
const char* key = item->getKey();
int success = propFile->removeProperty(key);
CPPUNIT_ASSERT(success == 0);
}
propFile->close();
// Now iterate again, and we should have now more elements
enumeration = propFile->getProperties();
CPPUNIT_ASSERT(!enumeration.hasMoreElement());
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:14,代码来源:PropertyFileTest.cpp
示例17: ret
USE_NAMESPACE
StringBuffer MemoryKeyValueStore::readPropertyValue(const char *prop) const {
StringBuffer ret(NULL);
for(int index = 0; index < data.size(); index++) {
KeyValuePair *kvp = (KeyValuePair *)data.get(index);
if (strcmp(prop, kvp->getKey()) == 0) {
ret = kvp->getValue();
break;
}
}
return ret;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:14,代码来源:MemoryKeyValueStore.cpp
示例18: k
int MemoryKeyValueStore::setPropertyValue(const char *prop, const char *value) {
int ret = 0;
for(KeyValuePair* kvp = (KeyValuePair *)data.front();
kvp;
kvp = (KeyValuePair *)data.next()) {
if (strcmp(prop, kvp->getKey()) == 0) {
kvp->setValue(value);
return ret;
}
}
KeyValuePair k(prop, value);
data.add(k);
return ret;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:15,代码来源:MemoryKeyValueStore.cpp
示例19: removeProperty
int MemoryKeyValueStore::removeProperty(const char *prop) {
int counter = 0;
for(KeyValuePair* kvp = (KeyValuePair *)data.front();
kvp;
kvp = (KeyValuePair *)data.next()) {
if (strcmp(prop, kvp->getKey()) == 0) {
data.removeElementAt(counter);
break;
}
counter++;
}
return 0;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:15,代码来源:MemoryKeyValueStore.cpp
示例20: tile_where_clause
void
QcOfflineCacheDatabase::delete_tile(const QcTileSpec & tile_spec)
{
QString where = tile_where_clause(tile_spec);
QSqlRecord record = select_one(TILE, QStringList(OFFLINE_COUNT), where);
if (!record.isEmpty()) {
int offline_count = record.value(0).toInt();
if (offline_count > 1) {
KeyValuePair kwargs;
kwargs.insert(OFFLINE_COUNT, offline_count -1);
update(TILE, kwargs, where);
}
else
delete_row(TILE, where);
}
}
开发者ID:FabriceSalvaire,项目名称:qtcarto,代码行数:16,代码来源:offline_cache_database.cpp
注:本文中的KeyValuePair类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论