本文整理汇总了C++中ObjectInputStream::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectInputStream::clear方法的具体用法?C++ ObjectInputStream::clear怎么用?C++ ObjectInputStream::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectInputStream
的用法示例。
在下文中一共展示了ObjectInputStream::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMailDatabase
void ChatManagerImplementation::loadMailDatabase() {
info("Checking mail for expiration...", true);
ObjectDatabase* playerMailDatabase = ObjectDatabaseManager::instance()->loadObjectDatabase("mail", true);
if (playerMailDatabase == NULL) {
error("Could not load the player mail database.");
return;
}
int i = 0;
try {
ObjectDatabaseIterator iterator(playerMailDatabase);
uint64 objectID;
uint32 timeStamp, currentTime = System::getTime();
ObjectInputStream* objectData = new ObjectInputStream(2000);
while (i < 25000 && iterator.getNextKeyAndValue(objectID, objectData)) {
if (!Serializable::getVariable<uint32>(STRING_HASHCODE("PersistentMessage.timeStamp"), &timeStamp, objectData)) {
objectData->clear();
continue;
}
if (currentTime - timeStamp > PM_LIFESPAN) {
Reference<PersistentMessage*> mail = Core::getObjectBroker()->lookUp(objectID).castTo<PersistentMessage*>();
if (mail != NULL) {
i++;
ObjectManager::instance()->destroyObjectFromDatabase(objectID);
}
}
objectData->clear();
}
delete objectData;
} catch (DatabaseException& e) {
error("Database exception in ChatManager::loadMailDatabase(): " + e.getMessage());
}
info("Deleted " + String::valueOf(i) + " mails due to expiration.", true);
}
示例2: loadPlayerStructures
void StructureManager::loadPlayerStructures(const String& zoneName) {
info("Loading player structures from playerstructures.db");
ObjectDatabaseManager* dbManager = ObjectDatabaseManager::instance();
ObjectDatabase* playerStructuresDatabase =
ObjectDatabaseManager::instance()->loadObjectDatabase(
"playerstructures", true);
if (playerStructuresDatabase == NULL) {
error("Could not load the player structures database.");
return;
}
int i = 0;
try {
ObjectDatabaseIterator iterator(playerStructuresDatabase);
uint64 objectID;
ObjectInputStream* objectData = new ObjectInputStream(2000);
String zoneReference;
while (iterator.getNextKeyAndValue(objectID, objectData)) {
if (!Serializable::getVariable<String>(String("SceneObject.zone").hashCode(),
&zoneReference, objectData)) {
objectData->clear();
continue;
}
if (zoneName != zoneReference) {
objectData->clear();
continue;
}
Reference<SceneObject*> object = server->getObject(objectID);
if (object != NULL) {
++i;
if(object->isGCWBase()){
Zone* zone = object->getZone();
if(zone == NULL)
return;
GCWManager* gcwMan = zone->getGCWManager();
if(gcwMan == NULL)
return;
gcwMan->registerGCWBase(cast<BuildingObject*>(object.get()),false);
}
if (ConfigManager::instance()->isProgressMonitorActivated())
printf("\r\tLoading player structures [%d] / [?]\t", i);
} else {
error(
"Failed to deserialize structure with objectID: "
+ String::valueOf(objectID));
}
objectData->clear();
}
delete objectData;
} catch (DatabaseException& e) {
error(
"Database exception in StructureManager::loadPlayerStructures(): "
+ e.getMessage());
}
info(String::valueOf(i) + " player structures loaded for " + zoneName + ".",
true);
}