当前位置: 首页>>代码示例>>C++>>正文


C++ ReadLine函数代码示例

本文整理汇总了C++中ReadLine函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadLine函数的具体用法?C++ ReadLine怎么用?C++ ReadLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReadLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleSubstitution

static BOOL HandleSubstitution()
{
BOOL done = FALSE;
int LineNo = 0;
char *FixedLine;
BOOL HadChanges = FALSE;

/* now process the file */
while ( !done )
	{
	if ( ReadLine( ) != 0 )
		done = TRUE;
	else
		{
		++LineNo;
		/*
		TracePrintf( "HandleSubstitution: Processing Line %d\n", LineNo );
		*/
		FixedLine = XTL_Substitute( LineBuffer );
		
		if ( FixedLine == NULL )  /* Bad things happened */
			ErrorExit( "HandleSubstitution() Line blew up" );
		
		if ( ! HadChanges )
		{
			if ( strcmp( FixedLine, LineBuffer ) != 0 )
				HadChanges = TRUE;
		}
	
		WriteToOutputBuffer( FixedLine, strlen(FixedLine) );		
		FreeMemoryBlock( FixedLine );
		}
	}

	
printf( "HandleSubstitution: Processed %d lines for substitution processing this pass\n", LineNo );

return HadChanges;

}
开发者ID:XimeraProject,项目名称:ximeraLatex,代码行数:40,代码来源:xronosfmt.c

示例2: WriteOutputFile

static void WriteOutputFile( char *OutputFileName )
{
	FILE *Out;
	int num;
	XTL_FileStatus XTLFileStat;
	
	
	printf( "Checking to see if we need to make the directory for the output file %s\n", OutputFileName );
	MakeDirChainForFile( OutputFileName );
	
	printf( "Opening output file %s - ", OutputFileName );

	/* now write the actual output file */
	Out = fopen( OutputFileName, "w+");
	if ( Out == NULL )
		ErrorExit( "Failed to open output file" );

	puts( "Writing file header data" );

	if ( strlen( FileForOutputHeader ) > 0 )  /* if we have a fileheader */
	{
		if ( XTL_CopyFileContents( FileForOutputHeader, Out) != 0 )
			ErrorExit( "Unable to copy FileForOutputHeader" );
	}

	puts( "Writing actual file data" );

	/* DANA - FIXUP */
	while ( ReadLine( ) == 0 )
	{	
	num = fwrite(LineBuffer, 1, strlen(LineBuffer), Out );
	}
	
	if ( !QuestionsOnly	 )  /* if the user requested we include the document structure stuff intact */
		fputs( "\\end{document}", Out ); /* write the end document line */

	fclose(Out);
	puts( "output file complete" );

}
开发者ID:XimeraProject,项目名称:ximeraLatex,代码行数:40,代码来源:xronosfmt.c

示例3: ProcessPairs

/*****************************************
ProcessPairs(): Process pairs of names.
Format: dest src
*****************************************/
void ProcessPairs(FILE* Fin, char* Type)
{
  char Buf[10240];
  char Dst[FILENAME_MAX];
  char Src[FILENAME_MAX];
  int Space;
  int i, s, c;

  while (ReadLine(Fin, Buf, sizeof(Buf)) > 0)
  {
    Space = 0;
    /* save the dst name */
    while ((Buf[Space] != '\0') && (Buf[Space] != ' ')) Space++;
    strncpy(Dst, Buf, Space);
    /* skip the space */
    /* save the src name and remove unicode stuff */
    memset(Dst, '\0', sizeof(Dst));
    memset(Src, '\0', sizeof(Src));
    strncpy(Dst, Buf, Space);
    s = 0;
    for (i = Space + 1; Buf[i] != '\0'; i++)
    {
      if (Buf[i] != '&') Src[s++] = Buf[i];
      else
      {
        c = UnUnicodeHex(Buf + i);
        if (c >= 0)
        {
          Src[s++] = c;
          i += 5;
        }
        else Src[s++] = Buf[i];
      }
    }
#if 0
    printf("Dst='%s'  Src='%s'\n",Dst,Src);
#endif
    CopyFile(Src, Type, Dst);
  }
} /* ProcessPairs() */
开发者ID:7hibault,项目名称:fossology,代码行数:44,代码来源:repcopyin.c

