Ejemplo n.º 1
0
void CCmpPathfinder::Serialize(ISerializer& serialize)
{
    SerializeVector<SerializeLongRequest>()(serialize, "long requests", m_AsyncLongPathRequests);
    SerializeVector<SerializeShortRequest>()(serialize, "short requests", m_AsyncShortPathRequests);
    serialize.NumberU32_Unbounded("next ticket", m_NextAsyncTicket);
    serialize.NumberU16_Unbounded("same turn moves count", m_SameTurnMovesCount);
}
Ejemplo n.º 2
0
void Controller::writeScene(int plugin, const QString & filename)
{
    ISerializer * s;
    s = pl->getWriter(plugin, filename);
//    s = new WriterXML(filename);
    World * w = model->setScene();
    s->sWorld(w);
    delete s;
}
 virtual void write_worker(IWork *worker) override
 {
    ISerializable *object = dynamic_cast<ISerializable*>(worker);
    if (object != nullptr)
    {
       ISerializer* serializer = dynamic_cast<ISerializer*>(this);
       serializer->write_string(typeid(*worker).raw_name());
       object->serialize(serializer);
    }
 }
Ejemplo n.º 4
0
void CompoundCommand::serialize(ISerializer& serializer) const
{
	serializer.serialize(getId());
	serializer.serialize(getSubCommands().size());
	for (auto& c : getSubCommands())
	{
		serializer.serialize(c.first);
	}
	getMacroObject().getBase<MacroObject>()->serialize(serializer);
}
Ejemplo n.º 5
0
	virtual void Serialize(ISerializer& serialize)
	{
		// TODO: store the actor name, if !debug and it differs from the template

		if (serialize.IsDebug())
		{
			serialize.String("actor", m_ActorName, 0, 256);
		}

		SerializeCommon(serialize);
	}
void RPURU::saveRedoData(ISerializer& serializer, const ReflectedPropertyUndoRedoHelper& helper)
{
	const char* propertyHeaderTag = RPURU::getPropertyHeaderTag();
	// write header
	serializer.serialize(propertyHeaderTag);
	// write root object id
	serializer.serialize(helper.objectId_.toString());
	// write property fullPath
	serializer.serialize(helper.path_);
	// write value
	serializer.serialize(helper.postValue_);
}
Ejemplo n.º 7
0
	virtual void Serialize(ISerializer& serialize)
	{
		JSContext* cx = GetSimContext().GetScriptInterface().GetContext();
		JSAutoRequest rq(cx);

		serialize.NumberU32_Unbounded("num commands", (u32)m_LocalQueue.size());
		for (size_t i = 0; i < m_LocalQueue.size(); ++i)
		{
			serialize.NumberI32_Unbounded("player", m_LocalQueue[i].player);
			serialize.ScriptVal("data", &m_LocalQueue[i].data);
		}
	}
