本文整理汇总了C++中Writer::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ Writer::Write方法的具体用法?C++ Writer::Write怎么用?C++ Writer::Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Writer
的用法示例。
在下文中一共展示了Writer::Write方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Write
void TemplateParameterNodeList::Write(Writer& writer)
{
uint32_t n = static_cast<uint32_t>(templateParameterNodes.size());
writer.Write(n);
for (uint32_t i = 0; i < n; ++i)
{
writer.Write(templateParameterNodes[i].get());
}
}
示例2: Write
void FunctionNode::Write(Writer& writer)
{
writer.Write(specifiers);
bool hasReturnTypeExpr = returnTypeExpr != nullptr;
writer.Write(hasReturnTypeExpr);
if (hasReturnTypeExpr)
{
writer.Write(returnTypeExpr.get());
}
writer.Write(groupId.get());
templateParameters.Write(writer);
parameters.Write(writer);
bool hasConstraint = constraint != nullptr;
writer.Write(hasConstraint);
if (hasConstraint)
{
writer.Write(constraint.get());
}
bool hasBody = body != nullptr;
writer.Write(hasBody);
if (hasBody)
{
writer.Write(body.get());
}
}
示例3: main
int main(void) {
char data = ' ';
int id = 0;
cout << "pid: " << getpid() << endl;
cout << "digite id do reader: ";
cin >> id;
cout << "id = " << id << endl;
Writer *wr = new Writer(id);
signal(SIGCONT, sigusr);
kill(id, SIGCONT);
while (data != '.') {
cout << "digite o char: ";
cin >> data;
wr->Write(data);
}
wr->~Writer();
}
示例4: WriteVersion
void WriteVersion(Writer & w, uint64_t secondsSinceEpoch)
{
w.Write(MWM_PROLOG, ARRAY_SIZE(MWM_PROLOG));
// write inner data version
WriteVarUint(w, static_cast<uint32_t>(Format::lastFormat));
WriteVarUint(w, secondsSinceEpoch);
}
示例5: Save
void IngoingCrossNode::Save(Writer & w) const
{
uint64_t point = PointToInt64(m2::PointD(m_point.lon, m_point.lat), kCoordBits);
char buff[sizeof(m_nodeId) + sizeof(point)];
*reinterpret_cast<decltype(m_nodeId) *>(&buff[0]) = m_nodeId;
*reinterpret_cast<decltype(point) *>(&(buff[sizeof(m_nodeId)])) = point;
w.Write(buff, sizeof(buff));
}
示例6: WriteVersion
void WriteVersion(Writer & w, uint32_t versionDate)
{
w.Write(MWM_PROLOG, ARRAY_SIZE(MWM_PROLOG));
// write inner data version
WriteVarUint(w, static_cast<uint32_t>(lastFormat));
WriteVarUint(w, versionDate);
}
示例7: TestReadStruct
void TestReadStruct(Writer& output, Buffer& output_buffer, uint16_t val0, int64_t val1)
{
output.WriteStructBegin(bond::Metadata(), false);
output.WriteFieldBegin(bond::BT_UINT16, 0);
output.Write(val0);
output.WriteFieldEnd();
output.WriteFieldBegin(bond::BT_INT64, 1);
output.Write(val1);
output.WriteFieldEnd();
output.WriteStructEnd();
// read from output, using CB version 2
typename Reader::Buffer input_buffer(output_buffer.GetBuffer());
Reader input(input_buffer, 2);
uint16_t id;
bond::BondDataType type;
uint16_t value0;
int64_t value1;
input.ReadStructBegin();
input.ReadFieldBegin(type, id);
input.Read(value0);
input.ReadFieldEnd();
UT_AssertAreEqual(type, bond::BT_UINT16);
UT_AssertAreEqual(id, 0);
UT_AssertAreEqual(val0, value0);
input.ReadFieldBegin(type, id);
input.Read(value1);
input.ReadFieldEnd();
input.ReadStructEnd();
UT_AssertAreEqual(type, bond::BT_INT64);
UT_AssertAreEqual(id, 1);
UT_AssertAreEqual(val1, value1);
// test skipping struct, using CB version 2
typename Reader::Buffer input_buffer2(output_buffer.GetBuffer());
Reader input2(input_buffer2, 2);
input2.Skip(bond::BT_STRUCT);
UT_AssertIsTrue(input2.GetBuffer().IsEof());
}
示例8: main
int main(int argc, char* argv[]) {
Reader *x = new Reader("text_src");
Writer *y = new Writer("text_dest");
if (!x->IsOpened() && !y->IsOpened()) {
std::cout << "Could not open file\n";
return 1;
}
std::vector<uchar> *block = new std::vector<uchar>;
int i = 0;
while (!x->IsLastBlock()){
i++;
block->clear();
x->Read(block);
y->Write(*block);
}
x->~Reader();
y->~Writer();
return 0;
}
示例9: Write
void TypedefNode::Write(Writer& writer)
{
writer.Write(specifiers);
writer.Write(typeExpr.get());
writer.Write(id.get());
}
示例10: main
int main ()
{
ifstream infile; //stream to read from txt file
ofstream toBin; //stream to write to the binary file
ifstream fromBin; //stream to read from the binary file
STATE reader = NOT_READY; //program status bit
vector < int > values ( 1 ); //vector containing uncompressed digits
vector < unsigned short int > bin ( 1 ); //vector containing bit packed digits
vector < int > format ( 2 ); //vector containing formatting data
int data_set = 1; //counter for how many data sets have been processed
Reader read; //set up of reader class object to pull data from txt file
Packer pack; //set up of packer class that will perform bit packing / unpacking
Writer write; //set up of writer class that will read / write binary file
try //enclosed in a try block to catch any unexpected errors
{
reader = read.open(infile); //open the file. File name is coded into the funciton
while (reader != FILE_END) //while loop will ensure that it will continue until all data sets are processed
{
reader = read.process(infile, values); //first set of data is read from the file and stored in the values array
if (reader == SET_END || reader == FILE_END) //main body of main will only be processed if a data set was read successfully
{
format.resize ( read.getPer_set() + 1); //prepare format array to hold the formatting data
format[0] = read.getPer_set(); //first slot of the format array is the number of digits in each set to be encoded
for(int i = 0; i < format[0] ; ++i) //the remaining slots are how may bits each digit will be packed into
format[ i + 1 ] = read.getBits_per(i);
cout << "\n\nDisplay input for data set " << data_set << ":\n"; //display the data pulled from the file
read.display(values);
pack.compress(values, format, bin); //perform bit packing and save in the bin array
cout << "\nDisplay binary file input:\n"; //display bit packed data
read.display(bin);
write.Write(bin, toBin); //write the binary data to the file
write.Read(bin, fromBin); //read the binary data from the file and store in the bin array
cout << "\nDisplay binary file output:\n"; //display bit packed data as it was read from the file
read.display(bin);
pack.decompress(values, bin); //unpack the digits and store in the values array
cout << "\nDisplay data read from file:\n"; //display the unpacked digits
read.display(values);
cout << "\n\nEnd of data set " << data_set << endl << endl; //show end of data set
++data_set; //incriment data set counter
}
}
}
catch (exception & error) //catch any error thrown by program, display .what string
{
cout << error.what();
}
infile.close(); //close the stream from the .txt file. toBin and fromBin are opened and closed within the function using them
cout << "\nProgram Ending\n\n\n"; //end program
cout << "Press Enter key to end -->";
cin.ignore(80, '\n');
cout << endl;
return 0;
}
示例11: Write
void CompileUnitNode::Write(Writer& writer)
{
writer.Write(filePath);
writer.Write(globalNs.get());
}