示例4: ProgramMode

static int ProgramMode(int adx, int argc, FChS * argv[])
{
    FAssert(adx < argc);

    FObject nam = MakeStringS(argv[adx]);

    adx += 1;
    R.CommandLine = MakePair(MakeInvocation(adx, argv), MakeCommandLine(argc - adx, argv + adx));

    FObject port;
    {
        FDontWait dw;

        port = OpenInputFile(nam);
        if (TextualPortP(port) == 0)
        {
#ifdef FOMENT_WINDOWS
            printf("error: unable to open program: %S\n", argv[adx - 1]);
#endif // FOMENT_WINDOWS

#ifdef FOMENT_UNIX
            printf("error: unable to open program: %s\n", argv[adx - 1]);
#endif // FOMENT_UNIX
            return(Usage());
        }
    }

    FCh ch;

    // Skip #!/usr/local/bin/foment

    if (PeekCh(port, &ch) && ch == '#')
        ReadLine(port);

    FObject proc = CompileProgram(nam, port);

    ExecuteThunk(proc);
    ExitFoment();
    return(0);
}
开发者ID:beimprovised,项目名称:foment,代码行数:40,代码来源:main.cpp

示例5: debug

bool NntpConnection::Connect()
{
    debug("Opening connection to %s", GetHost());

    if (m_status == csConnected)
    {
        return true;
    }

    if (!Connection::Connect())
    {
        return false;
    }

    char* answer = ReadLine(m_lineBuf, m_lineBuf.Size(), nullptr);

    if (!answer)
    {
        ReportErrorAnswer("Connection to %s (%s) failed: Connection closed by remote host", nullptr);
        Disconnect();
        return false;
    }

    if (strncmp(answer, "2", 1))
    {
        ReportErrorAnswer("Connection to %s (%s) failed: %s", answer);
        Disconnect();
        return false;
    }

    if ((strlen(m_newsServer->GetUser()) > 0 && strlen(m_newsServer->GetPassword()) > 0) &&
            !Authenticate())
    {
        return false;
    }

    debug("Connection to %s established", GetHost());

    return true;
}
开发者ID:ta264,项目名称:nzbget,代码行数:40,代码来源:NntpConnection.cpp

示例6: ReadLine

inline
bool
TxtHandler::TestLine(const wxString & test, bool strip)
{
    // Only strip this line for the test.  In case whitespace characters are
    // meaningful, we should preserve them if we have to UngetLine().
    wxString line = ReadLine(NO_STRIP_WHITESPACE);

    if (strip == true)
    {
        if (line.Trim(true).Trim(false) == test)
            return true;
    }
    else
    {
        if (line == test)
            return true;
    }

    UngetLine(line);
    return false;
}
开发者ID:brho,项目名称:xword,代码行数:22,代码来源:TxtHandler.hpp

示例7: while

/*******************************************************************
 * Function Name: Read
 * Return Type 	: int
 * Created On	: Feb 26, 2013
 * Created By 	: hrushi
 * Comments		: Reads the feature file into the memory
 * Arguments	: const Args& args
 *******************************************************************/