Ejemplo n.º 8
0
void KeysStorage::serialize(ISerializer& serializer, const std::string& name) {
  serializer.beginObject(name);

  serializer(creationTimestamp, "creation_timestamp");

  serializer(spendPublicKey, "spend_public_key");
  serializer(spendSecretKey, "spend_secret_key");

  serializer(viewPublicKey, "view_public_key");
  serializer(viewSecretKey, "view_secret_key");

  serializer.endObject();
}
Ejemplo n.º 9
0
void CompoundCommand::deserialize(ISerializer& serializer)
{
	size_t size = 0;
	serializer.deserialize(size);

	std::string id;
	for (size_t i = 0; i < size; ++i)
	{
		serializer.deserialize(id);
		addCommand(id.c_str(), ObjectHandle());
	}
	getMacroObject().getBase<MacroObject>()->deserialize(serializer);
}
void serialize(TransactionOutputTarget& output, ISerializer& serializer) {
  if (serializer.type() == ISerializer::OUTPUT) {
    BinaryVariantTagGetter tagGetter;
    uint8_t tag = boost::apply_visitor(tagGetter, output);
    serializer.binary(&tag, sizeof(tag), "type");

    VariantSerializer visitor(serializer, "data");
    boost::apply_visitor(visitor, output);
  } else {
    uint8_t tag;
    serializer.binary(&tag, sizeof(tag), "type");

    getVariantValue(serializer, tag, output);
  }
}
bool WalletUnconfirmedTransactions::serialize(ISerializer& s) {
  s(m_unconfirmedTxs, "transactions");
  if (s.type() == ISerializer::INPUT) {
    collectUsedOutputs();
  }
  return true;
}
void serialize(const char* file)
{
   project_manager pm("Agnes");
   pm.add_team_member(new cpp_developer("Bill"));
   pm.add_team_member(new cpp_developer("Chris"));
   pm.add_team_member(new cpp_developer("Dave"));
   pm.add_team_member(new database_admin("Edith"));
   print_team(&pm);

   cout << endl << "writing to " << file << endl;

   file_writer writer(file);
   ISerializer* ser = dynamic_cast<ISerializer*>(&writer);
   ser->write_worker(&pm);
   writer.close();
}
Ejemplo n.º 13
0
 void BlockIndex::serialize(ISerializer& s) {
   if (s.type() == ISerializer::INPUT) {
     readSequence<Crypto::Hash>(std::back_inserter(m_container), "index", s);
   } else {
     writeSequence<Crypto::Hash>(m_container.begin(), m_container.end(), "index", s);
   }
 }
void serialize(Transaction& tx, ISerializer& serializer) {
  serialize(static_cast<TransactionPrefix&>(tx), serializer);

  size_t sigSize = tx.inputs.size();
  //TODO: make arrays without sizes
//  serializer.beginArray(sigSize, "signatures");

  // ignore base transaction
  if (serializer.type() == ISerializer::INPUT && !(sigSize == 1 && tx.inputs[0].type() == typeid(BaseInput))) {
    tx.signatures.resize(sigSize);
  }

  bool signaturesNotExpected = tx.signatures.empty();
  if (!signaturesNotExpected && tx.inputs.size() != tx.signatures.size()) {
    throw std::runtime_error("Serialization error: unexpected signatures size");
  }

  for (size_t i = 0; i < tx.inputs.size(); ++i) {
    size_t signatureSize = getSignaturesCount(tx.inputs[i]);
    if (signaturesNotExpected) {
      if (signatureSize == 0) {
        continue;
      } else {
        throw std::runtime_error("Serialization error: signatures are not expected");
      }
    }

    if (serializer.type() == ISerializer::OUTPUT) {
      if (signatureSize != tx.signatures[i].size()) {
        throw std::runtime_error("Serialization error: unexpected signatures size");
      }

      for (Crypto::Signature& sig : tx.signatures[i]) {
        serializePod(sig, "", serializer);
      }

    } else {
      std::vector<Crypto::Signature> signatures(signatureSize);
      for (Crypto::Signature& sig : signatures) {
        serializePod(sig, "", serializer);
      }

      tx.signatures[i] = std::move(signatures);
    }
  }
//  serializer.endArray();
}
Ejemplo n.º 15
0
	void serialize(ISerializer& serializer) override
	{
		serializer.write("count", m_prefabs.size());

		for (PrefabResource* res : m_resources)
		{
			serializer.write("resource", res->getPath().c_str());
		}
		serializer.write("resource", "");

		for (int i = 0; i < m_instances.size(); ++i)
		{
			u64 prefab = m_instances.getKey(i);
			if ((prefab & 0xffffFFFF) != prefab) continue;
			Entity entity = m_instances.at(i);
			while(entity.isValid())
			{
				serializer.write("prefab", (u32)prefab);
				serializer.write("pos", m_universe->getPosition(entity));
				serializer.write("rot", m_universe->getRotation(entity));
				serializer.write("scale", m_universe->getScale(entity));
				entity = m_prefabs[entity.index].next;
			}
		}
		serializer.write("prefab", (u32)0);
	}
