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()); } }
void TemplateParameterNode::Write(Writer& writer) { writer.Write(id.get()); bool hasDefaultTemplateArgument = defaultTemplateArgument != nullptr; writer.Write(hasDefaultTemplateArgument); if (hasDefaultTemplateArgument) { writer.Write(defaultTemplateArgument.get()); } }
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()); } }
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(); }
int main(int argc, char* argv[]) { String name, outputPath; if (argc < 2) { std::cout << "Invalid arguments" << std::endl; std::cout << std::endl; std::cout << "Usage: SPMBuild input_file [output_filename]" << std::endl; return -1; } String path = argv[1]; auto split = SplitString(path, "/\\"); name = split.back(); if (argc > 2) { outputPath = argv[2]; } else { outputPath = name.substr(0, name.size() - 4) + ".spm"; std::cout << "Output path not specified. Outputting to " << outputPath << std::endl; } Mesh* mesh = new Mesh(); mesh->LoadMesh(path); Writer* writer = new Writer(name, POSITION | NORMAL | UV | BINORMAL | TANGENT | JOINTWEIGHT | JOINTINDEX, mesh->m_Entries, mesh->m_BoneInfo); writer->Write(outputPath); return 0; }
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); }
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)); }
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); }
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()); }
void CrossRoutingContextWriter::Save(Writer & w) const { uint32_t size = static_cast<uint32_t>(m_ingoingNodes.size()); w.Write(&size, sizeof(size)); for (auto const & node : m_ingoingNodes) node.Save(w); size = static_cast<uint32_t>(m_outgoingNodes.size()); w.Write(&size, sizeof(size)); for (auto const & node : m_outgoingNodes) node.Save(w); CHECK(m_adjacencyMatrix.size() == m_outgoingNodes.size() * m_ingoingNodes.size(), ()); w.Write(&m_adjacencyMatrix[0], sizeof(m_adjacencyMatrix[0]) * m_adjacencyMatrix.size()); size = static_cast<uint32_t>(m_neighborMwmList.size()); w.Write(&size, sizeof(size)); for (string const & neighbor : m_neighborMwmList) { size = static_cast<uint32_t>(neighbor.size()); w.Write(&size, sizeof(size)); w.Write(neighbor.c_str(), neighbor.size()); } }
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; }
void TypedefNode::Write(Writer& writer) { writer.Write(specifiers); writer.Write(typeExpr.get()); writer.Write(id.get()); }
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; }
void CompileUnitNode::Write(Writer& writer) { writer.Write(filePath); writer.Write(globalNs.get()); }
void TemplateIdNode::Write(Writer& writer) { writer.Write(subject.get()); templateArguments.Write(writer); }
void FunctionGroupIdNode::Write(Writer& writer) { writer.Write(functionGroupId); }