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


C++ IFstream类代码示例

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


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

示例1: while

// Read up to line starting with cmd. Sets args to rest of line.
// Returns true if found, false if stream is not good anymore.
bool Foam::fileFormats::AC3DsurfaceFormatCore::cueTo
(
    IFstream& is,
    const string& cmd,
    string& args
)
{
    while (is.good())
    {
        string line;
        is.getLine(line);

        string::size_type space = line.find(' ');

        if (space != string::npos)
        {
            if (line.substr(0, space) == cmd)
            {
                args = line.substr(space+1);

                return true;
            }
        }
    }
    return false;
}
开发者ID:BarisCumhur,项目名称:OpenFOAM-dev,代码行数:28,代码来源:AC3DsurfaceFormatCore.C

示例2: readTag

// Reads past -1 and reads element type
label readTag(IFstream& is)
{
    string tag;
    do
    {
        if (!is.good())
        {
            return -1;
        }

        string line;

        is.getLine(line);

        if (line.size() < 6)
        {
            return -1;
        }

        tag = line.substr(0, 6);

    } while (tag == SEPARATOR);

    return readLabel(IStringStream(tag)());
}
开发者ID:Brzous,项目名称:WindFOAM,代码行数:26,代码来源:ideasUnvToFoam.C

示例3: abort

bool Foam::meshReaders::STARCD::readHeader(IFstream& is, word fileSignature)
{
    if (!is.good())
    {
        FatalErrorInFunction
            << abort(FatalError);
    }

    word header;
    label majorVersion;

    is >> header;
    is >> majorVersion;

    // skip the rest of the line
    readToNewline(is);

    // add other checks ...
    if (header != fileSignature)
    {
        Info<< "header mismatch " << fileSignature << "  " << is.name()
            << endl;
    }

    return true;
}
开发者ID:qyzeng,项目名称:OpenFOAM-dev,代码行数:26,代码来源:STARCDMeshReader.C

示例4: while

// Reads points section. Read region as well?
void readPoints
(
    IFstream& is,
    DynamicList<point>& points,     // coordinates
    DynamicList<label>& unvPointID  // unv index
)
{
    Sout<< "Starting reading points at line " << is.lineNumber() << '.' << endl;

    static bool hasWarned = false;

    while (true)
    {
        string line;
        is.getLine(line);

        label pointI = readLabel(IStringStream(line.substr(0, 10))());

        if (pointI == -1)
        {
            break;
        }
        else if (pointI != points.size()+1 && !hasWarned)
        {
            hasWarned = true;

            IOWarningIn
            (
                "readPoints(IFstream&, label&, DynamicList<point>"
                ", DynamicList<label>&)",
                is
            )   << "Points not in order starting at point " << pointI
                //<< " at line " << is.lineNumber()
                //<< abort(FatalError);
                << endl;
        }

        point pt;
        is.getLine(line);
        pt[0] = readUnvScalar(line.substr(0, 25));
        pt[1] = readUnvScalar(line.substr(25, 25));
        pt[2] = readUnvScalar(line.substr(50, 25));

        unvPointID.append(pointI);
        points.append(pt);
    }

    points.shrink();
    unvPointID.shrink();

    Sout<< "Read " << points.size() << " points." << endl;
}
开发者ID:Brzous,项目名称:WindFOAM,代码行数:53,代码来源:ideasUnvToFoam.C

示例5: while

Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment
(
    IFstream& is
)
{
    string line;
    do
    {
        is.getLine(line);
    }
    while ((line.empty() || line[0] == '#') && is.good());

    return line;
}
开发者ID:TsukasaHori,项目名称:openfoam-extend-foam-extend-3.1,代码行数:14,代码来源:surfaceFormatsCore.C

示例6: skipSection

// Skip
void skipSection(IFstream& is)
{
    Info<< "Skipping section at line " << is.lineNumber() << '.' << endl;

    string line;

    while (is.good())
    {
        is.getLine(line);

        if (isSeparator(line))
        {
            break;
        }
    }
}
开发者ID:OpenFOAM,项目名称:OpenFOAM-dev,代码行数:17,代码来源:ideasUnvToFoam.C

示例7: skipSection

// Skips till end of section. Returns false if end of file.
bool skipSection(IFstream& inFile)
{
    string line;
    do
    {
        inFile.getLine(line);

        if (!inFile.good())
        {
            return false;
        }
    }
    while (line.size() < 4 || line.substr(0, 4) != "$End");

    return true;
}
开发者ID:ADGlassby,项目名称:OpenFOAM-2.2.x,代码行数:17,代码来源:gmshToFoam.C

