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


C++ fstream::get方法代码示例

本文整理汇总了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);
    }
开发者ID:icylord,项目名称:facedetect,代码行数:28,代码来源:detect.cpp

示例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;
}
开发者ID:CorinnaL,项目名称:tdeditor,代码行数:25,代码来源:Parser.cpp

示例3: getnextnonwhite

char getnextnonwhite(std::fstream &mfilestream)
{
    char c;
    mfilestream.get(c);
    while(whitespace(c))
    {
        mfilestream.get(c);
    }
    return c;
}
开发者ID:CorinnaL,项目名称:tdeditor,代码行数:10,代码来源:Parser.cpp

示例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;
    }
}
开发者ID:CorinnaL,项目名称:tdeditor,代码行数:51,代码来源:Parser.cpp

示例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';
}
开发者ID:orcchg,项目名称:CppCourse,代码行数:9,代码来源:abstract_1.cpp

示例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;
}
开发者ID:CorinnaL,项目名称:tdeditor,代码行数:13,代码来源:Parser.cpp

示例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;
}
开发者ID:brandonrogers,项目名称:Sic-XE-Disassembler,代码行数:16,代码来源:HeaderRecord.cpp

示例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;
}
开发者ID:brandonrogers,项目名称:Sic-XE-Disassembler,代码行数:19,代码来源:HeaderRecord.cpp

示例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);
}
开发者ID:watbe,项目名称:Source-2-Decompiler,代码行数:22,代码来源:keyvalues.cpp

示例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();
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:32,代码来源:fileio.cpp

示例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;
}
开发者ID:o-peregudov,项目名称:libcrs,代码行数:22,代码来源:parsing.cpp

示例12: Advance

void Scanner::Advance()
{
	cur_char_ = file_.get();
}
开发者ID:OkabeRintarou,项目名称:syl,代码行数:4,代码来源:FAO.cpp


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