本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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");
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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
}
}
示例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();
}