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


C++ Istream::read方法代码示例

本文整理汇总了C++中Istream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ Istream::read方法的具体用法?C++ Istream::read怎么用?C++ Istream::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Istream的用法示例。


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

示例1: int

unsigned char Foam::SHA1Digest::readHexDigit(Istream& is)
{
    // Takes into account that 'a' (or 'A') is 10
    static const int alphaOffset = toupper('A') - 10;
    // Takes into account that '0' is 0
    static const int zeroOffset = int('0');


    // silently ignore leading or intermediate '_'
    char c = 0;
    do
    {
        is.read(c);
    }
    while (c == '_');

    if (!isxdigit(c))
    {
        FatalIOErrorIn("SHA1Digest::readHexDigit(Istream&)", is)
            << "Illegal hex digit: '" << c << "'"
            << exit(FatalIOError);
    }

    if (isdigit(c))
    {
        return int(c) - zeroOffset;
    }
    else
    {
        return toupper(c) - alphaOffset;
    }
}
开发者ID:Kiiree,项目名称:CONSELFcae-dev,代码行数:32,代码来源:SHA1Digest.C

示例2: load_data_record

static void load_data_record(Istream& fin, const gcstring& table, int tran, int n)
	{
	try
		{
		if (n > loadbuf_size)
			{
			loadbuf_size = max(n, 2 * loadbuf_size);
			mem_release(loadbuf);
			loadbuf = (char*) mem_committed(loadbuf_size);
			verify(loadbuf);
			}
		fin.read(loadbuf, n);
		Record rec(loadbuf);
		if (rec.cursize() != n)
			except_err(table << ": rec size " << rec.cursize() << " not what was read " << n);
		if (table == "views")
			theDB()->add_any_record(tran, table, rec);
		else
			theDB()->add_record(tran, table, rec);
		}
	catch (const Except& e)
		{
		errlog("load: skipping corrupted record in: ", table.str(), e.str());
		alert("skipping corrupted record in: " << table << ": " << e);
		alerts = true;
		}
	}
开发者ID:leeeqian,项目名称:csuneido,代码行数:27,代码来源:load.cpp

示例3: ParcelType

Foam::WetParcel<ParcelType>::WetParcel
(
    const polyMesh& mesh,
    Istream& is,
    bool readFields
)
:
    ParcelType(mesh, is, readFields),
    Vliq_(0.0)
{
    if (readFields)
    {
        if (is.format() == IOstream::ASCII)
        {
            Vliq_ = readScalar(is);
        }
        else
        {
            is.read
            (
                reinterpret_cast<char*>(&Vliq_),
                sizeof(Vliq_)
            );
        }
    }

    // Check state of Istream
    is.check
    (
        "WetParcel<ParcelType>::WetParcel"
        "(const polyMesh&, Istream&, bool)"
    );
}
开发者ID:Washino,项目名称:OpenFOAM-User-Dir,代码行数:33,代码来源:WetParcelIO.C

示例4: if

bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
{
    token keywordToken;

    // Read the next valid token discarding spurious ';'s
    do
    {
        if
        (
            is.read(keywordToken).bad()
         || is.eof()
         || !keywordToken.good()
        )
        {
            return false;
        }
    }
    while (keywordToken == token::END_STATEMENT);

    // If the token is a valid keyword set 'keyword' return true...
    if (keywordToken.isWord())
    {
        keyword = keywordToken.wordToken();
        return true;
    }
    else if (keywordToken.isString())
    {
        // Enable wildcards
        keyword = keywordToken.stringToken();
        return true;
    }
    // If it is the end of the dictionary or file return false...
    else if (keywordToken == token::END_BLOCK || is.eof())
    {
        return false;
    }
    // Otherwise the token is invalid
    else
    {
        cerr<< "--> FOAM Warning : " << std::endl
            << "    From function "
            << "entry::getKeyword(keyType&, Istream&)" << std::endl
            << "    in file " << __FILE__
            << " at line " << __LINE__ << std::endl
            << "    Reading " << is.name().c_str() << std::endl
            << "    found " << keywordToken << std::endl
            << "    expected either " << token::END_BLOCK << " or EOF"
            << std::endl;

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

示例5: while

void Foam::functionEntries::ifeqEntry::readToken(token& t, Istream& is)
{
    // Skip dummy tokens - avoids entry::getKeyword consuming #else, #endif
    do
    {
        if
        (
            is.read(t).bad()
         || is.eof()
         || !t.good()
        )
        {
            return;
        }
    }
    while (t == token::END_STATEMENT);
}
开发者ID:OpenFOAM,项目名称:OpenFOAM-dev,代码行数:17,代码来源:ifeqEntry.C

示例6: load_data

static int load_data(Istream& fin, const gcstring& table)
	{
	int nrecs = 0;
	int tran = theDB()->transaction(READWRITE);
	for (;; ++nrecs)
		{
		int n;
		fin.read((char*) &n, sizeof n);
		if (fin.gcount() != sizeof n)
			except("unexpected eof");
		if (n == 0)
			break ;
		load_data_record(fin, table, tran, n);
		if (nrecs % recsPerTran == recsPerTran - 1)
			{
			verify(theDB()->commit(tran));
			tran = theDB()->transaction(READWRITE);
			}
		}
	verify(theDB()->commit(tran));
	return nrecs;
	}
开发者ID:leeeqian,项目名称:csuneido,代码行数:22,代码来源:load.cpp

示例7: readScalar

Foam::ThermoParcel<ParcelType>::ThermoParcel
(
    const Cloud<ParcelType>& cloud,
    Istream& is,
    bool readFields
)
:
    KinematicParcel<ParcelType>(cloud, is, readFields),
    T_(0.0),
    cp_(0.0),
    Tc_(0.0),
    cpc_(0.0)
{
    if (readFields)
    {
        if (is.format() == IOstream::ASCII)
        {
            T_ = readScalar(is);
            cp_ = readScalar(is);
        }
        else
        {
            is.read
            (
                reinterpret_cast<char*>(&T_),
              + sizeof(T_)
              + sizeof(cp_)
            );
        }
    }

    // Check state of Istream
    is.check
    (
        "ThermoParcel::ThermoParcel(const Cloud<ParcelType>&, Istream&, bool)"
    );
}
开发者ID:TsukasaHori,项目名称:openfoam-extend-foam-extend-3.1,代码行数:37,代码来源:ThermoParcelIO.C

示例8:

Foam::token::token(Istream& is)
:
    type_(UNDEFINED)
{
    is.read(*this);
}
开发者ID:AmaneShino,项目名称:OpenFOAM-2.0.x,代码行数:6,代码来源:tokenIO.C

示例9: append

bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
{
    is.fatalCheck
    (
        "primitiveEntry::readData(const dictionary&, Istream&)"
    );

    label blockCount = 0;
    token currToken;

    if
    (
        !is.read(currToken).bad()
     && currToken.good()
     && currToken != token::END_STATEMENT
    )
    {
        append(currToken, dict, is);

        if
        (
            currToken == token::BEGIN_BLOCK
         || currToken == token::BEGIN_LIST
        )
        {
            blockCount++;
        }

        while
        (
            !is.read(currToken).bad()
         && currToken.good()
         && !(currToken == token::END_STATEMENT && blockCount == 0)
        )
        {
            if
            (
                currToken == token::BEGIN_BLOCK
             || currToken == token::BEGIN_LIST
            )
            {
                blockCount++;
            }
            else if
            (
                currToken == token::END_BLOCK
             || currToken == token::END_LIST
            )
            {
                blockCount--;
            }

            append(currToken, dict, is);
        }
    }

    is.fatalCheck
    (
        "primitiveEntry::readData(const dictionary&, Istream&)"
    );

    if (currToken.good())
    {
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:Kiiree,项目名称:CONSELFcae-dev,代码行数:70,代码来源:primitiveEntryIO.C

示例10: ParcelType

Foam::WetParcel<ParcelType>::WetParcel
(
    const polyMesh& mesh,
    Istream& is,
    bool readFields
)
:
    ParcelType(mesh, is, readFields),
    Vliq_(0.0),
    partVliq_(),
    liquidPositionVectors_(),
    liquidPositions_(),
    contactList_(),
    previousContactList_()
{
    if (readFields)
    {
        if (is.format() == IOstream::ASCII)
        {
            Vliq_ = readScalar(is);
            partVliq_ = readList<scalar>(is);
            liquidPositions_ = readList<vector>(is);
            liquidPositionVectors_ = readList<vector>(is);
            contactList_ = readList<label>(is);
            previousContactList_ = readList<label>(is);
        }
        else
        {
        	/*
            is.read
            (
                reinterpret_cast<char*>(&Vliq_),
                sizeof(Vliq_)
            );
            is.read
            (
                reinterpret_cast<char*>(&partVliq_),
                sizeof(partVliq_)
            );
            is.read
            (
                reinterpret_cast<char*>(&liquidPositions_),
                sizeof(liquidPositions_)
            );
            is.read
            (
                reinterpret_cast<char*>(&liquidPositionVectors_),
                sizeof(liquidPositionVectors_)
            );
            */
        	is.read
            (
        	     reinterpret_cast<char*>(&Vliq_),
        	     sizeof(Vliq_)
        	    +sizeof(partVliq_)
        	    +sizeof(liquidPositionVectors_)
        	    +sizeof(liquidPositions_)
        	    +sizeof(contactList_)
        	    +sizeof(previousContactList_)
        	 );
        }
    }

    // Check state of Istream
    is.check
    (
        "WetParcel<ParcelType>::WetParcel"
        "(const polyMesh&, Istream&, bool)"
    );
}
开发者ID:miyazakiKoki,项目名称:OpenFoam,代码行数:70,代码来源:WetParcelIO.C


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