int BitMatrixParser::readCorner4(int numRows, int numColumns) { int currentByte = 0; if (readModule(numRows - 3, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRows - 2, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRows - 1, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(0, numColumns - 2, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(0, numColumns - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(1, numColumns - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(2, numColumns - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(3, numColumns - 1, numRows, numColumns)) { currentByte |= 1; } return currentByte; }
int BitMatrixParser::readUtah(int row, int column, int numRows, int numColumns) { int currentByte = 0; if (readModule(row - 2, column - 2, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row - 2, column - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row - 1, column - 2, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row - 1, column - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row - 1, column, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row, column - 2, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row, column - 1, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(row, column, numRows, numColumns)) { currentByte |= 1; } return currentByte; }
void Bank::createFromXml( istringstream& is, Program& program ) { Document doc; try { doc.Parse( is.str(), true ); Node* root = &doc; Node* programNode = doc.FirstChild( "Program", false ); if( programNode != NULL ) { root = programNode; } Iterator< Element > it( "Module" ); for( it = it.begin( root ); it != it.end(); it++ ) { ModuleData* data = new ModuleData(); Element* moduleElement = it.Get(); readModule( moduleElement, data ); program.addModule( data ); } } catch( const exception& e ) { TRACE( e.what() ); } }
void Bank::readProgram( Element* element, Program* program ) { program->name_ = element->GetAttribute( "name" ); program->category_ = element->GetAttribute( "category" ); program->comment_ = element->GetAttribute( "comment" ); element->GetAttribute( "voices", &program->numVoices_, false ); element->GetAttribute( "unison", &program->numUnison_, false ); element->GetAttribute( "sprd", &program->unisonSpread_, false ); element->GetAttribute( "hold", &program->hold_, false ); element->GetAttribute( "retrig", &program->retrigger_, false ); element->GetAttribute( "legato", &program->legato_, false ); Iterator< Element > it( "Module" ); for( it = it.begin( element ); it != it.end(); it++ ) { ModuleData* data = new ModuleData(); Element* moduleElement = it.Get(); readModule( moduleElement, data ); program->addModule( data ); } }
bool ModuleListInstance::readProjectFile(const QString& path) { clearData(); mFileSource = path; QFile srcFile(path); int stage = 0; if(srcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { while(!srcFile.atEnd()) { QString text = srcFile.readLine(); QString strippedText = text.simplified(); if(!strippedText.startsWith("//")) { if(text.contains("Torque3D::beginConfig(", Qt::CaseInsensitive)) { // We now check for modules and project defines. On to the next stage. stage = 1; } else if(text.contains("Torque3D::endConfig(", Qt::CaseInsensitive)) { // Done checking for modules and project defines. On to the next stage. stage = 2; } else if(stage == 0 && strippedText.startsWith("$")) { // Could be a move class variable or a module path. Start with // a move class. bool handled = readMoveClass(text); if(!handled) { // Not a move class so try a module path. readModulePath(text); } } else if(stage == 1 && text.contains("includeModule(")) { // Handle the module readModule(text); } else if(stage == 1 && text.contains("addProjectDefine(")) { // Handle the project define readProjectDefine(text); } } } srcFile.close(); } else { return false; } return true; }
/** * Read a node from a hat file. * * @param hatFile The file to read from - assumed to be open. * @param offset The offset to start reading in the hat file. * @return A node pointer to the node found in the hatFile at offset. */ node* readNode (FILE *hatFile, unsigned long offset) { int err; char b; node *newNode; // Find out which type of node we have. fseek (hatFile, offset, SEEK_SET); err = fread (&b, sizeof(char), 1, hatFile); if (err != 1) { return NULL; } else { int tag = lower5(b); if ((ExpDoStmt < tag && tag < AtomVariable) || tag > AtomAbstract) { fprintf (stderr, "strange tag %d at byte offset 0x%x\n", tag, offset); exit (1); } switch (tag) { case AtomAbstract: newNode = readAtomAbstract(hatFile, offset); break; case AtomConstructor: newNode = readAtomConstructor(hatFile, offset); break; case AtomVariable: newNode = readAtomVariable(hatFile, offset); break; case ExpApp: newNode = readExpApp(hatFile, offset); break; case ExpCase: newNode = readExpCase(hatFile, offset); break; case ExpChar: newNode = readExpChar(hatFile, offset); break; case ExpConstDef: newNode = readExpConstDef(hatFile, offset); break; case ExpConstUse: newNode = readExpConstUse(hatFile, offset); break; case ExpDouble: newNode = readExpDouble(hatFile, offset); break; case ExpDoStmt: newNode = readExpDoStmt(hatFile, offset); break; case ExpFieldUpdate: newNode = readExpFieldUpdate(hatFile, offset); break; case ExpFloat: newNode = readExpFloat(hatFile, offset); break; case ExpForward: newNode = readExpForward(hatFile, offset); break; case ExpGuard: newNode = readExpGuard(hatFile, offset); break; case ExpHidden: newNode = readExpHidden(hatFile, offset); break; case ExpIf: newNode = readExpIf(hatFile, offset); break; case ExpInt: newNode = readExpInt(hatFile, offset); break; case ExpInteger: newNode = readExpInteger(hatFile, offset); break; case ExpProjection: newNode = readExpProjection(hatFile, offset); break; case ExpRat: newNode = readExpRat(hatFile, offset); break; case ExpRational: newNode = readExpRational(hatFile, offset); break; case ExpValueApp: newNode = readExpValueApp(hatFile, offset); break; case ExpValueUse: newNode = readExpValueUse(hatFile, offset); break; case Module: newNode = readModule(hatFile, offset); break; case SrcPos: newNode = readSrcPos(hatFile, offset); break; } return newNode; } }