int lyrebird(char *inputFile, char *outputFile) { ll exponent = 1921821779; long modulus = 4294434817; FILE *fin = fopen(inputFile,"r"); FILE *fout = fopen(outputFile,"w"); if (fin == NULL) { exit(-1); } size_t len = 0; size_t read; char *line = NULL; while ((read = getline(&line, &len, fin)) != -1) { char *handle = readString(line); handleString(fout, handle,exponent,modulus); free(handle); } fclose(fin); fclose(fout); return 0; }
Console::Console(QString _name, CommandInterpreter *_interpreter) : stopping(false), name(_name), interpreter(_interpreter) { QObject::connect(this, SIGNAL(read(QString)), interpreter, SLOT(handleString(QString))); QObject::connect(interpreter, SIGNAL(write(QString)), this, SLOT(write(QString))); QObject::connect(interpreter, SIGNAL(writeAsync(QString)), this, SLOT(writeAsync(QString))); QObject::connect(interpreter, SIGNAL(exit()), this, SLOT(quit())); /** allow conditional parsing of the inputrc file */ rl_readline_name = name.toAscii(); /** tell the completer that we want a crack first. */ rl_console = this; rl_attempted_completion_function = &Console::ConsoleCompletion; rl_event_hook = poll; rl_catch_signals = 0; // rl_set_keyboard_input_timeout(100000); using_history(); historyFile = QDir::homePath() + QString("/.%1_history").arg(name); QFile file(historyFile); if (!file.exists()) { // create file file.open(QIODevice::ReadWrite); file.close(); } read_history(historyFile.toAscii().constData()); // rl_bind_key('\t', readline_completion); }
vector<Member*> MDSCHEMA_MEMBERS::getRestrictMembers(Restrictions &restrictions){ vector<Member*> members; string catalogn=""; string cuben=""; string dimensionn=""; string hien=""; string leveln=""; Restrictions::iterator catalognIt=restrictions.find(CATALOG_NAME); //有CATALOG_NAME约束 if(catalognIt!= restrictions.end()){ catalogn=catalognIt->second; //earse restrictions.erase(catalognIt); } Restrictions::iterator cubenIt=restrictions.find(CUBE_NAME); //有CUBE_NAME约束 if(cubenIt!=restrictions.end()){ cuben=cubenIt->second; restrictions.erase(cubenIt); } Restrictions::iterator dimensionnIt=restrictions.find(DIMENSION_UNIQUE_NAME); //有DIMENSION_NAME约束 if(dimensionnIt!=restrictions.end()){ dimensionn=dimensionnIt->second; restrictions.erase(dimensionnIt); } Restrictions::iterator hienIt=restrictions.find(HIERARCHY_UNIQUE_NAME); //有HIERARCHY_UNIQUE_NAME约束 if(hienIt!=restrictions.end()){ hien=hienIt->second; restrictions.erase(hienIt); } Restrictions::iterator levelnIt=restrictions.find(LEVEL_UNIQUE_NAME); //有LEVEL_UNIQUE_NAME约束 if(levelnIt!=restrictions.end()){ leveln=levelnIt->second; restrictions.erase(levelnIt); } handleString(hien); handleString(leveln); members=XSchemas::instance().getMembers(catalogn,cuben,dimensionn,hien,leveln); return members; }
/*select the relevant handle*/ void handleGuideline(GuidelineHolder* holder, AssemblyLine* assemblyLine) { if (startsWith(assemblyLine->line, STRING_STR)) { handleString(holder, assemblyLine); } else if (startsWith(assemblyLine->line, DATA_STR)) { handleData(holder, assemblyLine); } else if (startsWith(assemblyLine->line, EXTERN_STR)) { handleExtern(holder, assemblyLine); } else if (startsWith(assemblyLine->line, ENTRY_STR)){ handleEntern(holder, assemblyLine); } }
Token Scanner::getToken() { /* Reads the next available character and dispatches to the appropriate FSA for them to parse. */ // do not return MP_COMMENT to the parser do { // detect EOF and skip whitespace hasToken(); char next = peek(); // reset the TOKEN and LEXEME variables, FSA will set new values _token = MP_NULL; _lexeme = ""; // which FSA to call if (next == '\'') // handle strings, start with ' (single quote) handleString(); else if (isdigit(next)) handleNumberic(); else if (isalpha(next) || next=='_' ) // check for identifier handleWord(); else if (next == '{' || next == '}') // handle comments first becuase {} are considered punctation handleComment(); else if (ispunct(next)) handleSymbol(); else if (next == EOF) { _token = MP_EOF; _lexeme = get(); } } while (_token == MP_COMMENT); return _token; };
void JSONHandler::handle(const JSONEntity& value) { switch(value.type()) { case JSONEntity::JSON_T_ARRAY_BEGIN: handleArrayBegin(); setKey(false); incrementLevel(); break; case JSONEntity::JSON_T_ARRAY_END: poco_assert(!isKey()); if (level() > 0) decrementLevel(); handleArrayEnd(); break; case JSONEntity::JSON_T_OBJECT_BEGIN: handleObjectBegin(); setKey(false); incrementLevel(); break; case JSONEntity::JSON_T_OBJECT_END: poco_assert(!isKey()); if (level() > 0) decrementLevel(); handleObjectEnd(); break; case JSONEntity::JSON_T_VALUE_SEPARATOR: handleValueSeparator(); setKey(false); break; case JSONEntity::JSON_T_INTEGER: handleInteger(value); setKey(false); break; case JSONEntity::JSON_T_FLOAT: handleFloat(value); setKey(false); break; case JSONEntity::JSON_T_NULL: handleNull(); setKey(false); break; case JSONEntity::JSON_T_TRUE: handleTrue(); setKey(false); break; case JSONEntity::JSON_T_FALSE: handleFalse(); setKey(false); break; case JSONEntity::JSON_T_KEY: setKey(true); handleKey(value); break; case JSONEntity::JSON_T_STRING: handleString(value); setKey(false); break; default: poco_assert (false); break; } }
void WorksheetSubStreamHandler::handleRecord(Record* record) { if (!record) return; const unsigned type = record->rtti(); if (type == BottomMarginRecord::id) handleBottomMargin(static_cast<BottomMarginRecord*>(record)); else if (type == BoolErrRecord::id) handleBoolErr(static_cast<BoolErrRecord*>(record)); else if (type == BlankRecord::id) handleBlank(static_cast<BlankRecord*>(record)); else if (type == CalcModeRecord::id) handleCalcMode(static_cast<CalcModeRecord*>(record)); else if (type == ColInfoRecord::id) handleColInfo(static_cast<ColInfoRecord*>(record)); else if (type == DataTableRecord::id) handleDataTable(static_cast<DataTableRecord*>(record)); else if (type == FormulaRecord::id) handleFormula(static_cast<FormulaRecord*>(record)); else if (type == FooterRecord::id) handleFooter(static_cast<FooterRecord*>(record)); else if (type == HeaderRecord::id) handleHeader(static_cast<HeaderRecord*>(record)); else if (type == LabelRecord::id) handleLabel(static_cast<LabelRecord*>(record)); else if (type == LabelSSTRecord::id) handleLabelSST(static_cast<LabelSSTRecord*>(record)); else if (type == LeftMarginRecord::id) handleLeftMargin(static_cast<LeftMarginRecord*>(record)); else if (type == MergedCellsRecord::id) handleMergedCells(static_cast<MergedCellsRecord*>(record)); else if (type == MulBlankRecord::id) handleMulBlank(static_cast<MulBlankRecord*>(record)); else if (type == MulRKRecord::id) handleMulRK(static_cast<MulRKRecord*>(record)); else if (type == NumberRecord::id) handleNumber(static_cast<NumberRecord*>(record)); else if (type == RightMarginRecord::id) handleRightMargin(static_cast<RightMarginRecord*>(record)); else if (type == RKRecord::id) handleRK(static_cast<RKRecord*>(record)); else if (type == RowRecord::id) handleRow(static_cast<RowRecord*>(record)); else if (type == RStringRecord::id) handleRString(static_cast<RStringRecord*>(record)); else if (type == SharedFormulaRecord::id) handleSharedFormula(static_cast<SharedFormulaRecord*>(record)); else if (type == StringRecord::id) handleString(static_cast<StringRecord*>(record)); else if (type == TopMarginRecord::id) handleTopMargin(static_cast<TopMarginRecord*>(record)); else if (type == HLinkRecord::id) handleHLink(static_cast<HLinkRecord*>(record)); else if (type == NoteRecord::id) handleNote(static_cast<NoteRecord*>(record)); else if (type == ObjRecord::id) handleObj(static_cast<ObjRecord*>(record)); else if (type == TxORecord::id) handleTxO(static_cast<TxORecord*>(record)); else if (type == BOFRecord::id) handleBOF(static_cast<BOFRecord*>(record)); else if (type == DefaultRowHeightRecord::id) handleDefaultRowHeight(static_cast<DefaultRowHeightRecord*>(record)); else if (type == DefaultColWidthRecord::id) handleDefaultColWidth(static_cast<DefaultColWidthRecord*>(record)); else if (type == SetupRecord::id) handleSetup(static_cast<SetupRecord*>(record)); else if (type == HCenterRecord::id) handleHCenter(static_cast<HCenterRecord*>(record)); else if (type == VCenterRecord::id) handleVCenter(static_cast<VCenterRecord*>(record)); else if (type == ZoomLevelRecord::id) handleZoomLevel(static_cast<ZoomLevelRecord*>(record)); else if (type == 0xA) {} //EofRecord else if (type == DimensionRecord::id) handleDimension(static_cast<DimensionRecord*>(record)); else if (type == MsoDrawingRecord::id) handleMsoDrawing(static_cast<MsoDrawingRecord*>(record)); else if (type == Window2Record::id) handleWindow2(static_cast<Window2Record*>(record)); else if (type == PasswordRecord::id) handlePassword(static_cast<PasswordRecord*>(record)); else if (type == BkHimRecord::id) handleBkHim(static_cast<BkHimRecord*>(record)); else if (type == VerticalPageBreaksRecord::id) handleVerticalPageBreaksRecord(static_cast<VerticalPageBreaksRecord*>(record)); else if (type == HorizontalPageBreaksRecord::id) handleHorizontalPageBreaksRecord(static_cast<HorizontalPageBreaksRecord*>(record)); else if (type == CondFmtRecord::id) handleCondFmtRecord(static_cast<CondFmtRecord*>(record)); else if (type == CFRecord::id) handleCFRecord(static_cast<CFRecord*>(record)); else { //std::cout << "Unhandled worksheet record with type=" << type << " name=" << record->name() << std::endl; } }