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


C++ DataWriter类代码示例

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


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

示例1: write_samples

bool Solver::write_samples() {

    try {

        DataWriter dw;

        dw.writeAll(gyro::SAMPLE_FILE);

        cout << endl << "Samples are successfully written" << endl;

    }
    catch (ios_base::failure& ) {

        msg = "(ios_base::failure)";

        return FAILED;
    }
    catch (exception& e) {

        msg = string("(") + e.what() + string(")");

        return FAILED;
    }

    return SUCCESS;
}
开发者ID:szte-wsn,项目名称:szte-wsn,代码行数:26,代码来源:Solver.cpp

示例2: readOne

bool QueryReader::readOne(UInt8 type, DataWriter& writer) {
	
	const UInt8* cur = packet.current();
	const UInt8* end = cur+packet.available();
	if (type==OBJECT) {

		// OBJECT
		writer.beginObject();
		do {
			cur = packet.current();
			writer.writePropertyName(_property.c_str());
			writeValue(valueType(), writer);

			// next!
			while (cur<end && *cur != '&')
				cur++;
			packet.next(cur-packet.current() + (*cur=='&'));

			_type = END;
		} while (cur<end && (_type=followingType())==OBJECT);
		writer.endObject();
		return true;
	}

	writeValue(type, writer);

	// next!
	while (cur<end && *cur != '&')
		cur++;
	packet.next(cur-packet.current() + (*cur=='&'));
	_type = END;
	return true;
}
开发者ID:8088,项目名称:MonaServer,代码行数:33,代码来源:QueryReader.cpp

示例3: write

void GeodesicProvider::write(DataWriter &writer) const {
	writer.write(this->m_source_vertices);
	writer.write(this->m_target_vertices);
	writer.write(this->m_algorithm_option);
	writer.write(this->m_subdivision_level);
	writer.write(this->m_geodesics);
}
开发者ID:NagaoKagetora,项目名称:geometric-terminal,代码行数:7,代码来源:GeodesicProvider.cpp

示例4: write

void SamplingProvider::write(DataWriter &writer) const {
    writer.write(this->m_sampling_radius);
    writer.write(this->m_curvatures);
    writer.write(this->m_barycentric_areas);
    writer.write(this->m_geodesics);
    writer.write(this->m_samples);
}
开发者ID:NagaoKagetora,项目名称:geometric-terminal,代码行数:7,代码来源:SamplingProvider.cpp

示例5: saveMap

void Observer::saveMap(DataWriter& writer, const std::map<const PlayerId*, CardSet>& map){
    writer.write(static_cast<unsigned int>(map.size()));
    for (std::map<const decore::PlayerId*, decore::CardSet>::const_iterator it = map.begin(); it != map.end(); ++it) {
        writer.write(mPlayers.index(it->first));
        writer.write(it->second.begin(), it->second.end());
    }
}
开发者ID:na1x,项目名称:DeCore,代码行数:7,代码来源:observer.cpp

示例6: saveRoundData

void Observer::saveRoundData(DataWriter& writer, const RoundData& roundData){
    writer.write(static_cast<unsigned int>(roundData.mPlayers.size()));
    for(PlayerIds::const_iterator it = roundData.mPlayers.begin(); it != roundData.mPlayers.end(); ++it) {
        writer.write(mPlayers.index(*it));
    }
    saveMap(writer, roundData.mDroppedCards);
    saveMap(writer, roundData.mPickedUpCards);
}
开发者ID:na1x,项目名称:DeCore,代码行数:8,代码来源:observer.cpp

示例7: writeStruct

void Struct_CP_Table::writeStruct(DataWriter &data) const
{
    data.put16(constants.size(), "size");
    data.pad16();

    foreach (QSharedPointer<Struct_CP> cp, constants)
        data.putAddress(cp, "constant");
}
开发者ID:adjustive,项目名称:ucjvm-manager,代码行数:8,代码来源:Struct_CP_Table.cpp

示例8: gethostbyname

bool ClientSocket::connect(const char* host,const char* nick)
{
	hostent* serv = gethostbyname(host);
	if (!serv) {
		cout<<"gethostbyname failed\n";
		exit(16);
	}
	sockaddr_in addr;
	#ifdef WIN32
	int sockfd = socket(PF_INET, SOCK_STREAM, 0);
	#else
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);
	#endif
		#ifdef WIN32
	if (sockfd==INVALID_SOCKET) {
		cout<<"binding socket failed "<<WSAGetLastError()<<endl;
		exit(15);
	}
		#endif
	memset(&addr,0,sizeof(addr));
	addr.sin_family = AF_INET;
#ifdef WIN32
	addr.sin_addr.s_addr = ((struct in_addr *)(serv->h_addr))->s_addr;
//    memcpy(serv->h_addr, &addr.sin_addr.s_addr, serv->h_length);
#else
	bcopy(serv->h_addr, &addr.sin_addr.s_addr, serv->h_length);
#endif
	addr.sin_port = htons(SERVER_PORT);
	if (::connect(sockfd, (sockaddr*)&addr, sizeof(addr))<0) {
		perror("Connecting failed");
		#ifdef WIN32
		cout<<"connect error: "<<WSAGetLastError()<<'\n';
		#endif
		return 0;
	}
	#ifndef WIN32
	fcntl(sockfd, F_SETFL, O_NONBLOCK);
	#else
    unsigned long x=1;
    ioctlsocket(sockfd, FIONBIO, &x);
    char flag=1;
    if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag))<0) {
    	perror("setsockopt TCP_NODELAY");
    	exit(16);
    }
	#endif
	conn.fd = sockfd;

    DataWriter w;
    w.writeByte(CLI_NAME);
    char buf[33]={};
    strncpy(buf,nick,31);
    w.write(buf,32);
    conn.write(w);
	return 1;
}
开发者ID:sisu,项目名称:taisto2,代码行数:56,代码来源:ClientSocket.cpp

