本文整理汇总了C++中Istream类的典型用法代码示例。如果您正苦于以下问题:C++ Istream类的具体用法?C++ Istream怎么用?C++ Istream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Istream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextToken
Foam::autoPtr<Foam::entry> Foam::entry::New(Istream& is)
{
is.fatalCheck("entry::New(Istream&)");
keyType keyword;
// Get the next keyword and if invalid return false
if (!getKeyword(keyword, is))
{
return autoPtr<entry>(NULL);
}
else // Keyword starts entry ...
{
token nextToken(is);
is.putBack(nextToken);
if (nextToken == token::BEGIN_BLOCK)
{
return autoPtr<entry>
(
new dictionaryEntry(keyword, dictionary::null, is)
);
}
else
{
return autoPtr<entry>
(
new primitiveEntry(keyword, is)
);
}
}
}
示例2: if
void Foam::functionEntries::ifeqEntry::skipUntil
(
DynamicList<filePos>& stack,
const dictionary& parentDict,
const word& endWord,
Istream& is
)
{
while (!is.eof())
{
token t;
readToken(t, is);
if (t.isWord())
{
if (t.wordToken() == "#if" || t.wordToken() == "#ifeq")
{
stack.append(filePos(is.name(), is.lineNumber()));
skipUntil(stack, parentDict, "#endif", is);
stack.remove();
}
else if (t.wordToken() == endWord)
{
return;
}
}
}
FatalIOErrorInFunction(parentDict)
<< "Did not find matching " << endWord << exit(FatalIOError);
}
示例3: t
// from Istream
blockDescriptor::blockDescriptor
(
const pointField& blockMeshPoints,
const curvedEdgeList& edges,
Istream& is
)
:
blockMeshPoints_(blockMeshPoints),
blockShape_(is),
curvedEdges_(edges),
edgePoints_(12),
edgeWeights_(12),
n_(),
expand_(12),
zoneName_()
{
// Look at first token
token t(is);
is.putBack(t);
// Optional zone name
if (t.isWord())
{
zoneName_ = t.wordToken();
// Consume zoneName token
is >> t;
// New look-ahead
is >> t;
is.putBack(t);
}
示例4: tokenIndex
void Foam::primitiveEntry::readEntry(const dictionary& dict, Istream& is)
{
label keywordLineNumber = is.lineNumber();
tokenIndex() = 0;
if (read(dict, is))
{
setSize(tokenIndex());
tokenIndex() = 0;
}
else
{
std::ostringstream os;
os << "ill defined primitiveEntry starting at keyword '"
<< keyword() << '\''
<< " on line " << keywordLineNumber
<< " and ending at line " << is.lineNumber();
SafeFatalIOErrorIn
(
"primitiveEntry::readEntry(const dictionary&, Istream&)",
is,
os.str()
);
}
}
示例5: 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)"
);
}
示例6: codeDict
bool Foam::functionEntries::codeStream::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
Info<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
return true;
}
示例7: thermoParcelInjectionData
Foam::reactingParcelInjectionData::reactingParcelInjectionData(Istream& is)
:
thermoParcelInjectionData(is)
{
is.check("reading Y's");
is >> Y_;
is.check("reactingParcelInjectionData(Istream& is)");
}
示例8: kinematicParcelInjectionData
Foam::thermoParcelInjectionData::thermoParcelInjectionData(Istream& is)
:
kinematicParcelInjectionData(is)
{
is.check("reading T");
is >> T_;
is.check("reading cp");
is >> cp_;
is.check("thermoParcelInjectionData(Istream& is)");
}
示例9: while
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;
}
}
示例10: nextToken
void Foam::dimensioned<Type>::initialize(Istream& is)
{
token nextToken(is);
is.putBack(nextToken);
// Check if the original format is used in which the name is provided
// and reset the name to that read
if (nextToken.isWord())
{
is >> name_;
is >> nextToken;
is.putBack(nextToken);
}
示例11: entry
Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
:
entry(key),
ITstream
(
is.name() + '.' + key,
tokenList(10),
is.format(),
is.version()
)
{
readEntry(dictionary::null, is);
}
示例12: firstToken
void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
{
is.fatalCheck("HashPtrTable<T, Key, Hash>::read(Istream&, const INew&)");
token firstToken(is);
is.fatalCheck
(
"HashPtrTable<T, Key, Hash>::read(Istream&, const INew&) : "
"reading first token"
);
if (firstToken.isLabel())
{
label s = firstToken.labelToken();
// Read beginning of contents
char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
if (s)
{
if (2*s > this->tableSize_)
{
this->resize(2*s);
}
if (delimiter == token::BEGIN_LIST)
{
for (label i=0; i<s; i++)
{
Key key;
is >> key;
this->insert(key, inewt(key, is).ptr());
is.fatalCheck
(
"HashPtrTable<T, Key, Hash>::"
"read(Istream&, const INew&) : reading entry"
);
}
}
else
{
FatalIOErrorIn
(
"HashPtrTable<T, Key, Hash>::read(Istream&, const INew&)",
is
) << "incorrect first token, '(', found " << firstToken.info()
<< exit(FatalIOError);
}
}
示例13: specie
Foam::incompressible::incompressible(Istream& is)
:
specie(is),
rho_(readScalar(is))
{
is.check("incompressible::incompressible(Istream& is)");
}
示例14: 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;
}
}
示例15: toupper
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;
}
}