int Features::Read( const Args& args)
{
	string line;
	unsigned int LineCount = 0;

	if( fPtr.is_open() )
	{
		while(fPtr.good())
		{
			getline(fPtr, line);
			LineCount++;

			try
			{
				ReadLine(args, line);
			}
			catch( int Err )
			{
				cerr << "Check Line Number: " << LineCount << endl;
				throw Err;
			}
		}

		ZMUL(args);
	}
	else
	{
		cerr << "Cannot read Feature File " << endl;
		exit(ERR_CANNOT_OPEN_FILE);
	}

	if( ImgFeature.size() == 0 )
	{
		cerr << "No feature read from " << FilePath.string() << endl;
		throw ERR_CANNOT_READ_VALUE;
	}

	return EXIT_SUCCESS;
}
开发者ID:hnkulkarni,项目名称:DetectCarriedObjs-PerfEval,代码行数:47,代码来源:Features.cpp

示例8: ResetLine

bool CDialogLoaderMK2::ProcessScript(CDialogScript* pScript, const XmlNodeRef& node)
{
	CDialogScript::SScriptLine scriptLine;

	const char* scriptID = pScript->GetID();
	string desc = node->getAttr("Description");
	pScript->SetDescription(desc);

	for (int i=0; i<node->getChildCount(); ++i)
	{
		XmlNodeRef lineNode = node->getChild(i);
		if (lineNode && lineNode->isTag("Line"))
		{
			ResetLine(scriptLine);
			if (ReadLine (lineNode, scriptLine, scriptID, i) == true)
			{
				pScript->AddLine(scriptLine);
			}
		}
	}
	return true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:22,代码来源:DialogLoaderMK2.cpp

示例9: while

// Load an .obj file into Manta
model* FileManager_Model::LoadObj(string filename, vec3* objPosition)
{
	byte* buffer;
	byte  lineBuffer[MAX_FILE_LINE_LENGTH];
	bool  reachedEnd = false;
	byte* position;

	if (LoadFile(&buffer, filename))
	{
		int vertexCount = 0;
		int polyCount = 0;
		// Set vertex offset (-1 since obj is indexed from 1)
		vertexOffset = scene->getVertexCount() - 1;
		polyOffset = scene->getPolyCount();
		// Loop through each line
		position = buffer;
		while (!reachedEnd)
		{
			reachedEnd = ReadLine(&position, lineBuffer);
			switch (lineBuffer[0])
			{
				case 'v':
					vertexCount++;
					LoadObj_AddVertex(lineBuffer);
					break;
				case 'f':
					polyCount++;
					LoadObj_AddPolygon(lineBuffer);
					break;
				default:
//					printf("-- Skipping line --\n");
					break;
			}
		}
		free(buffer);
		return scene->addModel(objPosition, vertexOffset+1, vertexCount, polyOffset, polyCount);
	}
	return NULL;
}
开发者ID:NickPollard,项目名称:Manta,代码行数:40,代码来源:filemanager_model.cpp

示例10: while

bool ReplayLogger::ReadPoint(double *Time,
			     double *Latitude,
			     double *Longitude,
			     double *Altitude)
{
  TCHAR buffer[200];
/*
  // This is creating problems with the interpolator and calculations based on differential times
  // such as variometer derived from altitude differences. Probably due to vario lowpass filters.
  while(ReadLine(buffer)) {
    if(ScanBuffer(buffer, Time, Latitude, Longitude, Altitude))
      return true;
  }
  return false;
*/
  bool found=false;
  while(ReadLine(buffer) &&!found) {
    if(ScanBuffer(buffer, Time, Latitude, Longitude, Altitude))
      found=true;
  }
  return found;
}
开发者ID:Acrobot,项目名称:LK8000,代码行数:22,代码来源:ReplayLogger.cpp

示例11: while

char* FileReader::ReadFile()
{
	if (!file || file->eof())
	{
		return nullptr;
	}
	char* file = new char[1];
	file[0] = '\0';

	while (char* line = ReadLine())
	{
		char* temp = new char[strlen(file) + strlen(line) + 2];
		Copy(temp, file, strlen(file));
		Copy(temp + strlen(file), line, strlen(line));
		Copy(temp + strlen(temp), "\n", 1);
		delete[] file;
		delete[] line;
		file = temp;
	}

	return file;
}
开发者ID:TotallWAR,项目名称:compiler,代码行数:22,代码来源:FileReader.cpp

示例12: loop

void loop() {
	  //put your main code here, to run repeatedly: 
	delay(1000);
        
        //rundiagnostic();
	
        //rundiagnostic();
	utrasonic_espi.getReadings(es);
	//Serial.println(es.ultrasonic0); 
        
	printf("%d %d %d %d\n", es.ultrasonic0, es.ultrasonic90, es.ultrasonic180, es.ultrasonic270);
	
        struct Map* beliefs;
	
	beliefs = new_map();

         // debug - need to add defensive code that means function poitners are all valid prior to entry into function
	 struct Actn action = collision_avoidance_str(beliefs, 0, 0, 0, TURN_PROBABILITY);// 0% prob of turn
	 //printf("Action is 1  %d with magnitude 10 %d\n", action.c, action.m);
         if(action.c == MOVE) {
	   printf("forward %d cm\n", action.m);
         } else if(action.c == TURN) {
           printf("turn %d deg\n",action.m);
         } else if(action.c == NOP) {
           printf("NOP\n");
         } else {
           printf("dunno\n");
         }

         char inputdata[20];
         Serial.println("done\n");

         ReadLine(inputdata); 

         Serial.println("you clicked\n");

	 Serial.flush();
}
开发者ID:rsiwicki,项目名称:ecobot,代码行数:38,代码来源:bot.c

示例13: WriteLine

bool NntpConnection::AuthInfoUser(int recur)
{
    if (recur > 10)
    {
        return false;
    }

    WriteLine(BString<1024>("AUTHINFO USER %s\r\n", m_newsServer->GetUser()));

    char* answer = ReadLine(m_lineBuf, m_lineBuf.Size(), nullptr);
    if (!answer)
    {
        ReportErrorAnswer("Authorization for %s (%s) failed: Connection closed by remote host", nullptr);
        return false;
    }

    if (!strncmp(answer, "281", 3))
    {
        debug("Authorization for %s successful", GetHost());
        return true;
    }
    else if (!strncmp(answer, "381", 3))
    {
        return AuthInfoPass(++recur);
    }
    else if (!strncmp(answer, "480", 3))
    {
        return AuthInfoUser(++recur);
    }

    if (char* p = strrchr(answer, '\r')) *p = '\0'; // remove last CRLF from error message

    if (GetStatus() != csCancelled)
    {
        ReportErrorAnswer("Authorization for %s (%s) failed: %s", answer);
    }
    return false;
}
开发者ID:ta264,项目名称:nzbget,代码行数:38,代码来源:NntpConnection.cpp

示例14: iPos

int CFCMReadFile::GetNumberColums(CString szDelimiter)
{
	int nCol = 0;
	int iPos(0), iFound;
	CString szline;

	if (ReadLine(szline))
	{
		ResetFilePointer();

		// Format data: A, B, C
	
		if (szline.IsEmpty()) { return 0; }

		while ((iFound = szline.Find(szDelimiter, iPos)) != -1)
		{
			++nCol;
			iPos = iFound + 1;
		}
	}

	return (nCol + 1);
}
开发者ID:gzumpan,项目名称:fuzzy-cmeans,代码行数:23,代码来源:ReadWriteFile.cpp

示例15: ResetData

bool CFCMReadFile::ParsingTextFile(CString szDelimiter)
{
    if(!IsOpen())
    {
        return false;
    }

    CString szLine;

    ResetData();
    m_nCols = GetNumberColums(szDelimiter);

    while(!Eof())
    {
        if(ReadLine(szLine))
        {
            ++m_nRows;
            ParsingLine(szLine, szDelimiter);
        }
    };

    return true;
}
开发者ID:gzumpan,项目名称:fuzzy-cmeans,代码行数:23,代码来源:ReadWriteFile.cpp


注:本文中的ReadLine函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。