Ejemplo n.º 16
0
bool IObjectMapPropertyType<KeyType, ValueType>::DoSerialize(
	BidirectionalSerializer &bidi, KeyType &key, ValueType &value)
{
	bool result = true;
	ISerializer *serializer = bidi.Serializer();

	Command item(Command::EITEM);

	Command attribute(Command::EATTRIBUTE, "key");

	if(false == serializer->BeginCommand(item))
		result = false;
	if(false == serializer->BeginCommand(attribute))
		result = false;

	serializer->Hint( "map_key" );
	bidi | key;
	if(false == serializer->EndCommand(attribute))
		result = false;
		
	serializer->Hint( "map_value" );
	bidi | value;
	if(false == serializer->EndCommand(item))
		result = false;

	if(false == result)
		bidi.Fail();

	return bidi.Succeeded();
}
	virtual void Serialize(ISerializer& serialize)
	{
		// Because this is just graphical effects, and because it's all non-deterministic floating point,
		// we don't do much serialization here.
		// (That means projectiles will vanish if you save/load - is that okay?)
		
		// The attack code stores the id so that the projectile gets deleted when it hits the target
		serialize.NumberU32_Unbounded("next id", m_NextId);
	}
Ejemplo n.º 18
0
const char *DoSerializeEnum(int value, EnumNameMap *enum_map, BidirectionalSerializer &bidi)
{
	ISerializer *pser = bidi.Serializer();

	pser->Hint( "EnumMap", reinterpret_cast<intptr_t>(enum_map) );

	for(int i = 0; enum_map[i].name; i++)
	{
		if(value == enum_map[i].value)
		{
			return enum_map[i].name;
		}
	}

	bidi.Fail();

	return "<<BAD_ENUM>>";
}
Ejemplo n.º 19
0
bool serialize(boost::multi_index_container<T, Indexes>& value, Common::StringView name, ISerializer& s) {
    if (s.type() == ISerializer::INPUT) {
        readSequence<T>(std::inserter(value, value.end()), name, s);
    } else {
        writeSequence<T>(value.begin(), value.end(), name, s);
    }

    return true;
}
Ejemplo n.º 20
0
	virtual void Serialize(ISerializer& serialize)
	{
		serialize.Bool("in world", m_InWorld);
		if (m_InWorld)
		{
			serialize.NumberFixed_Unbounded("x", m_X);
			serialize.NumberFixed_Unbounded("z", m_Z);
			serialize.NumberFixed_Unbounded("last x", m_LastX);
			serialize.NumberFixed_Unbounded("last z", m_LastZ);
		}
		serialize.NumberFixed_Unbounded("rot x", m_RotX);
		serialize.NumberFixed_Unbounded("rot y", m_RotY);
		serialize.NumberFixed_Unbounded("rot z", m_RotZ);
		serialize.NumberFixed_Unbounded("altitude", m_YOffset);
		serialize.Bool("relative", m_RelativeToGround);

		if (serialize.IsDebug())
		{
			const char* anchor = "???";
			switch (m_AnchorType)
			{
			case PITCH: 
				anchor = "pitch"; 
				break;

			case PITCH_ROLL: 
				anchor = "pitch-roll"; 
				break;
			
			case ROLL:
				anchor = "roll";
				break;

			case UPRIGHT: // upright is the default
			default: 
				anchor = "upright"; 
				break;
			}
			serialize.StringASCII("anchor", anchor, 0, 16);
			serialize.Bool("floating", m_Floating);
		}
	}