示例8: readToNl

void starMesh::readToNl(IFstream& is)
{
    char c;
    do
    {
        is.get(c);
    } while (is && c != '\n');
}
开发者ID:GoldenMan123,项目名称:openfoam-extend-foam-extend-3.1,代码行数:8,代码来源:readPoints.C

示例9: readHeader

// Reads and prints header
void readHeader(IFstream& is)
{
    string line;

    while (is.good())
    {
        is.getLine(line);

        if (isSeparator(line))
        {
            break;
        }
        else
        {
            Sout<< line << endl;
        }
    }
}
开发者ID:Brzous,项目名称:WindFOAM,代码行数:19,代码来源:ideasUnvToFoam.C

示例10: readCmd

static bool readCmd(IFstream& ACfile, string& cmd, string& args)
{
    if (ACfile.good())
    {
        string line;
        ACfile.getLine(line);

        string::size_type space = line.find(' ');

        if (space != string::npos)
        {
            cmd  = line.substr(0, space);
            args = line.substr(space+1);

            return true;
        }
    }
    return false;
}
开发者ID:0184561,项目名称:OpenFOAM-2.1.x,代码行数:19,代码来源:readAC.C

示例11: IFstream

Foam::Istream* Foam::IOobject::objectStream(const fileName& fName)
{
    if (fName.size())
    {
        IFstream* isPtr = new IFstream(fName);

        if (isPtr->good())
        {
            return isPtr;
        }
        else
        {
            delete isPtr;
            return NULL;
        }
    }
    else
    {
        return NULL;
    }
}
开发者ID:ADGlassby,项目名称:OpenFOAM-2.2.x,代码行数:21,代码来源:IOobject.C

示例12: units

// Reads unit section
void readUnits
(
    IFstream& is,
    scalar& lengthScale,
    scalar& forceScale,
    scalar& tempScale,
    scalar& tempOffset
)
{
    Sout<< "Starting reading units at line " << is.lineNumber() << '.' << endl;

    string line;
    is.getLine(line);

    label l = readLabel(IStringStream(line.substr(0, 10))());
    Sout<< "l:" << l << endl;

    string units(line.substr(10, 20));
    Sout<< "units:" << units << endl;

    label unitType = readLabel(IStringStream(line.substr(30, 10))());
    Sout<< "unitType:" << unitType << endl;

    // Read lengthscales
    is.getLine(line);

    lengthScale = readUnvScalar(line.substr(0, 25));
    forceScale = readUnvScalar(line.substr(25, 25));
    tempScale = readUnvScalar(line.substr(50, 25));

    is.getLine(line);
    tempOffset = readUnvScalar(line.substr(0, 25));

    Sout<< "Unit factors:" << nl
        << "    Length scale       : " << lengthScale << nl
        << "    Force scale        : " << forceScale << nl
        << "    Temperature scale  : " << tempScale << nl
        << "    Temperature offset : " << tempOffset << nl
        << endl;
}
开发者ID:Brzous,项目名称:WindFOAM,代码行数:41,代码来源:ideasUnvToFoam.C

示例13: readVtxCmpt

scalar starMesh::readVtxCmpt(IFstream& is)
{
    char lcs[17];

    for (int i=0; i<16; i++)
    {
        is.get(lcs[i]);
    }

    lcs[16] = '\0';

    return scalar(atof(lcs));
}
开发者ID:GoldenMan123,项目名称:openfoam-extend-foam-extend-3.1,代码行数:13,代码来源:readPoints.C

示例14: readVtxLabel

label starMesh::readVtxLabel(IFstream& is)
{
    char lcs[16];

    for (int i=0; i<15; i++)
    {
        is.get(lcs[i]);
    }

    lcs[15] = '\0';

    return atoi(lcs);
}
开发者ID:GoldenMan123,项目名称:openfoam-extend-foam-extend-3.1,代码行数:13,代码来源:readPoints.C

示例15: while

// Read up to line starting with cmd. Sets args to rest of line.
// Returns true if found, false if stream is not good anymore.
static bool readUpto
(
    const string& cmd,
    IFstream& ACfile,
    string& args
)
{
    while (ACfile.good())
    {
        string line;
        ACfile.getLine(line);

        string::size_type space = line.find(' ');

        if (space != string::npos && line.substr(0, space) == cmd)
        {
            args = line.substr(space+1);
            return true;
        }
    }
    return false;
}
开发者ID:0184561,项目名称:OpenFOAM-2.1.x,代码行数:24,代码来源:readAC.C


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