本文整理汇总了C++中processLine函数的典型用法代码示例。如果您正苦于以下问题:C++ processLine函数的具体用法?C++ processLine怎么用?C++ processLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了processLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: input
//-----------------------------------------------------------------------------------------------
// Reads the input file, generates a pressure drop calculator
//-----------------------------------------------------------------------------------------------
PressureDropCalculator* PipeReader::readFile(const QString &file_name)
{
PressureDropCalculator *calc = 0;
// opening the input file
QFile input(file_name);
// checking if file opened ok...
if(!input.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning("Could not open PIPE input file: %s", file_name.toLatin1().constData());
exit(1);
}
// starting to read the file, finding what type of calculator to produce
QStringList list = processLine(input.readLine());
while(!input.atEnd() && !list.at(0).startsWith("EOF"))
{
if(list.at(0).startsWith("CORRELATION"))
{
if(list.at(1).startsWith("BB73")) calc = readBeggsBrill(input); // this is a beggs and brill correlation
else if(list.at(1).startsWith("TABLE")) calc = readDpTable(input); // this is a table correlation
}
else if(!isEmpty(list))
{
cout << endl << "### Error detected in PIPE definition file! ###" << endl
<< "File: " << file_name.toLatin1().constData() << endl
<< "Keyword: " << list.join(" ").toLatin1().constData() << endl
<< "Not understood in current context." << endl << endl;
exit(1);
}
list = processLine(input.readLine());
}
// everything ok, closing input file
input.close();
return calc;
}
示例2: generate
void generate( options *o)
{
FILE *fileHandle = fopen( o->file, "r" );
char line[ 256 ];
if( !fileHandle )
{
perror( "Error opening the source file" );
}
else
{
assert( fileHandle );
while( fgets( line, 256, fileHandle ) )
{
count( line );
}
rewind( fileHandle );
OBJModel.vertices = calloc( OBJModel.numOfObjVertex , sizeof( vertex ) );
assert( OBJModel.vertices );
if( OBJModel.numOfObjNormal > 0 )
{
OBJModel.normals = calloc( OBJModel.numOfObjNormal , sizeof( normal ) );
assert( OBJModel.normals );
}
if( OBJModel.numOfObjNormal > 0 )
{
OBJModel.textures = calloc( OBJModel.numOfObjTex , sizeof( texture ) );
assert( OBJModel.textures );
}
OBJModel.faces = calloc( OBJModel.numOfObjFaces , sizeof( face ) );
OBJModel.indexLength = OBJModel.numOfObjFaces * 3;
OBJModel.indices = calloc( OBJModel.indexLength, sizeof( Index ) );
assert( OBJModel.faces );
assert( OBJModel.indices );
while( fgets( line, 256, fileHandle ) )
{
processLine( line );
}
generateFile( o->outputFile );
if( o->verbose )
{
printf( "Total Vertices: %i\n", OBJModel.numOfObjVertex );
printf( "Total Normals: %i\n", OBJModel.numOfObjNormal );
printf( "Total Textures: %i\n", OBJModel.numOfObjTex );
printf( "Total Index: %i\n", OBJModel.indexCount );
}
fclose( fileHandle );
}
}
示例3: readBaseFileStatus
void readBaseFileStatus(char* filename) {
FILE* file;
char line[MAXPATHLEN];
if (!(file = fopen(filename, "r"))) {
// Let's try to create the .file_status in the baseline system
fprintf(stderr, "CreateFileStatus (.file_status is missing)\n");
sprintf(line, "CreateFileStatus -d %s", dirs.working);
if (execute(line)) {
exit(-1);
}
if (!(file = fopen(filename, "r"))) {
fprintf(stderr, "Couldn't open %s and CreateFileStatus failed.\n",
filename);
exit(-1);
}
}
// The first line of the file is a comment so skip it.
if (fgets(line_buf, line_buf_size, file) == NULL) {
fprintf(stderr, "Couldn't read the first line of %s\n", filename);
exit(-1);
}
while (fgets(line_buf, line_buf_size, file) != NULL) {
processLine(line_buf);
}
if (fclose(file)) {
fprintf(stderr, "Couldn't close %s\n", filename);
exit(-1);
}
}
示例4: handleHeader
/*
* handleHeader - scan through and process header information
*/
static void handleHeader( int *start, SAREA *line )
{
int cur;
cur = 0;
if( strnicmp( helpInBuf, ":h", 2 ) == 0 ) {
for( ;; ) {
if( !mygetline() )
break;
if( strnicmp( helpInBuf, ":t", 2 ) == 0 )
break;
if( strnicmp( helpInBuf, ":eh", 3 ) == 0 )
break;
processLine( helpInBuf, helpOutBuf, cur, false );
putline( helpOutBuf, cur );
cur ++;
}
line->row = cur;
uivfill( &helpScreen, *line, AT( ATTR_NORMAL ), UiGChar[UI_SBOX_HORIZ_LINE] );
cur++;
topPos = HelpTell( helpFileHdl );
if( strnicmp( helpInBuf, ":eh", 3 ) == 0 ) {
mygetline();
}
}
*start = cur;
}
示例5: handleFooter
/*
* handleFooter - scan through and process footer information
*/
static void handleFooter( int *startline, SAREA *use, SAREA *line )
{
int start;
start = *startline;
if( strnicmp( helpInBuf, ":t", 2 ) == 0 ) {
++start; /* leave room for line */
for( ;; ) {
if( !mygetline() )
break;
if( strnicmp( helpInBuf, ":et", 3 ) == 0 )
break;
processLine( helpInBuf, helpOutBuf, start, false );
putline( helpOutBuf, start );
++start;
}
vscroll_fields( &helpTab, *use, start - use->row - use->height );
vvscroll( &helpScreen, *use, start - use->row - use->height );
use->height -= start - use->row;
line->row = use->row + use->height;
uivfill( &helpScreen, *line, AT( ATTR_NORMAL ), UiGChar[UI_SBOX_HORIZ_LINE] );
topPos = HelpTell( helpFileHdl );
}
*startline = start;
}
示例6: processLine
void KateBuildView::slotReadReadyStdErr()
{
// FIXME This works for utf8 but not for all charsets
QString l= QString::fromUtf8(m_proc->readAllStandardError());
l.remove(QLatin1Char('\r'));
m_output_lines += l;
QString tmp;
int end=0;
do {
end = m_output_lines.indexOf(QLatin1Char('\n'));
if (end < 0) break;
end++;
tmp = m_output_lines.mid(0, end);
tmp.remove(QLatin1Char('\n'));
m_buildUi.plainTextEdit->appendPlainText(tmp);
processLine(tmp);
m_output_lines.remove(0,end);
} while (1);
}
示例7: y
void CIniFile::ReadFile()
{
// Normally you would use ifstream, but the SGI CC compiler has
// a few bugs with ifstream. So ... fstream used.
fstream f;
string line;
Vector<string> iniLines;
string x = path;
string y(x.begin(), x.end());
y.assign(x.begin(), x.end());
f.open(y.c_str(), ios::in);
if(!f.fail()) // This is true if the file cannot be opened or something... in which case we don't want to read the file!
{
while(getline(f, line))
if(line.length() > 2) // Anything shorter can't be useful...
iniLines.push_back(line);
f.close();
}
lineCount = iniLines.size(); // Set our INI vector length
// Process our INI lines, will provide sensible defaults for any missing or malformed entries
for(S32 i = 0; i < lineCount; i++)
processLine(iniLines[i]);
}
示例8: while
void LR_IPC_IN::run()
{
while (!threadShouldExit())
{
char line[256] = { '\0' };
int sizeRead = 0;
bool canReadLine = true;
// parse input until we have a line, then process that line
while (!String(line).endsWithChar('\n') && !threadShouldExit())
{
auto waitStatus = waitUntilReady(true, 0);
if (waitStatus < 0)
{
canReadLine = false;
break;
}
else if (waitStatus == 0)
{
wait(100);
continue;
}
sizeRead += read(line + sizeRead, 1, false);
}
if (canReadLine)
{
String param(line);
processLine(param);
}
}
}
示例9: processFile
void processFile(char *fname, int searchincl)
{
FILE *fp;
char *pathname;
if (verbose)
printf("Processing file:%s\r\n", fname);
pathname = (char *)NULL;
fp = fopen(fname, "r");
if (!fp) {
if (searchincl) {
searchenv(fname, "INCLUDE", &pathname);
if (strlen(pathname)) {
fp = fopen(pathname, "r");
if (fp) goto j1;
}
}
printf("Can't open file <%s>\r\n", fname);
goto j2;
}
j1:
while (!feof(fp)) {
fgets(buf, sizeof(buf)/sizeof(char), fp);
processLine(buf);
}
fclose(fp);
j2:
if (pathname)
free(pathname);
}
示例10: processLine
/*
* scans a char* buffer for lines that does not
* start with the specified comment character.
*/
bool AnyOption::consumeFile (char *buffer) {
if (buffer == NULL)
return false;
char *cursor = buffer; /* preserve the ptr */
char *pline = NULL;
int linelength = 0;
bool newline = true;
for (unsigned int i = 0; i < strlen (buffer); i++) {
if (*cursor == endofline) { /* end of line */
if (pline != NULL) /* valid line */
processLine (pline, linelength);
pline = NULL;
newline = true;
} else if (newline) { /* start of line */
newline = false;
if ((*cursor != comment)) { /* not a comment */
pline = cursor;
linelength = 0;
}
}
cursor++; /* keep moving */
linelength++;
}
free (buffer);
return true;
}
示例11: QFile
GaussianFchk::GaussianFchk(const QString &filename, BasisSet* basis)
{
// Open the file for reading and process it
QFile* file = new QFile(filename);
QtIOCompressor* compressedFile = 0;
if (filename.endsWith(".gz")) {
compressedFile = new QtIOCompressor(file);
compressedFile->setStreamFormat(QtIOCompressor::GzipFormat);
compressedFile->open(QIODevice::ReadOnly);
m_in = compressedFile;
}
else {
file->open(QIODevice::ReadOnly | QIODevice::Text);
m_in = file;
}
qDebug() << "File" << filename << "opened.";
// Process the formatted checkpoint and extract all the information we need
while (!m_in->atEnd()) {
processLine();
}
// Now it should all be loaded load it into the basis set
load(basis);
if (compressedFile)
delete compressedFile;
else
delete file;
}
示例12: at_send_command_to_data_channel
int at_send_command_to_data_channel(const char *command, ATResponse **pp_outResponse, RILChannelCtx *p_channel) {
const char* line = NULL;
int ret = writeline(command, p_channel);
if (ret == 0) {
p_channel->p_response = at_response_new();
do {
line = readline(p_channel);
if (line != NULL)
RLOGI("readline: %s", line);
else
RLOGI("readline: EMPTY");
} while (line != NULL && !(strcmp(line, "OK") == 0 || strcmp(line, "NO CARRIER") == 0 || strStartsWith(line, "CONNECT") == 1 || strstr(line, "ERROR")));
if (line != NULL) {
RLOGI("process line: %s", line);
processLine(line, p_channel);
if (pp_outResponse == NULL) {
at_response_free(p_channel->p_response);
} else {
reverseIntermediates(p_channel->p_response);
*pp_outResponse = p_channel->p_response;
}
return 0;
}
}
return AT_ERROR_GENERIC;
}
示例13: file
/**
* Scan and process a configuration file, and store the retrieved
* configuration values into the PortageSettings object.
*
* @param settings The PortageSettings object that will be filled
* with configuration values.
* @param filename Path of the configuration file.
*
* @return PortageLoaderBase::NoError if the file has successfully been handled.
* PortageLoaderBase::OpenFileError if there was an error opening the file.
* PortageLoaderBase::NullObjectError if the given settings object is NULL.
*/
PortageLoaderBase::Error FileMakeConfigLoader::loadFile(
PortageSettings* settings, const QString& filename )
{
// Check on a NULL settings object, which would be bad
if( settings == NULL )
return NullObjectError;
else
this->settings = settings;
// Open the file for reading
QFile file( filename );
if( !file.open( IO_ReadOnly ) ) {
return OpenFileError;
}
QString line;
QTextStream stream( &file );
// Process each line
while ( !stream.atEnd() )
{
line = stream.readLine();
if( line.isEmpty() == true )
continue;
processLine( line );
}
return NoError;
}
示例14: processPacket
/*
* Processes a packet of data that supposedly contains an HTTP request
* This function looks for CR/LF (or just LF) and calls processLine
* with each line of data found.
*/
boolean processPacket(char* data, int len) {
// Address after the last byte of data
char* end = data + len;
// Start of current line
char* start = data;
// Scan through the bytes in the packet looking for a Line Feed character
while (data < end) {
if (*data == LF) {
// Determine the length of the line excluding the Line Feed
int lineLength = data - start;
if (*(data - 1) == CR) {
lineLength--;
}
*(start + lineLength) = 0;
// Process the line
if (processLine(start, lineLength)) {
return true;
}
// Set up for the start of the next line
start = ++data;
} else {
// Go to the next byte
data++;
}
}
return false;
}
示例15: lastSurf
ConfigHandler::ConfigHandler()
: lastSurf(0)
{
//check to see whether config file exists
QDir home = QDir().home();
QFile configFile;
QDir::setCurrent(home.path());
configFile.setFileName(".cangjie");
if(configFile.exists())
{
//read it
configFile.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream config(&configFile);
QString line(config.readLine());
while(!line.isNull())
{
processLine(line);
line = config.readLine();
}
}
else
{
//make it
configFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream config(&configFile);
config << "lastSurf=0\n";
configFile.close();
}
}