Ejemplo n.º 21
0
void serializeBlockHeader(BlockHeader& header, ISerializer& serializer) {
  serializer(header.majorVersion, "major_version");
  if (header.majorVersion > BLOCK_MAJOR_VERSION_1) {
    throw std::runtime_error("Wrong major version");
  }

  serializer(header.minorVersion, "minor_version");
  serializer(header.timestamp, "timestamp");
  serializer(header.previousBlockHash, "prev_id");
  serializer.binary(&header.nonce, sizeof(header.nonce), "nonce");
}
void serialize(TransactionPrefix& txP, ISerializer& serializer) {
  serializer(txP.version, "version");

  if (CURRENT_TRANSACTION_VERSION < txP.version && serializer.type() == ISerializer::INPUT) {
    throw std::runtime_error("Wrong transaction version");
  }

  serializer(txP.unlockTime, "unlock_time");
  serializer(txP.inputs, "vin");
  serializer(txP.outputs, "vout");
  serializeAsBinary(txP.extra, "extra", serializer);
}
Ejemplo n.º 23
0
	virtual void Serialize(ISerializer& serialize)
	{
		// TODO: store the actor name, if !debug and it differs from the template

		if (serialize.IsDebug())
		{
			serialize.String("actor", m_ActorName, 0, 256);
		}

		// TODO: store random variation. This ought to be synchronised across saved games
		// and networks, so everyone sees the same thing. Saving the list of selection strings
		// would be awfully inefficient, so actors should be changed to (by default) represent
		// variations with a 16-bit RNG seed (selected randomly when creating new units, or
		// when someone hits the "randomise" button in the map editor), only overridden with
		// a list of strings if it really needs to be a specific variation.

		// TODO: store animation state

		serialize.NumberFixed_Unbounded("r", m_R);
		serialize.NumberFixed_Unbounded("g", m_G);
		serialize.NumberFixed_Unbounded("b", m_B);
	}
Ejemplo n.º 24
0
void CComponentTypeScript::Serialize(ISerializer& serialize)
{
	// If the component set Serialize = null, then do no work here
	if (m_HasNullSerialize)
		return;
	
	JSContext* cx = m_ScriptInterface.GetContext();
	JSAutoRequest rq(cx);

	// Support a custom "Serialize" function, which returns a new object that will be
	// serialized instead of the component itself
	if (m_HasCustomSerialize)
	{
		JS::RootedValue val(cx);
		if (!m_ScriptInterface.CallFunction(m_Instance, "Serialize", &val))
			LOGERROR("Script Serialize call failed");
		serialize.ScriptVal("object", &val);
	}
	else
	{
		serialize.ScriptVal("object", &m_Instance);
	}
}
Ejemplo n.º 25
0
    virtual void Serialize(ISerializer& serialize)
    {
        size_t count = 0;

        for (std::map<entity_id_t, std::string>::const_iterator it = m_LatestTemplates.begin(); it != m_LatestTemplates.end(); ++it)
        {
            if (ENTITY_IS_LOCAL(it->first))
                continue;
            ++count;
        }
        serialize.NumberU32_Unbounded("num entities", (u32)count);

        for (std::map<entity_id_t, std::string>::const_iterator it = m_LatestTemplates.begin(); it != m_LatestTemplates.end(); ++it)
        {
            if (ENTITY_IS_LOCAL(it->first))
                continue;
            serialize.NumberU32_Unbounded("id", it->first);
            serialize.StringASCII("template", it->second, 0, 256);
        }
        // TODO: maybe we should do some kind of interning thing instead of printing so many strings?

        // TODO: will need to serialize techs too, because we need to be giving out
        // template data before other components (like the tech components) have been deserialized
    }
