当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectOutputStream类代码示例

本文整理汇总了C++中ObjectOutputStream的典型用法代码示例。如果您正苦于以下问题:C++ ObjectOutputStream类的具体用法?C++ ObjectOutputStream怎么用?C++ ObjectOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: info

void ObjectVersionUpdateManager::updateCityTreasuryToDouble(){

	info("---------------MOdifying City Treasury---------------------",true);
	info("Converting treasury to double for all cities ", true);
	ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("cityregions", true);
	ObjectInputStream objectData(2000);

	String className;
	ObjectDatabaseIterator iterator(database);

	uint64 objectID = 0;
	int count = 0;
	try {
		while (iterator.getNextKeyAndValue(objectID, &objectData)) {

			String className;
			try {

				if (!Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)) {

					objectData.clear();
					continue;
				}
			} catch (...) {
				objectData.clear();
				continue;
			}
			float funds;
			double floatFunds = 5;

			if (className == "CityRegion") {
				count++;
				printf("\r\tUpdating city treasury [%d] / [?]\t", count);
				if ( Serializable::getVariable<float>(STRING_HASHCODE("CityRegion.cityTreasury"), &funds, &objectData)){

					floatFunds = funds;
					ObjectOutputStream newFunds;
					TypeInfo<double>::toBinaryStream(&floatFunds, &newFunds );
					ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("CityRegion.cityTreasury"), &objectData, &newFunds);
					test->reset();
					database->putData(objectID, test, NULL);


				} else {
					info("Error... city " + String::valueOf(objectID) + " doesn't have cityTreasury variable",true);
				}
			}

			objectData.clear();


		}

	} catch (Exception& e) {
		error(e.getMessage());
		e.printStackTrace();
	}

}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:59,代码来源:ObjectVersionUpdateManager.cpp

示例2: serialize

void XojFont::serialize(ObjectOutputStream& out)
{
	XOJ_CHECK_TYPE(XojFont);

	out.writeObject("XojFont");

	out.writeString(this->name);
	out.writeDouble(this->size);

	out.endObject();
}
开发者ID:cass00,项目名称:xournalpp,代码行数:11,代码来源:Font.cpp

示例3: serializeElement

void Element::serializeElement(ObjectOutputStream& out)
{
	XOJ_CHECK_TYPE(Element);

	out.writeObject("Element");

	out.writeDouble(this->x);
	out.writeDouble(this->y);
	out.writeInt(this->color);

	out.endObject();
}
开发者ID:project-renard-survey,项目名称:xournalpp,代码行数:12,代码来源:Element.cpp

示例4: serialize

void Text::serialize(ObjectOutputStream & out) {
	XOJ_CHECK_TYPE(Text);

	out.writeObject("Text");

	serializeElement(out);

	out.writeString(this->text);

	font.serialize(out);

	out.endObject();
}
开发者ID:yolanother,项目名称:Xournal,代码行数:13,代码来源:Text.cpp

示例5: serialize

void Image::serialize(ObjectOutputStream & out) {
	XOJ_CHECK_TYPE(Image);

	out.writeObject("Image");

	serializeElement(out);

	out.writeDouble(this->width);
	out.writeDouble(this->height);

	out.writeImage(this->image);

	out.endObject();
}
开发者ID:wbrenna,项目名称:xournalpp,代码行数:14,代码来源:Image.cpp

示例6: write

void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
    if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
         os.writeNull(p);
    } else {
        unsigned char prolog[] = {
         0x72,
         0x00,
         0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
         0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
         0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
         0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
         0x00,
         0x01, 0x4C,
         0x00,
         0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74,
         0x00,
         0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
         0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
        };
      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
        char* line = p.itoa(lineNumber);
        //
        //   construct Java-like fullInfo (replace "::" with ".")
        //
        std::string fullInfo(methodName);
        size_t openParen = fullInfo.find('(');
        if (openParen != std::string::npos) {
            size_t space = fullInfo.find(' ');
            if (space != std::string::npos && space < openParen) {
                fullInfo.erase(0, space + 1);
            }
        }
        openParen = fullInfo.find('(');
        if (openParen != std::string::npos) {
            size_t classSep = fullInfo.rfind("::", openParen);
            if (classSep != std::string::npos) {
                fullInfo.replace(classSep, 2, ".");
            } else {
                fullInfo.insert(0, ".");
            }
        }
        fullInfo.append(1, '(');
        fullInfo.append(fileName);
        fullInfo.append(1, ':');
        fullInfo.append(line);
        fullInfo.append(1, ')');
        os.writeUTFString(fullInfo, p);
    }
}
开发者ID:delta1766,项目名称:logging-log4cxx,代码行数:49,代码来源:locationinfo.cpp

示例7: getVariableDataOffset

