本文整理汇总了C++中std::fstream::get方法的典型用法代码示例。如果您正苦于以下问题:C++ fstream::get方法的具体用法?C++ fstream::get怎么用?C++ fstream::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::fstream
的用法示例。
在下文中一共展示了fstream::get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static bool loadY4MHeader(std::fstream& fs, cv::Mat &img)
{
fs.seekg(fs.beg);
if (fs.good())
{
char inbuf [256];
fs >> inbuf;
if (strcmp(inbuf, "YUV4MPEG2") != 0)
{
return false;
}
fs.get(); // space
int width, height;
char c = fs.get();
if (c != 'W')
{
return false;
}
fs >> width;
c = fs.get();// space
c = fs.get();
if (c != 'H')
{
return false;
}
fs >> height;
img.create(height * 3 / 2, width, CV_8UC1);
}
示例2: parseShotTypeList
std::set<wxString> parseShotTypeList(std::fstream &mfilestream)
{
char c;
std::set<wxString> types;
std::string shottypename;
c = getnextnonwhite(mfilestream);
if(c!='{') throw parseerror::missing_opening_bracket;
while(whitespace(mfilestream.peek()))
{
c=mfilestream.get();
}
if(mfilestream.peek() == '}')
{
mfilestream.get();
return types;
}
while(c!='}')
{
shottypename = extractQuotedPrefix(mfilestream);
types.insert(shottypename);
c = getnextnonwhite(mfilestream);
if(c!=',' && c!='}') throw parseerror::missing_comma;
}
return types;
}
示例3: getnextnonwhite
char getnextnonwhite(std::fstream &mfilestream)
{
char c;
mfilestream.get(c);
while(whitespace(c))
{
mfilestream.get(c);
}
return c;
}
示例4: extractQuotedPrefix
std::string extractQuotedPrefix(std::fstream &mfilestream)
{
char c;
c = getnextnonwhite(mfilestream);
if(c!='\"')
{
throw parseerror::no_leading_quote;
}
else
{
mfilestream.get(c);
std::string output;
bool escaped = false;
bool stringmfinished = false;
while(!stringmfinished)
{
output+=c;
if(mfilestream.eof())
{
throw parseerror::no_finishing_quote;
}
mfilestream.get(c);
if(c=='\\')
{
if(escaped)
{
escaped = false;
}
else
{
escaped = true;
}
}
else if(c =='\"')
{
if(escaped)
{
escaped = false;
}
else stringmfinished = true;
}
else
{
escaped = false;
}
}
return output;
}
}
示例5: processData
void FileReader::processData() {
DBG("File: processing data...");
int offset = 0;
char ch;
while (offset < SIZE && m_fs.get(ch)) {
m_data[offset++] = ch;
}
m_data[offset] = '\0';
}
示例6: extractNumber
std::string extractNumber(std::fstream &mfilestream)
{
char c;
std::string entry;
do
{
mfilestream.get(c);
entry+=c;
c = mfilestream.peek();
}
while (c!=','&&c!='}'&&c!=')');
return entry;
}
示例7: setProgName
// sets the prog name. Requires a file pointer. Extracts exactly six characters
// from fstream
void HeaderRecord::setProgName(std::fstream & file) {
int i;
// get 6 characters and append them to the progName string
for (i = 0; i < 6; i++) {
// needs a string argument for append()
char tempChar = file.get();
// error handler, check for eof bit
Record::unexpectedEOF(file);
// append to string
progName += tempChar;
}
std::cout << "Program name: " + progName;
}
示例8: setProgStart
// gets column 8-13 in header record setting the prog start address
void HeaderRecord::setProgStart(std::fstream & file) {
int i = 0;
// get 6 characters, convert them to ints, and multiply to get their
// significant places
for (i = 0x100000; i > 0x00; i = i / 0x10) {
int hexVal;
char tempChar;
tempChar = file.get();
// check for error, unexpected eof
Record::unexpectedEOF(file);
hexVal = ASCIItoHEX(tempChar);
hexVal *= i;
// adds values starting at MSB position and moving right each
// iteration
progStart += hexVal;
}
std::cout << " Program start address: " << progStart;
}
示例9: ReadOffsetString
//ReadOffsetString
// Reads in the next 4 bytes as an offset to a zero-terminated string value, then
// allocates and fills in the provided string with that value.
void ReadOffsetString(std::fstream& f, char*& sz)
{
int32_t i;
char szBuffer[4];
f.read(szBuffer, 4);
if (*(int32_t*)szBuffer == 0)
sz = NULL;
else
{
f.seekg(*(int32_t*)szBuffer - 4, ios::cur);
for (i = 0; f.get() != '\0'; ++i);
f.seekg(-(i + 1), ios::cur);
sz = new char[i + 1];
f.read(sz, i);
sz[i] = '\0';
}
f.seekg(4 - *(int32_t*)szBuffer - i, ios::cur);
}
示例10: ReadLine
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Reads a line from a fstream adding it to a string, reading up
/// to a newline character.
///
/// \param[in] str File stream operator.
/// \param[out] line Line read from file (doesn't include carriage return).
///
/// \return Number of characters read.
///
////////////////////////////////////////////////////////////////////////////////////
unsigned int FileIO::ReadLine(std::fstream& str,
std::string& line)
{
char ch;
line.reserve(512);
line.clear();
while(str.eof() == false && str.good())
{
str.get(ch);
if(ch == '\n')
{
break;
}
else
{
line.push_back(ch);
}
}
return (unsigned int)line.size();
}
示例11: search_forward
std::streampos search_forward ( std::fstream & _bs, const std::string & sample )
{
size_t match ( 0 );
cSaveIStreamPosition ip ( &_bs );
streampos result ( static_cast<streampos>( -1 ) );
cSaveStreamExceptions se ( &_bs, std::ios_base::goodbit );
for( int ch( EOF ); match < sample.length(); match++ )
{
ch = _bs.get();
if( ch == EOF )
break;
else if( ch != sample[match] )
match = 0;
}
if( match == sample.length() )
result = _bs.tellg() - static_cast<streampos>( match );
_bs.clear();
return result;
}
示例12: Advance
void Scanner::Advance()
{
cur_char_ = file_.get();
}