void serialize(TransactionExtraMergeMiningTag& tag, ISerializer& serializer) {
  if (serializer.type() == ISerializer::OUTPUT) {
    std::string field;
    StringOutputStream os(field);
    BinaryOutputStreamSerializer output(os);
    doSerialize(tag, output);
    serializer(field, "");
  } else {
    std::string field;
    serializer(field, "");
    MemoryInputStream stream(field.data(), field.size());
    BinaryInputStreamSerializer input(stream);
    doSerialize(tag, input);
  }
}
Ejemplo n.º 27
0
void serializeBlockHeight(ISerializer& s, uint32_t& blockHeight, Common::StringView name) {
  if (s.type() == ISerializer::INPUT) {
    uint64_t height;
    s(height, name);

    if (height == std::numeric_limits<uint64_t>::max()) {
      blockHeight = std::numeric_limits<uint32_t>::max();
    } else if (height > std::numeric_limits<uint32_t>::max() && height < std::numeric_limits<uint64_t>::max()) {
      throw std::runtime_error("Deserialization error: wrong value");
    } else {
      blockHeight = static_cast<uint32_t>(height);
    }
  } else {
    s(blockHeight, name);
  }
}
void RPURU::saveRedoData(ISerializer& serializer, const ReflectedMethodUndoRedoHelper& helper)
{
	const char* methodHeaderTag = RPURU::getMethodHeaderTag();
	serializer.serialize(methodHeaderTag);
	serializer.serialize(helper.objectId_.toString());
	serializer.serialize(helper.path_);
	serializer.serialize(helper.parameters_.size());

	for (auto itr = helper.parameters_.cbegin(); itr != helper.parameters_.cend(); ++itr)
	{
		serializer.serialize(*itr);
	}

	serializer.serialize(helper.result_);
}
Ejemplo n.º 29
0
//==============================================================================
bool ContextDefinitionManager::deserializeDefinitions(ISerializer& serializer)
{
	// load generic definitions
	size_t count = 0;
	serializer.deserialize(count);
	for (size_t i = 0; i < count; i++)
	{
		std::string defName;
		serializer.deserialize(defName);

		std::string parentDefName;
		serializer.deserialize(parentDefName);
		auto pDef = getDefinition(defName.c_str());
		IClassDefinitionModifier* modifier = nullptr;
		if (!pDef)
		{
			auto definition = registerDefinition(createGenericDefinition(defName.c_str()));
			modifier = definition->getDetails().getDefinitionModifier();
		}

		size_t size = 0;
		serializer.deserialize(size);
		std::string propName;
		std::string typeName;
		uint32_t flags;
		for (size_t j = 0; j < size; j++)
		{
			propName.clear();
			typeName.clear();
			serializer.deserialize(propName);
			serializer.deserialize(typeName);
			serializer.deserialize(flags);
			IBasePropertyPtr property = nullptr;
			auto metaType = MetaType::find(typeName.c_str());
			if (modifier)
			{
				bool isCollection = flags & ContextDefinitionManagerDetails::IS_COLLECTION;
				auto property = modifier->addProperty(
				propName.c_str(), metaType != nullptr ? metaType->typeId().getName() : typeName.c_str(), nullptr,
				isCollection);
				// TF_ASSERT( property );
			}
		}
	}
	return true;
}
Ejemplo n.º 30
0
	virtual void Serialize(ISerializer& serialize)
	{
		serialize.Bool("in world", m_InWorld);
		if (m_InWorld)
		{
			serialize.NumberFixed_Unbounded("x", m_X);
			serialize.NumberFixed_Unbounded("y", m_Y);
			serialize.NumberFixed_Unbounded("z", m_Z);
			serialize.NumberFixed_Unbounded("last x", m_LastX);
			serialize.NumberFixed_Unbounded("last y diff", m_LastYDifference);
			serialize.NumberFixed_Unbounded("last z", m_LastZ);
		}
		serialize.NumberI32_Unbounded("territory", m_Territory);
		serialize.NumberFixed_Unbounded("rot x", m_RotX);
		serialize.NumberFixed_Unbounded("rot y", m_RotY);
		serialize.NumberFixed_Unbounded("rot z", m_RotZ);
		serialize.NumberFixed_Unbounded("altitude", m_Y);
		serialize.Bool("relative", m_RelativeToGround);
		serialize.Bool("floating", m_Floating);
		serialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress);

		if (serialize.IsDebug())
		{
			const char* anchor = "???";
			switch (m_AnchorType)
			{
			case PITCH:
				anchor = "pitch";
				break;

			case PITCH_ROLL:
				anchor = "pitch-roll";
				break;

			case ROLL:
				anchor = "roll";
				break;

			case UPRIGHT: // upright is the default
			default:
				anchor = "upright";
				break;
			}
			serialize.StringASCII("anchor", anchor, 0, 16);
		}
		serialize.NumberU32_Unbounded("turret parent", m_TurretParent);
		if (m_TurretParent != INVALID_ENTITY)
		{
			serialize.NumberFixed_Unbounded("x", m_TurretPosition.X);
			serialize.NumberFixed_Unbounded("y", m_TurretPosition.Y);
			serialize.NumberFixed_Unbounded("z", m_TurretPosition.Z);
		}
	}