/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool PositionTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 18, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Position positionOut(12, 4, 2); positionOut.SetVibrato(); positionOut.SetVolumeSwell(Dynamic::off, Dynamic::mp, 1); positionOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Position positionIn; positionIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((positionIn == positionOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests Serialization /// @return True if all tests were executed, false if not bool FontSettingTestSuite::TestCaseSerialize() { //------Last Checked------// // - Dec 6, 2004 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream FontSetting fontSettingOut(wxT("Arial"), 12, FontSetting::weightBold, true, true, true, wxColor(255,0,0)); fontSettingOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream FontSetting fontSettingIn; fontSettingIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((fontSettingIn == fontSettingOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests the Serialization Fucntions /// @return True if all tests were executed, false if not bool DirectionTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 11, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Direction directionOut(12, Direction::toCoda, Direction::activeDaCapo, 4); directionOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Direction directionIn; directionIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((directionIn == directionOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool AlternateEndingTestSuite::TestCaseSerialize() { //------Last Checked------// // - Dec 4, 2004 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream AlternateEnding alternateEndingOut(1, 2, testNumbers); alternateEndingOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream AlternateEnding alternateEndingIn; alternateEndingIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((alternateEndingIn == alternateEndingOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 4, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Barline barlineOut(12, Barline::repeatEnd, 12); barlineOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Barline barlineIn; barlineIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((barlineIn == barlineOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
void ExifShellExtension::PasteExifFromClipboard() { Win32::Clipboard cb(GetActiveWindow()); if (cb.IsFormatAvail(m_uiExifClipboardFormat)) { std::vector<BYTE> vecData; cb.GetData(m_uiExifClipboardFormat, vecData); CString cszOutputFilename = m_cszFilename + _T(".exifshellext-rename"); // rewrite jpeg file using new exif data { Stream::FileStream streamIn(m_cszFilename, Stream::FileStream::modeOpen, Stream::FileStream::accessRead, Stream::FileStream::shareRead); Stream::FileStream streamOut(cszOutputFilename, Stream::FileStream::modeCreateNew, Stream::FileStream::accessWrite, Stream::FileStream::shareRead); ExifRewriter rewriter(streamIn, streamOut, vecData); rewriter.Start(); } // TODO now set old file date/time // rename ::DeleteFile(m_cszFilename); ::MoveFile(cszOutputFilename, m_cszFilename); } }
/// Tests Serialization /// @return True if all tests were executed, false if not bool KeySignatureTestSuite::TestCaseSerialize() { //------Last Checked------// // - Dec 10, 2004 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream KeySignature keySignatureOut(KeySignature::minorKey, KeySignature::threeFlats); keySignatureOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream KeySignature keySignatureIn; keySignatureIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((keySignatureIn == keySignatureOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests Serialization /// @return True if all tests were executed, false if not bool GuitarTestSuite::TestCaseSerialize() { //------Last Checked------// // - Dec 8, 2004 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Guitar guitarOut(1, wxT("Test"), 2, 3, 4, 5, 6, 7, 8, 9); guitarOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Guitar guitarIn; guitarIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((guitarIn == guitarOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
inline T from_string(const std::string& string) { std::istringstream streamIn(string); T value; streamIn >> value; return value; }
bool Workspace::ImportSketch(Project * project, QString sketchFullPath) { QString name = QFileInfo(sketchFullPath).fileName(); QString path = QFileInfo(sketchFullPath).absolutePath(); // Copy main sketch file to project source folder, // adjusting the code as necessary QStringList importLibs; QFile file(sketchFullPath); file.open(QFile::ReadOnly | QFile::Text); QTextStream streamIn(&file); QString fileContent = streamIn.readAll(); file.close(); QStringList list = fileContent.split("\n"); for (int i=0; i<list.count(); i++) { if (list[i].indexOf("#include") >= 0) { QString text = list[i]; text.remove(0, text.indexOf("#include") + 8); text = text.trimmed(); text = text.remove(0, 1); //remove first quote or "<" int p = text.indexOf(".h"); if (p > 0) { text = text.left(p); importLibs.append(text); } } } fileContent = "#include \"mariamole_auto_generated.h\"\n" + fileContent; QFile outFile(config.workspace + "/" + project->name + "/source/" + project->name + ".cpp"); // main.cpp outFile.open(QFile::WriteOnly); QTextStream streamOut(&outFile); streamOut << fileContent; outFile.close(); ProjectFile pfile; pfile.name = project->name + ".cpp"; //"main.cpp"; pfile.open = false; pfile.type = ptSource; project->files.push_back(pfile); //CopyFileToProject(qApp->applicationDirPath() + "/templates/main.h", "main.h", project); CopyFileToProject(qApp->applicationDirPath() + "/templates/mariamole_auto_generated.h", "mariamole_auto_generated.h", project); ImportFilesFromSketchDirectory(project, path); for (int i=0; i < importLibs.count(); i++) { ImportLibrary(project, importLibs[i], ""); } return true; }
bool B9MatCat::load(QString sModelName) { clear(); m_Materials.clear(); m_sModelName = sModelName; QString sPath = QCoreApplication::applicationDirPath()+"/"+m_sModelName+".b9m"; QFile inFile(sPath); inFile.open(QIODevice::ReadOnly); if(!inFile.isOpen()) return false; QDataStream inStream(&inFile); streamIn(&inStream); return true; }
void ExifShellExtension::CopyExifToClipboard() { Stream::FileStream streamIn(m_cszFilename, Stream::FileStream::modeOpen, Stream::FileStream::accessRead, Stream::FileStream::shareRead); ExifReader reader(streamIn); reader.Start(); const std::vector<BYTE>& vecData = reader.GetData(); Win32::Clipboard cb(GetActiveWindow()); cb.Clear(); cb.SetData(m_uiExifClipboardFormat, &vecData[0], static_cast<UINT>(vecData.size())); // TODO parse Exif and also put CF_TEXT infos on clipboard }
ArgProcessor::ArgProcessor(QObject *parent) : QObject(parent) { QTextStream streamOut(stdout); QTextStream streamIn(stdin); #ifdef Q_OS_WIN QString defaultPort_ = "COM3"; #elif defined(Q_OS_MAC) QString defaultPort_ = "/dev/tty.usbmodem261"; #else QString defaultPort_ = "/dev/ttyACM0"; #endif streamOut << "Port (default is " + defaultPort_ + "): "; streamOut.flush(); mPort = streamIn.readLine(); if(mPort.isEmpty()) { mPort = defaultPort_; } streamOut << "Camera index (default is 0): "; streamOut.flush(); mCamera = streamIn.readLine().toInt(); streamOut << "Camera width (default is 1280): "; streamOut.flush(); mWidth = streamIn.readLine().toInt(); if(mWidth == 0) { mWidth = 1280; } streamOut << "Camera height (default is 720): "; streamOut.flush(); mHeight = streamIn.readLine().toInt(); if(mHeight == 0) { mHeight = 720; } streamOut << "Camera fps (default is 25.0): "; streamOut.flush(); mFps = streamIn.readLine().toInt(); if(mFps == 0) { mFps = 25.0; } }
/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool ScoreTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 6, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Score scoreOut; wxUint32 i = 0; for (; i < 3; i++) { scoreOut.m_guitarArray.Add(new Guitar); scoreOut.m_chordDiagramArray.Add(new ChordDiagram); scoreOut.m_floatingTextArray.Add(new FloatingText); scoreOut.m_guitarInArray.Add(new GuitarIn); scoreOut.m_tempoMarkerArray.Add(new TempoMarker); scoreOut.m_dynamicArray.Add(new Dynamic); scoreOut.m_alternateEndingArray.Add(new AlternateEnding); scoreOut.m_systemArray.Add(new System); } scoreOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Score scoreIn; scoreIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((scoreIn == scoreOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 5, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Staff staffOut(4, Staff::BASS_CLEF); wxUint32 i = 0; for (; i < 3; i++) { staffOut.m_positionArray[0].Add(new Position); staffOut.m_positionArray[1].Add(new Position); } staffOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Staff staffIn; staffIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((staffIn == staffOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
/// Tests the Serialization Fucntions /// @return True if all tests were executed, false if not bool ChordDiagramTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 15, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); ChordName chordName; chordName.SetFormula(ChordName::minor); // Write test data to stream ChordDiagram chordDiagramOut(chordName, 3, 3, 4, 5, 5, 3, ChordDiagram::stringMuted); chordDiagramOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream ChordDiagram chordDiagramIn; chordDiagramIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((chordDiagramIn == chordDiagramOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
bool Processor::setTransformsChain(const QString &xmlConf) { QXmlStreamReader streamIn(xmlConf); return setTransformsChain(transformFactory->loadConfFromXML(&streamIn)); }
int main(int argc, char** argv) { ros::init(argc, argv, "fmRemoteNode"); ros::NodeHandle nh; ros::NodeHandle n("~"); int baudRate; std::string device; ros::Publisher tele_pub = nh.advertise<fmMsgs::airframeControl>("/radioData", 1); n.param<int> ("baudrate", baudRate, 115200); n.param<std::string> ("device", device, "/dev/ttyUSB0"); int fd = ttySetup(baudRate, device.c_str()); uint8_t buf[512]; char num[9]; uint32_t msg_type; uint32_t msg_size; uint8_t msg_chksum; // while (ros::ok()) { while (ros::ok()) { uint32_t len = unslip_pkg(fd, buf, 512); // Only returns when package is received... if (len < 8) { printf("Package to small (len = %i) - skipping\n", len); continue; } memcpy(num, buf, 8); // First 8 bytes contain ascii hex descritions of msg_type and msg_size num[8] = 0x0A; // Insert \n sscanf(num, "%04X%04X", &msg_type, &msg_size); // Extract msg_type and msg_size if (msg_size != len - 10) { printf("Package size does not match description: %i (expected %i)\n", len, msg_size + 10); continue; } memcpy(num, &(buf[8 + msg_size]), 2); num[2] = 0x0A; sscanf(num, "%02X", (uint32_t*) &msg_chksum); uint8_t calc_chksum = 0; for (uint32_t i = 0; i < len - 2; i++) calc_chksum += buf[i]; if (msg_chksum != calc_chksum) { printf("Wrong checksum : %i != %i - 10\n", msg_chksum, calc_chksum); continue; } fmMsgs::airframeControl msg_in; boost::shared_array<uint8_t> bufIn(new uint8_t[msg_size]); ros::serialization::IStream streamIn(bufIn.get(), msg_size); memcpy(bufIn.get(), buf + 8, msg_size); switch(msg_type) { case 0x1000: ros::serialization::deserialize(streamIn, msg_in); tele_pub.publish(msg_in); break; default: printf("Unknown message type...\n"); } // } // tcflush(fd, TCIFLUSH); /* Clean the tty line*/ } }