示例9: Save

void GameEvent::Save(DataWriter &out) const
{
	out.Write("event");
	out.BeginChild();
	{
		if(date)
			out.Write("date", date.Day(), date.Month(), date.Year());
		conditionsToApply.Save(out);
		
		for(const System *system : systemsToUnvisit)
			if(system && !system->Name().empty())
				out.Write("unvisit", system->Name());
		for(const Planet *planet : planetsToUnvisit)
			if(planet && !planet->Name().empty())
				out.Write("unvisit planet", planet->Name());
		
		for(const System *system : systemsToVisit)
			if(system && !system->Name().empty())
				out.Write("visit", system->Name());
		for(const Planet *planet : planetsToVisit)
			if(planet && !planet->Name().empty())
				out.Write("visit planet", planet->Name());
		
		for(const DataNode &change : changes)
			out.Write(change);
	}
	out.EndChild();
}
开发者ID:Disiuze,项目名称:endless-sky,代码行数:28,代码来源:GameEvent.cpp

示例10: Save

void Personality::Save(DataWriter &out) const
{
	out.Write("personality");
	out.BeginChild();
	{
		out.Write("confusion", confusionMultiplier);
		for(const auto &it : TOKEN)
			if(flags & it.second)
				out.Write(it.first);
	}
	out.EndChild();
}
开发者ID:kikotheexile,项目名称:endless-sky,代码行数:12,代码来源:Personality.cpp

示例11: Pos_ReadDirect

void LOADERDECL Pos_ReadDirect()
{
	static_assert(N <= 3, "N > 3 is not sane!");
	auto const scale = posScale;
	DataWriter dst;
	DataReader src;

	for (int i = 0; i < 3; ++i)
		dst.Write(i<N ? PosScale(src.Read<T>(), scale) : 0.f);

	LOG_VTX();
}
开发者ID:Puniasterus,项目名称:dolphin,代码行数:12,代码来源:VertexLoader_Position.cpp

示例12: TexCoord_ReadDirect

void LOADERDECL TexCoord_ReadDirect()
{
	auto const scale = tcScale[tcIndex];
	DataWriter dst;
	DataReader src;

	for (int i = 0; i != N; ++i)
		dst.Write(TCScale(src.Read<T>(), scale));

	LOG_TEX<N>();

	++tcIndex;
}
开发者ID:Asmodean-,项目名称:dolphin,代码行数:13,代码来源:VertexLoader_TextCoord.cpp

示例13: Save

void ConditionSet::Save(DataWriter &out) const
{
	for(const Entry &entry : entries)
		out.Write(entry.name, entry.op, entry.value);
	for(const ConditionSet &child : children)
	{
		out.Write(child.isOr ? "or" : "and");
		out.BeginChild();
		{
			child.Save(out);
		}
		out.EndChild();
	}
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:14,代码来源:ConditionSet.cpp

示例14: run

   virtual void run(const dds::domain::DomainParticipant& dp,
         const dds::topic::Topic<T>& topic,
         const Params& params)
   {
      dds::pub::qos::PublisherQos pqos =
            dp.default_publisher_qos() << Partition("ishapes");

      dds::pub::Publisher pub(dp, pqos);

      dds::pub::qos::DataWriterQos dwqos =
            pub.default_datawriter_qos() << Durability::Transient() << Reliability::Reliable();

      dds::pub::DataWriter<T> dw(pub, topic, dwqos);

      const uint32_t period = params.period;
      const uint32_t samples = params.samples;
      uint32_t sleep_time = period * 1000;

      srand(clock());
      const uint32_t x0 = 10;
      const uint32_t y0 = 10;
      const uint32_t r = 200;
      const uint32_t dx = 5;
      const uint32_t dy = 7;

      // AnyDataWriter work just fine...
      AnyDataWriter adw = dw;
      DataWriter<ShapeType> xdw = adw.get<ShapeType>();
      std::cout << "Topic Name = " << xdw.topic().name()
                      << "\tType Name = " << xdw.topic().type_name() << std::endl;

      // ShapeType s = {params.color, x0, y0, params.shape_size};
      ShapeType s = {params.color.c_str(), x0 , y0, params.shape_size};

      std::cout << ">> Writing Data...";
               std::flush(std::cout);
      for (uint32_t i = 0; i < samples; ++i) {
         // Regular write
         dw.write(s);

         // Stream write
         dw << s;

         s.x = (s.x + dx) % r;
         s.y = (s.y + dy) % r;

         exampleSleepMilliseconds(sleep_time); // period is in ms
      }
   }
开发者ID:S73417H,项目名称:opensplice,代码行数:49,代码来源:writer.hpp

示例15: Pos_ReadIndex

void LOADERDECL Pos_ReadIndex()
{
	static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
	static_assert(N <= 3, "N > 3 is not sane!");

	auto const index = DataRead<I>();
	auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * arraystrides[ARRAY_POSITION]));
	auto const scale = posScale;
	DataWriter dst;

	for (int i = 0; i < 3; ++i)
		dst.Write(i<N ? PosScale(Common::FromBigEndian(data[i]), scale) : 0.f);

	LOG_VTX();
}
开发者ID:Puniasterus,项目名称:dolphin,代码行数:15,代码来源:VertexLoader_Position.cpp


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