这篇教程C++ GetLine函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetLine函数的典型用法代码示例。如果您正苦于以下问题:C++ GetLine函数的具体用法?C++ GetLine怎么用?C++ GetLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetLine函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(int argc,char **argv){ int curr_arg; bool bDebug; bool bVerbose; bool bHaveDateString; char *date_string; bool bGetDateFromCwd; bool bPosNeg; int retval; int offset; FILE *fptr; int linelen; int line_no; int number; int work; int total; int positive_total; int negative_total; if ((argc < 2) || (argc > 8)) { printf(usage); return 1; } bDebug = false; bVerbose = false; bHaveDateString = false; bGetDateFromCwd = false; bPosNeg = false; offset = 0; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else if (!strncmp(argv[curr_arg],"-offset",7)) sscanf(&argv[curr_arg][7],"%d",&offset); else if (!strncmp(argv[curr_arg],"-date",5)) { date_string = &argv[curr_arg][5]; bHaveDateString = true; } else if (!strcmp(argv[curr_arg],"-get_date_from_cwd")) bGetDateFromCwd = true; else if (!strcmp(argv[curr_arg],"-pos_neg")) bPosNeg = true; else break; } if (argc - curr_arg != 1) { printf(usage); return 2; } if (bHaveDateString && bGetDateFromCwd) { printf("can't specify both -date and -get_date_from_cwd/n"); return 3; } if (bDebug || bGetDateFromCwd) getcwd(save_dir,_MAX_PATH); if (bGetDateFromCwd) { retval = get_date_from_cwd(save_dir,&date_string); if (retval) { printf("get_date_from_cwd() failed: %d/n",retval); return 4; } bHaveDateString = true; } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 5; } line_no = 0; total = 0; if (bPosNeg) { positive_total = 0; negative_total = 0; } for ( ; ; ) { GetLine(fptr,line,&linelen,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(&line[offset],"%d %d",&number,&work); work *= number; total += work;//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:command_line_tools,代码行数:101,
示例2: mainint main(int argc,char **argv){ int m; int n; int curr_arg; bool bDebug; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int ix; int file_no; if ((argc < 3) || (argc > 4)) { printf(usage); return 1; } bDebug = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) { bDebug = true; getcwd(save_dir,_MAX_PATH); } else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } file_no = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; if (Contains(true, line,line_len, argv[player_name_ix],player_name_len, &ix)) { if (!strncmp(line,dealt_to,DEALT_TO_LEN)) { for (n = 0; n < line_len; n++) { if (line[n] == '[') break; } if (n < line_len) { n++; for (m = n; m < line_len; m++) { if (line[m] == ']') break; } if (m < line_len) { line[m] = 0; if (!bDebug) printf("%s/n",&line[n]); else printf("%s %s//%s/n",&line[n],save_dir,filename); continue; } }//.........这里部分代码省略.........
开发者ID:yawecodin,项目名称:misc_poker_utilities,代码行数:101,
示例3: PrintInstructions2void PrintInstructions2(){ printf("/nThe Game is going to start . Press any key when you are ready."); GetLine(); printf("/nTo pause,click mouse on the graph./n");}
开发者ID:jarvis-huang,项目名称:CPP,代码行数:6,
示例4: PreviewSubTaskvoid PreviewSubTask()#endif{#ifndef __PPC__ struct SubTask *st;#endif BOOL done = FALSE, working = FALSE, init = FALSE, stop = FALSE; int y; struct SubTaskMsg *stm; struct PreviewData *data; rsiSMALL_COLOR *line;#ifndef __PPC__ st = InitSubTask();#endif if(st) { /* ** after the sub task is up and running, we go into ** a loop and process the messages from the main task. */ while(!done) { while((stm = (struct SubTaskMsg *)WARPOS_PPC_FUNC(GetMsg)(st->st_Port))) { switch(stm->stm_Command) { case STC_SHUTDOWN: // This is the shutdown message from KillSubTask(). done = TRUE; working = FALSE; break; case STC_CLEANUP: working = FALSE; if(data->preview) {#ifdef __MIXEDBINARY__ PreviewDelete(data->preview);#else delete data->preview;#endif data->preview = NULL; } break; case STC_START: working = TRUE; stop = FALSE; init = FALSE; data = (struct PreviewData*)stm->stm_Parameter;#ifdef __MIXEDBINARY__ data->preview = PreviewCreate();#else data->preview = new PREVIEW;#endif if(!data->preview) done = TRUE; break; case STC_STOP: stop = TRUE; break; case STC_RESUME: stop = FALSE; break; } /* ** If we received a shutdown message, we do not reply it ** immediately. First, we need to free our resources. */ if(done) break; WARPOS_PPC_FUNC(ReplyMsg)((struct Message *)stm); } if(working && !stop) { if(!init) {#ifdef __MIXEDBINARY__ if(Init(data->preview, data->width, data->height, LINES, data->surf, data->object))#else if(data->preview->Init(data->width, data->height, LINES, data->surf, data->object))#endif { init = TRUE; DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 4, MUIM_MsgHandler_PushMessage, data->renderarea, 1, MUIM_Render_ResetColors); DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_SubTask, st);#ifdef __MIXEDBINARY__ DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, GetLine(data->preview));#else DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, data->preview->GetLine());#endif DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Lines, LINES); y = 0; } else { working = FALSE; } }//.........这里部分代码省略.........
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:101,
示例5: Kifacevoid CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ){ FOOTPRINT_ALIAS_LIST aliases; FOOTPRINT_ALIAS* alias; COMPONENT* component; wxFileName fn; wxString msg, tmp; char Line[1024]; FILE* file; size_t ii; SEARCH_STACK& search = Kiface().KifaceSearch(); if( m_netlist.IsEmpty() ) return; // Find equivalents in all available files. for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ ) { fn = m_AliasLibNames[ii]; if( !fn.HasExt() ) { fn.SetExt( FootprintAliasFileExtension ); // above fails if filename has more than one point } else { fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension ); } tmp = search.FindValidPath( fn.GetFullPath() ); if( !tmp ) { msg.Printf( _( "Footprint alias library file '%s' could not be found in the " "default search paths." ), GetChars( fn.GetFullName() ) ); wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR ); continue; } file = wxFopen( tmp, wxT( "rt" ) ); if( file == NULL ) { msg.Printf( _( "Error opening alias library '%s'." ), GetChars( tmp ) ); wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR ); continue; } while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL ) { char* text = Line; wxString value, footprint, wtext = FROM_UTF8( Line ); value = GetQuotedText( wtext ); if( text == NULL || ( *text == 0 ) || value.IsEmpty() ) continue; footprint = GetQuotedText( wtext ); if( footprint.IsEmpty() ) continue; value.Replace( wxT( " " ), wxT( "_" ) ); alias = new FOOTPRINT_ALIAS(); alias->m_Name = value; alias->m_FootprintName = footprint; aliases.push_back( alias ); } fclose( file ); } // Display the number of footprint aliases. msg.Printf( _( "%d footprint aliases found." ), aliases.size() ); SetStatusText( msg, 0 ); m_skipComponentSelect = true; ii = 0; for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ ) { component = m_netlist.GetComponent( kk ); bool found = false; m_compListBox->SetSelection( ii++, true ); if( !component->GetFPID().empty() ) continue; BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases ) { if( alias.m_Name.CmpNoCase( component->GetValue() ) != 0 ) continue;//.........这里部分代码省略.........
开发者ID:danstiurca,项目名称:kicad-source-mirror,代码行数:101,
示例6: mainint main(int argc,char **argv){ int m; int n; int p; int curr_arg; bool bDebug; bool bCount; bool bShowZero; int reupped_count; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int dbg_line_no; int ix; int street; int num_street_markers; int starting_balance; int spent_this_street; int spent_this_hand; int end_ix; int uncalled_bet_amount; int collected_from_pot; int collected_from_pot_count; int ending_balance; int file_no; int dbg_file_no; int dbg; int work; double dwork1; double dwork2; bool bSkipping; if ((argc < 3) || (argc > 6)) { printf(usage); return 1; } bDebug = false; bCount = false; bShowZero = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-count")) bCount = true; else if (!strcmp(argv[curr_arg],"-show_zero")) { bShowZero = true; bCount = true; } else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } file_no = 0; dbg_file_no = -1; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; strcpy(prev_filename,filename); file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; ending_balance = -1; reupped_count = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr))//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,
示例7: ExecuteDWORD WINAPI Execute(LPDWORD data){ int i, linenumber; char line[256], buf[256], logbuf[100], *prog; BOOL error = FALSE; obj = NULL; light = NULL; ULONG arg[MAXARGS]; for (i = 0; i < MAXARGS; i++) arg[i] = NULL; prog = ((THREAD_DATA *)data)->szProg; pDisplay = ((THREAD_DATA *)data)->pDisplay; strcpy(szIncludePath, ""); strcpy(szPicturePath, ""); err = rsiSetLogCB(Log); if (err) { rsiGetErrorMsg(buf,err); Log(buf); } err = rsiSetUpdateStatusCB(UpdateStatus); if (err) { rsiGetErrorMsg(buf,err); Log(buf); } err = rsiSetCheckCancelCB(CheckCancel); if (err) { rsiGetErrorMsg(buf,err); Log(buf); } err = rsiSetCooperateCB(Cooperate); if (err) { rsiGetErrorMsg(buf,err); Log(buf); } linenumber = 0; include = 0; while ((*prog || include > 0) && !error) { GetLine(&prog, line, &linenumber); // read command first if (!Scan(line, buf, arg)) { i = 0; // find command in list while (commands[i].name && stricmp(buf, commands[i].name)) i++; // call corresponding function with "arg" as argument if (commands[i].func) error = commands[i].func(arg); else error = ERROR_UNKNOWNCOM; for (i = 0; i < MAXARGS; i++) { if (arg[i]) delete (ULONG *)arg[i]; arg[i] = NULL; } if (error) { if (include) { sprintf(logbuf, "In include file: /"%s/"", Includefile[include].name); pDisplay->Log(logbuf); linenumber = Includefile[include].linenumber; } sprintf(logbuf, "Error executing command in line %i", linenumber); pDisplay->Log(logbuf); pDisplay->Log(line); GetError(logbuf, error); pDisplay->Log(logbuf); } } } if (error) { pDisplay->Log("Error occurred"); pDisplay->Log("Cancel execution"); // close open include files while (include > 0) { if (Includefile[include].hFile) fclose(Includefile[include].hFile); include--;//.........这里部分代码省略.........
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:101,
示例8: main//.........这里部分代码省略......... if (bDelta && bStartingBalance) { printf("can't specify both -delta and -starting_balance/n"); return 3; } player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 4; } ending_balance = -1; prev_ending_balance = -1; if (bDelta) { max_delta = -1; min_delta = 1; } else if (bStartingBalance) { max_starting_balance = -1; min_starting_balance = 1; } else { max_ending_balance = -1; min_ending_balance = 1; } file_no = 0; dbg_file_no = -1; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; street = 0; num_street_markers = 0; ante = 0; bring_in = 0; spent_this_street = 0; spent_this_hand = 0; uncalled_bet_amount = 0; collected_from_pot = 0; collected_from_pot_count = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++;
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:67,
示例9: IsFunctioning//=====================================================================bool Rowind::IsFunctioning() { if(GetLine() != Null) { return true; } return false;}
开发者ID:bobalong,项目名称:Rowind,代码行数:7,
示例10: read_ozoneint read_ozone(char* fname, short int** out_data, int* doy, int* year, int* nlats, int* nlons, float* minlat, float* minlon, float* maxlat, float* maxlon, float* latsteps, float* lonsteps, float* lat_array, float* lon_array){ FILE *fp; char line[MAX_STR_LEN+1]; char dtype[10],month[4],valbuf[4]; char c_day_of_month[3]; int day_of_month; int irow,icol,i=0,ival; int ilat; int number; short int* data; float mylat; float comp_lat,comp_lon; char hemisphere1, hemisphere2; /* Day: 260 Sep 17, 2001 EP/TOMS NRT OZONE GEN:01.271 Asc LECT: 11:09 AM 012345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2345678 Longitudes: 288 bins centered on 179.375 W to 179.375 E (1.25 degree steps) Latitudes : 180 bins centered on 89.5 S to 89.5 N (1.00 degree steps) */ fp = fopen(fname, "r"); GetLine(fp,line); sscanf(line," Day: %3d ",doy); strncpy(month,&line[10],3); month[3]='/0'; strncpy(c_day_of_month,&line[14],2); c_day_of_month[2]='/0'; strncpy(dtype,&line[26],7); dtype[7]='/0'; day_of_month= atoi( c_day_of_month ); *year= atoi( &line[18] ); printf("year=%d month=%s day_of_month=%d/n",*year,month,day_of_month); GetLine(fp,line); sscanf(line," Longitudes: %3d bins centered on %7f W to %7f E (%5f ", nlons, minlon, maxlon, lonsteps); /* OMI data used different index - Feng */ if(strstr(fname, "omi")) { hemisphere1= line[42]; hemisphere2= line[55]; } else { hemisphere1= line[43]; hemisphere2= line[56]; } *minlon *= (hemisphere1=='S'||hemisphere1=='W'?-1.0:1.0); *maxlon *= (hemisphere2=='S'||hemisphere2=='W'?-1.0:1.0); GetLine(fp,line); sscanf(line," Latitudes : %3d bins centered on %7f S to %7f N (%4f ", nlats, minlat, maxlat, latsteps); /* OMI data used different index - Feng */ if(strstr(fname, "omi")) { hemisphere1= line[42]; hemisphere2= line[55]; } else { hemisphere1= line[43]; hemisphere2= line[56]; } *minlat *= (hemisphere1=='S'||hemisphere1=='W'?-1.0:1.0); *maxlat *= (hemisphere2=='S'||hemisphere2=='W'?-1.0:1.0); comp_lat= *minlat; comp_lon= *minlon; data = (short int *)calloc(((*nlats)*(*nlons)), sizeof(short int)); for (icol=0; icol<*nlons; icol++) { lon_array[icol]= comp_lon; comp_lon += *lonsteps; } ilat=0; for (irow=0; irow<*nlats; irow++) { ival=0; for (icol=0; icol<NLINE; icol++) { GetLine(fp,line); for ( i=0; i<(icol<(NLINE-1)?longline:shortline); i++ ) { strncpy(valbuf,&line[i*3+1],3); valbuf[3]='/0'; sscanf(valbuf,"%3d",&number); data[(*nlats-ilat-1)*(*nlons)+ival++]= number; /* sscanf(&line[i*3+1],"%3d",&data[ival++]); */ } } sscanf(&line[i*3+1]," lat = %f",&mylat); if (0 ) printf("*** in=(%s) mylat=(%f) complat=(%f) ***/n",&line[i*3+1],mylat,comp_lat); lat_array[*nlats-ilat-1]= comp_lat; comp_lat += *latsteps; ilat++; } *out_data= data; return 0;}
开发者ID:Jwely,项目名称:ledaps,代码行数:100,
示例11: mainvoid main(void){ M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB01); // Enable DBB01 Interrupt for TempCounter M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB11); // Enable DBB01 Interrupt for MotorDriver M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO); // Enable GPIO interrupt for Tout // Start the UART(with no parity), LCD, TempCounter and MotorDriver UART_Start(UART_PARITY_NONE); LCD_Start(); TempCounter_EnableInt(); // Enable interrupts for counter TempCounter_Start(); MotorDriver_EnableInt(); // Enable interrupts for counter // Start I2CHW I2CHW_Start(); I2CHW_EnableMstr(); I2CHW_EnableInt(); WriteI2C(slaveAddress, 0xAC, 1, 0x02); // Write to access config, sets mode to cooling(POL = 1), also turns 1-SHOT off, continuous conversions WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets initial high temp to be setTemp + tolerance WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets initial low temp to be setTemp - tolerance WriteI2C(slaveAddress, 0xEE, 0); // This tells the temperature IC to start converting the temperatures // Writes initial string to LCD. When LCD is updated, only the numbers will be changed LCD_Position(0,0); LCD_PrCString("CUR: 00 OFF "); LCD_Position(1,0); LCD_PrCString("SET: 00 FAN OFF "); // This is the command usage string UART_CPutString("#################### Heating/Cooling Stepper Motors ##################/r/n/# S ##/r/n/# S - Set the desired Temperature/r/n/# ## - Desired temperature in celsius/r/n/#/r/n/# T ##/r/n/# T - Set the desired tolerance/r/n/# ## - Desired tolerance in celsius/r/n/#/r/n/# M X/r/n/# M - Change the mode of the thermostat/r/n/# X - C is for cool, H is for heat, F is for off/r/n/#/r/n/# F X S/r/n/# F - Change the mode of the fan/r/n/# X - A is for automatic fan control, M is for always on/r/n/# S - Speed of the fan, H = high, M = medium, L = low/r/n/#####################################################################/r/n"); while (1) { char *cmd; char *params; if (GetLine(buf, &strPos, 79)) // Only process the data if GetLine returns true { cmd = Lowercase(cstrtok(buf, " ")); // Lowercase the first word from the inputted string if (strlen(cmd) == 1 && cmd[0] == 's') // If the person entered s { int temp; params = cstrtok(0x00, " "); // Read next word // If next word isnt number or isnt 1 or 2 characters long, then return error if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &temp) != 1) goto error; // If there is additional data at end of string or if number is not within 0-99, return error if (cstrtok(0x00, " ") != 0x00) goto error; if ( temp > 99 || temp < 0) goto error; setTemp = temp; WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance updateLCD = TRUE; // Update the LCD } else if (strlen(cmd) == 1 && cmd[0] == 't') // If the person entered t { int tol; params = cstrtok(0x00, " "); // Read next word // If next word isnt number or isnt 1 or 2 characters long, then return error if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &tol) != 1) goto error; // If there is additional data at end of string or if number is not within 0-10, return error if (cstrtok(0x00, " ") != 0x00) goto error; if (tol < 0 || tol > 10) goto error; tolerance = tol; WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance updateLCD = TRUE; // Update the LCD } else if (strlen(cmd) == 1 && cmd[0] == 'm') // If the person entered m { char mode; params = cstrtok(0x00, " "); // Read next word // If next word isnt 1 character long, return error//.........这里部分代码省略.........
开发者ID:addisonElliott,项目名称:ECE381,代码行数:101,
示例12: mainint main(int argc,char **argv){ int m; int n; bool bNoSort; bool bNot; int curr_arg; FILE *fptr; int line_len; int num_sessions; int session_ix; int delta; int session_is_blue; int prev_session_is_blue; int chara; int *sort_ixs; int num_blue_streaks; int blue_streak_ix; int retval; char *cpt; int cumulative_delta; int max_cumulative_delta; if ((argc < 2) || (argc > 5)) { printf(usage); return 1; } bNoSort = false; bAscending = false; bNot = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-no_sort")) bNoSort = true; else if (!strcmp(argv[curr_arg],"-ascending")) bAscending = true; else if (!strcmp(argv[curr_arg],"-not")) bNot = true; else break; } if (argc - curr_arg != 1) { printf(usage); return 2; } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } num_sessions = 0; num_blue_streaks = 0; cumulative_delta = 0; max_cumulative_delta = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; if (!line_len) continue; chara = line[0]; if (((chara >= 'a') && (chara <= 'z')) || ((chara >= 'A') && (chara <= 'Z'))) continue; sscanf(&line[11],"%d",&delta); cumulative_delta += delta; if (cumulative_delta > max_cumulative_delta) { if (!bNot) session_is_blue = 1; else session_is_blue = 0; max_cumulative_delta = cumulative_delta; } else { if (!bNot) session_is_blue = 0; else session_is_blue = 1; } if ((session_is_blue == 1) && ((num_sessions == 0) || (prev_session_is_blue == 0))) num_blue_streaks++; num_sessions++; prev_session_is_blue = session_is_blue; } if ((session_info = (struct session_info_struct *)malloc(//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,
示例13: ParseInputintParseInput(register DviWidget dw){ int n, k; int c; char Buffer[BUFSIZ]; int NextPage; int otherc; StopSeen = 0; /* * make sure some state exists */ if (!dw->dvi.state) push_env (dw); for (;;) { switch (DviGetC(dw, &c)) { case '/n': break; case ' ': /* when input is text */ case 0: /* occasional noise creeps in */ break; case '{': /* push down current environment */ push_env(dw); break; case '}': pop_env(dw); break; /* * two motion digits plus a character */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': HorizontalMove(dw, (c-'0')*10 + DviGetC(dw,&otherc)-'0'); /* fall through */ case 'c': /* single ascii character */ DviGetC(dw,&c); if (c == ' ') break; Buffer[0] = c; Buffer[1] = '/0'; (void) PutCharacter (dw, Buffer); break; case 'C': GetWord (dw, Buffer, BUFSIZ); (void) PutCharacter (dw, Buffer); break; case 't': Buffer[1] = '/0'; while (DviGetC (dw, &c) != EOF && c != ' ' && c != '/n') { Buffer[0] = c; HorizontalMove (dw, PutCharacter (dw, Buffer)); } break; case 'u': n = GetNumber(dw); Buffer[1] = '/0'; while (DviGetC (dw, &c) == ' ') ; while (c != EOF && c != ' ' && c != '/n') { Buffer[0] = c; HorizontalMove (dw, PutCharacter (dw, Buffer) + n); DviGetC (dw, &c); } break; case 'D': /* draw function */ (void) GetLine(dw, Buffer, BUFSIZ); if (dw->dvi.display_enable) ParseDrawFunction(dw, Buffer); break; case 's': /* ignore fractional sizes */ n = GetNumber(dw); dw->dvi.state->font_size = n; break; case 'f': n = GetNumber(dw); dw->dvi.state->font_number = n; break; case 'H': /* absolute horizontal motion */ k = GetNumber(dw); HorizontalGoto(dw, k); break; case 'h': /* relative horizontal motion */ k = GetNumber(dw); HorizontalMove(dw, k); break; case 'w': /* word space */ Word (dw); break; case 'V': n = GetNumber(dw); VerticalGoto(dw, n); break; case 'v'://.........这里部分代码省略.........
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:101,
示例14: mainint main(int argc,char **argv){ int curr_arg; bool bVerbose; int ge_val; FILE *fptr; int line_len; int line_no; int last_ge_line_no; int val; int intervening; int max_intervening; if ((argc < 3) || (argc > 4)) { printf(usage); return 1; } bVerbose = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } sscanf(argv[curr_arg],"%d",&ge_val); if ((fptr = fopen(argv[curr_arg+1],"r")) == NULL) { printf(couldnt_open,argv[curr_arg+1]); return 3; } line_no = 0; last_ge_line_no = 0; max_intervening = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(line,"%d",&val); if (val >= ge_val) { if (!bVerbose) printf("%d/n",val); else if (!last_ge_line_no) printf("%s %d/n",line,line_no); else { intervening = line_no - (last_ge_line_no + 1); if (intervening > max_intervening) max_intervening = intervening; printf("%s %d (%d)/n",line,line_no,intervening); } last_ge_line_no = line_no; } } fclose(fptr); printf("max_intervening = %d/n",max_intervening); return 0;}
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:77,
示例15: mainint main(int argc,char **argv){ FILE *fptr; int line_len; int line_no; int val; int max_nonzero_streak; int max_nonzero_streak_start_ix; int curr_nonzero_streak; int curr_nonzero_streak_start_ix; if (argc != 2) { printf(usage); return 1; } if ((fptr = fopen(argv[1],"r")) == NULL) { printf(couldnt_open,argv[1]); return 2; } line_no = 0; max_nonzero_streak = 0; curr_nonzero_streak = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; sscanf(line,"%d",&val); if (!val) { if (curr_nonzero_streak > max_nonzero_streak) { max_nonzero_streak = curr_nonzero_streak; max_nonzero_streak_start_ix = curr_nonzero_streak_start_ix; } curr_nonzero_streak = 0; } else { if (!curr_nonzero_streak) curr_nonzero_streak_start_ix = line_no; curr_nonzero_streak++; } line_no++; } if (curr_nonzero_streak > max_nonzero_streak) { max_nonzero_streak = curr_nonzero_streak; max_nonzero_streak_start_ix = curr_nonzero_streak_start_ix; } fclose(fptr); printf("%d (%d)/n",max_nonzero_streak,max_nonzero_streak_start_ix+1); return 0;}
开发者ID:neostreet,项目名称:command_line_tools,代码行数:63,
示例16: switch//.........这里部分代码省略......... AutoCompleteInsertText(); AutoCompleteHide(); return; } case VK_LEFT: // left arrow case VK_RIGHT: // right arrow case VK_INSERT: // insert key case VK_DELETE: { // delete key return; } } } BracedSectionHide(); switch( nKey ) { case VK_TAB: { // multi-line tabs long selStart, selEnd; GetSel( selStart, selEnd ); // if multiple lines are selected add tabs to, or remove tabs from all of them if ( selEnd > selStart ) { CString text; text = GetSelText(); if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) { if ( idStr::CharIsTab( text[0] ) ) { text.Delete( 0, 1 ); } for ( int i = 0; i < text.GetLength() - 2; i++ ) { if ( idStr::CharIsNewLine( text[i] ) ) { do { i++; } while( idStr::CharIsNewLine( text[i] ) ); if ( idStr::CharIsTab( text[i] ) ) { text.Delete( i, 1 ); } } } } else { text.Insert( 0, '/t' ); for ( int i = 0; i < text.GetLength() - 1; i++ ) { if ( idStr::CharIsNewLine( text[i] ) ) { do { i++; } while( idStr::CharIsNewLine( text[i] ) ); text.Insert( i, '/t' ); } } } ReplaceSel( text, TRUE ); SetSel( selStart, selStart + text.GetLength() ); } else { ReplaceSel( "/t", TRUE ); } return; } case VK_RETURN: { // auto-indentation long selStart, selEnd; int line, length, numTabs, i; char buffer[1024]; idStr text; GetSel( selStart, selEnd ); line = LineFromChar( selStart ); length = GetLine( line, buffer, sizeof( buffer ) ); for ( numTabs = 0; numTabs < length; numTabs++ ) { if ( !idStr::CharIsTab( buffer[numTabs] ) ) { break; } } bool first = true; for ( i = numTabs; i < length; i++ ) { if ( buffer[i] == '{' ) { numTabs++; first = false; } else if ( buffer[i] == '}' && !first ) { numTabs--; } } text = "/r/n"; for ( i = 0; i < numTabs; i++ ) { text.Append( '/t' ); } ReplaceSel( text, TRUE ); return; } } m_TextDoc->Freeze( NULL ); CRichEditCtrl::OnKeyDown( nKey, nRepCnt, nFlags ); UpdateVisibleRange(); m_TextDoc->Unfreeze( NULL );}
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:101,
示例17: LinkCompComponent* LinkComp::Copy () { LinkComp* copy = new LinkComp((Line*) GetLine()->Copy()); *copy->GetGraphic() = *GetGraphic(); return copy;}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:6,
示例18: AutoCompleteUpdate/*================CSyntaxRichEditCtrl::OnChar================*/void CSyntaxRichEditCtrl::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ) { if ( nChar == VK_TAB ) { return; // tab is handle in OnKeyDown } CRichEditCtrl::OnChar( nChar, nRepCnt, nFlags ); // if the auto-complete list box is up if ( autoCompleteStart >= 0 ) { long selStart, selEnd; if ( charType[nChar] == CT_NAME ) { AutoCompleteUpdate(); return; } else if ( nChar == VK_BACK ) { GetSel( selStart, selEnd ); if ( selStart > autoCompleteStart ) { AutoCompleteUpdate(); } else { AutoCompleteHide(); } return; } else { AutoCompleteHide(); } } // if the function parameter tool tip is up if ( funcParmToolTipStart >= 0 ) { long selStart, selEnd; if ( nChar == ')' || nChar == VK_ESCAPE ) { ToolTipHide(); } else if ( nChar == VK_BACK ) { GetSel( selStart, selEnd ); if ( selStart < funcParmToolTipStart ) { ToolTipHide(); } } } // show keyword auto-completion if ( keyWordAutoCompletion && charType[nChar] == CT_NAME && funcParmToolTipStart < 0 ) { long selStart, selEnd; int line, column, length, i; char buffer[1024]; GetSel( selStart, selEnd ); line = LineFromChar( selStart ); length = GetLine( line, buffer, sizeof( buffer ) ); column = selStart - LineIndex( line ); if ( column <= 1 || charType[buffer[column-2]] == CT_WHITESPACE ) { if ( column >= length-1 || charType[buffer[column]] == CT_WHITESPACE ) { autoCompleteListBox.ResetContent(); for ( i = 0; keyWords[i].keyWord; i++ ) { autoCompleteListBox.AddString( keyWords[i].keyWord ); } AutoCompleteShow( selStart - 1 ); } } return; } // highlight braced sections if ( nChar == '{' ) { BracedSectionStart( '{', '}' ); } else if ( nChar == '}' ) { BracedSectionEnd( '{', '}' ); } else if ( nChar == '(' ) { BracedSectionStart( '(', ')' ); } else if ( nChar == ')' ) { BracedSectionEnd( '(', ')' ); } else if ( nChar == '[' ) { BracedSectionStart( '[', ']' ); } else if ( nChar == ']' ) { BracedSectionEnd( '[', ']' ); } else if ( nChar == '<' ) { BracedSectionStart( '<', '>' ); } else if ( nChar == '>' ) { BracedSectionEnd( '<', '>' ); } // show object member auto-completion if ( nChar == '.' && GetObjectMembers && funcParmToolTipStart < 0 ) { int charIndex; CString name; if ( GetNameBeforeCurrentSelection( name, charIndex ) ) { autoCompleteListBox.ResetContent(); if ( GetObjectMembers( name, autoCompleteListBox ) ) { AutoCompleteShow( charIndex ); } }//.........这里部分代码省略.........
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:101,
示例19: GetCurrentLineinlinescreenline_t* GetCurrentLine() { return GetLine(cur_ln);}
开发者ID:OmniBus,项目名称:hkday-pttbbs,代码行数:4,
示例20: whilewhile(!infile.eof()){ line = GetLine(&infile); var = line.Left(line.Find("=")); val = line.Right(line.GetLength() - line.Find("=") - 1); if(line.IsEmpty() || line[0] == '[' || val.IsEmpty()) ; else if(var == "pallete"){ long double en; m_Calculator.StringToDecimal(val, 10, en); m_CurrentPalete = (PaleteE)int(en); } else if(var == "sound"){ if(val == "1") m_SndEffects = true; else m_SndEffects = false; } else if(var == "tooltips"){ if(val == "1") m_ToolTips.On(true); else m_ToolTips.On(false); } else if(var == "longoutput"){ if(val == "1") m_OutputV.m_LongOutput = true; else m_OutputV.m_LongOutput = false; }
开发者ID:fallen2stealth,项目名称:GraphCalc-Update,代码行数:31,
示例21: mainint main(int argc,char **argv){ int curr_arg; bool bDebug; bool bVerbose; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int retval; char *date_string; int ix; int street; int num_street_markers; int starting_balance; int spent_this_street; int spent_this_hand; int end_ix; int wagered_amount; int uncalled_bet_amount; int collected_from_pot; int collected_from_pot_count; int ending_balance; int delta; int file_no; int dbg_file_no; int dbg; int work; int total_wagered; if ((argc < 3) || (argc > 5)) { printf(usage); return 1; } bDebug = false; bVerbose = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } if (!bVerbose && bDebug) { getcwd(save_dir,_MAX_PATH); retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() on %s failed: %d/n",save_dir,retval); return 4; } } ending_balance = -1; file_no = 0; dbg_file_no = -1; if (!bVerbose) total_wagered = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; street = 0; num_street_markers = 0;//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,
示例22: PromptInterpretervoid PromptInterpreter(Closure_clp self) { Nash_clp nash; char *buf; int nread; int leave; Rd_clp raw_in, cooked_rd; Wr_clp raw_out, cooked_wr; CLine_clp cline; CLineCtl_clp clinectl; /* Cook the command line */ raw_in = Pvs(in); raw_out = Pvs(out); leave = 0; cline = NAME_FIND("modules>CLine", CLine_clp); cooked_rd = CLine$New(cline, Pvs(in) , Pvs(out), &cooked_wr, &clinectl); Pvs(in) = cooked_rd; Pvs(out) = cooked_wr; buf = malloc(sizeof(char)*256); nash = NewNash(0);#ifdef CONFIG_NASHLOGIN while (!leave) { printf("/n/nWelcome to %s's Nemesis/n/n%s login: ", NAME_FIND("conf>userid", string_t), gethostname()); nread = Rd$GetLine(Pvs(in), buf, 255); if (nread) buf[nread-1] = 0; if (!strcmp(buf, "reboot")) { printf("Rebooting/n"); Nash$ExecuteString(nash, "reboot"); } if (!strcmp(buf, "b") || !strcmp(buf, "boot")) { printf("Rebooting/n"); Nash$ExecuteString(nash, "b"); } if (!strcmp(buf, "root")) { leave = 1; } else if (!strcmp(buf, "user")) { leave = 1; } else if (strlen(buf) > 0) { { /* figure out homedirectory */ char *newhomedir; char *ptr; char *lastslash; nash_st *st = (nash_st*) (nash->st); newhomedir = malloc(strlen(st->homedir)+strlen(buf)); strcpy(newhomedir, st->homedir); ptr = newhomedir; lastslash = ptr; while (*ptr) { if (*ptr == '/') lastslash = ptr; ptr++; } lastslash++; strcpy(lastslash, buf); free(st->homedir); st->homedir = newhomedir; printf("New home directory will be %s/n", newhomedir); Nash$ExecuteString(nash, "cd ~"); leave = 1; } } }#endif /* CONFIG_NASHLOGIN */ Nash$ExecuteString(nash, "source profile.nash"); while (1) { printf("%s ", Nash$GetPrompt(nash)); nread = Rd$GetLine(Pvs(in), buf, 255); TRC(printf("/n")); if (nread) { buf[nread-1] = 0; TRC(printf("nread %d buf %s/n", nread, buf+1)); Nash$ExecuteString(nash, buf); } }}
开发者ID:berkus,项目名称:nemesis,代码行数:88,
示例23: main//.........这里部分代码省略......... if (bExactCount && bOneAndDone) { printf("can't specify both -exact_countn and -one_and_done/n"); return 3; } if (bCount && bStartingStack) { printf("can't specify both -count and -starting_stack/n"); return 4; } if (bExactCount && !exact_count) bShowZero = true; player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 5; } if (!bStud) max_streets = 3; else max_streets = 4; file_no = 0; dbg_file_no = -1; if (bConsecutive) consecutive_hit_felt_count = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } retval = get_date_from_path(filename,'//',3,&date_string); if (retval) { printf("get_date_from_path() on %s failed: %d/n",filename,retval); continue; } strcpy(prev_filename,date_string); line_no = 0; hit_felt_count = 0; ending_balance = -1; reupped_count = 0; hand_number = 0; if (bMaxFeltDistance) { last_felted_hand_number = 0; max_felt_distance = 0;
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:67,
示例24: UnitModelGeometryint CUnit3DLoader::ParseSub(CFileHandler& ifs, UnitModel &model,const string& filename,float3 offset,const string& treename){ string s; bool inComment=false; Animation* curAnim=0; int curAnimFrame=0; bool firstGeometryPass=false; if(geometryModels.find(treename)==geometryModels.end()){ geometryModels[treename]=new UnitModelGeometry(); UnitModelGeometry& geometry=*geometryModels[treename]; firstGeometryPass=true; geometry.normalBuffer=0; geometry.indexBuffer=0; geometry.numIndeces=0; geometry.numVerteces=0; } model.geometry=geometryModels[treename]; UnitModelGeometry& geometry=*model.geometry; geometry.radius=1; geometry.height=1; geometry.isAnimated=false; model.texCoordBuffer=0; while(ifs.Peek()!=EOF){ s=GetWord(ifs); MakeLow(s); if(s[0]=='/' && !inComment){ if(s[1]=='/'){ GetLine(ifs); continue; } if(s[1]=='*') inComment=true; } if(inComment){ for(int a=0;a<s.size()-1;++a) if(s[a]=='*' && s[a+1]=='/') inComment=false; if(inComment) continue; } if(ifs.Eof()) break; while((s.c_str()[0]=='/') || (s.c_str()[0]=='/n')){ s=GetLine(ifs); s=GetWord(ifs); MakeLow(s); if(ifs.Eof()) break; } if(s=="vertex"){ int num=atoi(GetWord(ifs).c_str()); float3 v; v.x=atof(GetWord(ifs).c_str()); v.y=atof(GetWord(ifs).c_str()); v.z=atof(GetWord(ifs).c_str()); v-=offset; if(firstGeometryPass){ if(curAnim==0){ while(geometry.vertex.size()<=num){ geometry.vertex.push_back(float3(0,0,0)); geometry.vertexNormal.push_back(float3(0,0,0)); } geometry.vertex[num]=v; } else { AnimFrame* af=&curAnim->frames[curAnimFrame]; while(af->vertex.size()<=num){ af->vertex.push_back(float3()); // model.vertexNormal.push_back(float3(0,0,0)); } af->vertex[num]=v; } } } else if(s=="quad"){ Quad q; QuadTex qt; for(int a=0;a<4;++a) q.verteces[a]=atoi(GetWord(ifs).c_str()); for(int a=0;a<8;++a) qt.texPos[0][a]=atof(GetWord(ifs).c_str()); qt.texName=GetWord(ifs); qt.teamTex=atoi(GetWord(ifs).c_str()); q.normalType=atoi(GetWord(ifs).c_str()); model.quadTex.push_back(qt); if(firstGeometryPass) geometry.quad.push_back(q); } else if(s=="tri"){ Tri t; TriTex tt; for(int a=0;a<3;++a) t.verteces[a]=atoi(GetWord(ifs).c_str()); for(int a=0;a<3;++a){ tt.texPos[0][a*2]=1-atof(GetWord(ifs).c_str());//.........这里部分代码省略.........
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:101,
示例25: LineToOffsetSTextOffset TTextLayout::PointToOffset(const TPoint& point, bool round) const{ TCoord h = point.h - fInset.h; if (h < 0) h = 0; TCoord v = point.v - fInset.v; if (v < 0) v = 0; uint32 line; for (line = 0; line < fLineCount; line++) { if (fLineBreaks[line].vertOffset > v) { if (line > 0) line--; break; } } if (line >= fLineCount) line = fLineCount - 1; STextOffset result = LineToOffset(line); const TChar* lineStart; STextOffset lineLength; TCoord vertOffset, ascent, height; GetLine(line, lineStart, lineLength, vertOffset, ascent, height); if (lineLength == 0) return result; const TChar* lineEnd = lineStart + lineLength; const TChar* text = lineStart; const TChar* lastText = text; TCoord horizOffset = 0; TCoord lastHorizOffset = 0; while (text < lineEnd) { NextCharacter(text); TCoord horizOffset = MeasureText(lineStart, text - lineStart, 0); if (horizOffset > h) { if (round && h - lastHorizOffset + 1 >= horizOffset - h) return result + (text - lineStart); else return result + (lastText - lineStart); } lastHorizOffset = horizOffset; lastText = text; } if (round && h - lastHorizOffset + 1 >= horizOffset - h) return result + (text - lineStart); else return result + (lastText - lineStart);}
开发者ID:mikevoydanoff,项目名称:zoinks,代码行数:62,
示例26: GetQuadByAnimateValuevoid C3DTransform::Render(const PARAM3DTRANSFORM & param3d){ RECT rc = {0, 0, m_nSrcWndWidth, m_nSrcWndHeight}; // 计算当前的动画窗口屏幕坐标 Quad quad; GetQuadByAnimateValue(param3d.nRotateX,param3d.nRotateY, param3d.nRotateZ, param3d.nOffsetZ, &quad); // 用于计算矩形->任意四边形的对应关系 PerspectiveTransform perspective; perspective.SetQuad(&quad, &rc); perspective.ChangeToFixedPoint(); int nWidthDst = m_nSrcWndWidth-1; // (300->299),数据范围是它的大小减一 int nHeightDst = m_nSrcWndHeight-1; // int nDstPitch = nWidthDst*4; float fxSrc = 0; float fySrc = 0; float *pfxSrc = &fxSrc; // 为了在perspective_transform中使用指针 float *pfySrc = &fySrc; LPBYTE pDstBits=m_pDstBits; int nPixByte=m_nBitsPixel/8;#if 1 // 在大循环之前剔除掉一些空白区域 //将目标图片清空 memset(pDstBits, 0, nDstPitch * nHeightDst); int nMinX = max(0, min(min(min(quad.Ax,quad.Bx),quad.Cx),quad.Dx)); int nMinY = max(0, min(min(min(quad.Ay,quad.By),quad.Cy),quad.Dy)); int nMaxX = min(nWidthDst, max(max(max(quad.Ax,quad.Bx),quad.Cx),quad.Dx)); int nMaxY = min(nHeightDst, max(max(max(quad.Ay,quad.By),quad.Cy),quad.Dy)); pDstBits += (nMinY*nDstPitch); for (int Y = nMinY; Y < nMaxY; Y++) { LPBYTE pDest=pDstBits; for (int X = nMinX; X < nMaxX; X++) {#else for (int X = 0, Y = 0; Y < m_nSrcWndHeight; Y++) { for (X = 0; X < m_nSrcWndWidth; X++) {#endif perspective_transform_fp(perspective, X, Y, pfxSrc, pfySrc); int nx = 0; //fx; // 注: 直接赋值 int i = floatvalue; 会产生一个 _ftol()调用 int ny = 0; //fy; // 导致效率降低。这里使用内嵌汇编指令。(3D游戏编程大师技巧 P918) // 浮点数转整数。 注意:默认的fistp是四舍五入模式。需要通过调用_control87(_MCW_RC, _RC_DOWN);进行调整#ifndef _WIN64 __asm fld fxSrc; __asm fistp nx; __asm fld fySrc; __asm fistp ny;#else nx = int(fxSrc); ny = int(fySrc);#endif//WIN32 // 1. ceil的效率非常非常低!千万别在这用 // 但是有一个问题如果height为300,ySrc=299.99999999时,转成(int)得到的结果是300, // 但在这里判断的话是成功的,导致最后崩溃,因此当ySrc>299时即退出 if (nx < 0 || nx >= nWidthDst || ny < 0 || ny >= nHeightDst) { continue; } // 目标与源图像素对应#if 0 ////////////////////////////////////////////////////////////////////////// // 邻近取样, 速度快,但有锯齿 ((DWORD*)pDstBits)[X] = ((DWORD*)(m_pSrcBits + m_nSrcPitch*(int)ySrc))[(int)xSrc];#else ////////////////////////////////////////////////////////////////////////// // 二次线性插值,能有效去掉锯齿,但速度非常慢 //((DWORD*)pDstBits)[X] = Bilinear(m_pSrcBits, m_nSrcPitch, nx, ny, (float)fxSrc, (float)fySrc); // // 二次线性插值公式推导 // http://blog.csdn.net/dakistudio/article/details/1767100 二次线性插值公式推导 // // x为fx的向下取整,y为fy的向下取整 // //inline DWORD& Bilinear(BYTE* pBits, const int& nPitch, const int& x, const int& y, const float& fx, const float& fy) { // 已将原始图片的right/bottom扩大1px,这样在获取 x+1, y+1时达到数组边缘也不会崩溃 // 取附近的四个像素的颜色值(x,y) (x+1, y) (x, y+1) (x+1, y+1) LPBYTE pValue=GetLine(m_pSrcBits, m_nSrcPitch, ny); pValue += nx*nPixByte; LPBYTE p0=pValue;//(x,y); LPBYTE p2=pValue+nPixByte;//(x+1,y)//.........这里部分代码省略.........
开发者ID:3rdexp,项目名称:soui,代码行数:101,
示例27: mainint main(int argc,char **argv){ int curr_arg; bool bVerbose; bool bSeconds; bool bAvg; FILE *fptr; int line_len; int line_no; int num_hands; int ix; int hyphen_ix; time_t date1; time_t date2; int seconds; int diff; int hours; double avg; if ((argc < 2) || (argc > 5)) { printf(usage); return 1; } bVerbose = false; bSeconds = false; bAvg = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-verbose")) { bVerbose = true; getcwd(save_dir,_MAX_PATH); } else if (!strcmp(argv[curr_arg],"-seconds")) bSeconds = true; else if (!strcmp(argv[curr_arg],"-avg")) bAvg = true; else break; } if (argc - curr_arg != 1) { printf(usage); return 2; } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } line_no = 0; num_hands = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; if (Contains(true, line,line_len, pokerstars,POKERSTARS_LEN, &ix)) { num_hands++; hyphen_ix = get_hyphen_ix(line,line_len); if (hyphen_ix < 0) { printf("line %d: get_hyphen_ix failed/n",line_no); return 4; } line[hyphen_ix + 12] = 0; line[line_len - 4] = 0; date2 = cvt_date_and_time(&line[hyphen_ix + 2],&line[hyphen_ix + 13]); if (date2 == -1L) { printf(invalid_date_and_time,line_no, &line[hyphen_ix + 2],&line[hyphen_ix + 13]); return 5; } if (line_no == 1) date1 = date2; } } fclose(fptr); seconds = date2 - date1; if (bSeconds || (seconds < 60)) printf("%d seconds",seconds); else { diff = seconds;//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,
示例28: whilebool CHTMLElement_FrameSet::ValidateTree(CBDParser *pParser, CParseHTMLNode *pThisEle){// <!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?)CParseHTMLNode *pEle;CHTMLElement *pE;bool bValid=true, bOneFrame=false; pEle = (CParseHTMLNode *)pThisEle->GetFirstChild(); while(pEle && bValid) { if ((pE = pEle->m_pElement)) { bValid = true; if (pE->GetID() == NODE_ID_FRAMESET || pE->GetID() == NODE_ID_FRAME) bOneFrame = true; else if (pE->GetID() == NODE_ID_NOFRAMES || entIsPCData(pE->GetID())) ; else bValid=false; } // pEle = (CParseHTMLNode *)pThisEle->GetNextChild(pEle); } // if (!bValid || !bOneFrame) { SetValid(false); pParser->AddError(0, "The <FRAMESET> tag may only include <FRAMESET>s and <FRAME>s", NULL, NULL, GetLine(), GetCol()); } // return true;}
开发者ID:MarquisdeGeek,项目名称:html_parser,代码行数:33,
注:本文中的GetLine函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetLineCount函数代码示例 C++ GetLevel函数代码示例 |