ObjectOutputStream* ObjectVersionUpdateManager::changeVariableData(const uint32& variableHashCode, ObjectInputStream* object, Stream* newVariableData) {
	int offset = getVariableDataOffset(variableHashCode, object);

	if (offset == -1)
		return NULL;

	ObjectOutputStream* newData = new ObjectOutputStream(object->size());
	object->copy(newData);

	object->reset();
	newData->reset();
	object->shiftOffset(offset - 4);
	uint32 dataSize = object->readInt();

	newData->shiftOffset(offset); //we go data length

	if (dataSize > 0)
		newData->removeRange(offset, offset + dataSize);

	newData->writeInt(offset - 4, newVariableData->size());
	newData->insertStream(newVariableData, newVariableData->size(), offset);

	object->reset();
	//newData->reset();

	return newData;
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:27,代码来源:ObjectVersionUpdateManager.cpp

示例8: objectData

void ObjectVersionUpdateManager::setResidence(uint64 buildingID, bool isResidence){
	ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("playerstructures", true);
	ObjectInputStream objectData(2000);

	bool res  = isResidence;
	String className;

	ObjectOutputStream newResidenceValue;
	TypeInfo<bool>::toBinaryStream(&res, &newResidenceValue );

	if(!database->getData(buildingID,&objectData)){


		if ( Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)){

			if(className == "BuildingObject"){
				if ( !Serializable::getVariable<bool>(STRING_HASHCODE("BuildingObject.isOwnerResidence"), &isResidence, &objectData)){
					//info("setResidence() adding the variable",true);
					ObjectOutputStream* newVariableData = addVariable("BuildingObject.isOwnerResidence", &objectData, &newResidenceValue);
					database->putData(buildingID, newVariableData, NULL);

				} else {
					//info("setResidence() has variable and value = " + String::valueOf(isResidence) +  " ... changing it",true);
					ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("BuildingObject.isOwnerResidence"), &objectData, &newResidenceValue);
					test->reset();
					database->putData(buildingID, test, NULL);
				}

			}
		} else {

			info("ERROR couldn't get object " + String::valueOf(buildingID),true);

		}


	}
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:38,代码来源:ObjectVersionUpdateManager.cpp

示例9: serialize

void EditSelection::serialize(ObjectOutputStream & out) {
	out.writeObject("EditSelection");

	out.writeDouble(this->x);
	out.writeDouble(this->y);
	out.writeDouble(this->width);
	out.writeDouble(this->height);

	out << this->contents;
	out.endObject();

	ListIterator<Element *> it = this->getElements();
	int count = it.getLength();
	out.writeInt(count);

	while (it.hasNext()) {
		Element * e = it.next();
		out << e;
	}
}
开发者ID:wbrenna,项目名称:xournalpp,代码行数:20,代码来源:EditSelection.cpp

示例10: ObjectOutputStream

ObjectOutputStream* ObjectVersionUpdateManager::addVariable(String variableName, ObjectInputStream* object, Stream* newVariableData){
	object->reset();

	uint16 oldVariableCount = object->readShort();
	//info("first variable count is " + String::valueOf(oldVariableCount),true);
	ObjectOutputStream* newData = new ObjectOutputStream(object->size());
	object->copy(newData, 0);

	newData->writeShort(0, oldVariableCount + 1);
	newData->setOffset(newData->size());


	uint32 _nameHashCode = variableName.hashCode();
	TypeInfo<uint32>::toBinaryStream(&_nameHashCode, newData);
	newData->writeInt(newVariableData->size());
	newData->writeStream(newVariableData);

	return newData;


}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:21,代码来源:ObjectVersionUpdateManager.cpp

示例11: writeObject

void EntryRemovedEvent::writeObject (ObjectOutputStream& out) const
{
    presents::dobj::EntryEvent::writeObject(out);
    out.writeObject(key);
}
开发者ID:691739159,项目名称:narya,代码行数:5,代码来源:EntryRemovedEvent.cpp

示例12: writeObject

void DObject::writeObject (ObjectOutputStream& out) const
{
    out.writeInt(oid);
}
开发者ID:691739159,项目名称:narya,代码行数:4,代码来源:DObject.cpp

示例13: writeObject

void BoxedShort::writeObject (ObjectOutputStream& out) const
{
    out.writeShort(value);
}
开发者ID:691739159,项目名称:narya,代码行数:4,代码来源:BoxedShort.cpp

示例14: writeTo

void ArrayMask::writeTo (ObjectOutputStream& out)
{
    out.writeShort((int16) _length);
    out.writeBytes(_mask, _length);
}
开发者ID:691739159,项目名称:narya,代码行数:5,代码来源:ArrayMask.cpp

示例15: iterator

void ObjectVersionUpdateManager::updateStructurePermissionLists() {
	ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("playerstructures", true);

	ObjectDatabaseIterator iterator(database);

	ObjectInputStream objectData(2000);
	uint64 objectID = 0;
	int count = 0;

	info("Setting owner on structure permission lists",true);

	try {

		while (iterator.getNextKeyAndValue(objectID, &objectData)) {

			String className;

			try {
				if (!Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)) {
					objectData.clear();
					continue;
				}
			} catch (...) {
				objectData.clear();
				continue;
			}

			if (className == "BuildingObject" || className == "InstallationObject" || className == "GarageInstallation" || className == "ShuttleInstallation") {
				uint64 ownerID = 0;
				String ownerName;
				count ++;
				printf("\r\tUpdating structure owners [%d] / [?]\t", count);

				if( Serializable::getVariable<uint64>(STRING_HASHCODE("StructureObject.ownerObjectID"), &ownerID, &objectData)) {
					StructurePermissionList permissionList;

					if ( Serializable::getVariable<StructurePermissionList>(STRING_HASHCODE("StructureObject.structurePermissionList"), &permissionList, &objectData)){
						ObjectOutputStream newOutputStream;
						permissionList.setOwner(ownerID);
						permissionList.toBinaryStream(&newOutputStream);

						ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("StructureObject.structurePermissionList"), &objectData, &newOutputStream);
						test->reset();
						database->putData(objectID, test, NULL);
					} else {
						info("ERROR unable to get structurePermissionList for structure " + String::valueOf(objectID),true);
					}

				} else {
					info("ERROR unable to get ownerObjectID for structure " + String::valueOf(objectID),true);
				}
			}
			objectData.clear();
		}
	} catch (Exception& e) {
		error(e.getMessage());
		e.printStackTrace();
	}
	info("Done updating owner on structure permission lists\n",true);

}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:61,代码来源:ObjectVersionUpdateManager.cpp


注:本文中的ObjectOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。