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


C++ ifstream::exceptions方法代码示例

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


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

示例1: open

 /// open file for reading
 void open(const std::string& a_fname) {
     if (m_open) return;
     // make sure exception thrown in case of error
     m_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
     m_file.open(a_fname.c_str(), std::ios::in | std::ios::binary);
     // further read can set failbit in case there is not enough data
     // this case should not throw an exception in our class
     m_file.exceptions(std::ifstream::badbit);
     m_open = true;
     m_fname = a_fname;
     m_buf.reset();
     BOOST_ASSERT(m_buf.capacity() > 0);
 }
开发者ID:GHamrouni,项目名称:utxx,代码行数:14,代码来源:file_reader.hpp

示例2: ReadPicData

bool ReadPicData (std::ifstream &fdata, unsigned char *buffer, int frame_size)
{
    bool ret_stat = true;

    ios::iostate oldExceptions = fdata.exceptions();
    fdata.exceptions (ios::failbit | ios::badbit);
    try
    {
        fdata.read ((char *)buffer, frame_size);
    }
    catch (...)
    {
        ret_stat = false;
    }
    fdata.exceptions (oldExceptions);
    return ret_stat;
}
开发者ID:cheeyeo,项目名称:dirac,代码行数:17,代码来源:encmain.cpp

示例3: open

		void open(std::ifstream& stream) const {
			stream.open(m_path.c_str(), std::ios::in|std::ios::binary);
			if (!stream.is_open()) {
				LOG4CXX_ERROR(m_logger, "Couldn't open file [" << m_path << "]");
				MR4C_THROW(std::logic_error, "Couldn't open file [" << m_path << "]");
			}
			stream.exceptions(std::ifstream::badbit);
		}
开发者ID:Andy-Amoy,项目名称:mr4c,代码行数:8,代码来源:LocalDataFileSource.cpp

示例4: open

    /**
     * Opens the prt_ifstream to read from the specified file
     * @param file Path to the file to read particles from
     */
    void open( const std::string& file ) {
        m_fin.open( file.c_str(), std::ios::in | std::ios::binary );
        if( m_fin.fail() )
            throw std::ios_base::failure( "Failed to open file \"" + file + "\"" );

        m_filePath = file;
        m_fin.exceptions( std::ios::badbit );

        read_header();
        init_zlib();
    }
开发者ID:nyue,项目名称:PRT-IO-Library,代码行数:15,代码来源:prt_ifstream.hpp

示例5: runtime_error

 PolyFileReader (Boundary *b_, const string &polyfilename)
     : is (polyfilename.c_str ()),
       b (b_)
 {
     if (!is) {
         throw std::runtime_error ("Cannot open \"" +
             polyfilename + "\"");
     }
     is.exceptions (std::ios::failbit | std::ios::badbit);
     vertex_map.reserve (1000);
 }
开发者ID:mapleyustat,项目名称:papaya,代码行数:11,代码来源:readpoly.cpp

示例6: Skip

bool Skip (std::ifstream &fdata, int start_frame, int frame_size)
{
    bool ret_stat = true;
    ios::iostate oldExceptions = fdata.exceptions();
    fdata.exceptions (ios::failbit | ios::badbit);
    try
    {
       unsigned char* buffer = new unsigned char[frame_size];
       for (int i=0; i<start_frame; ++i)
       ReadPicData(fdata, buffer, frame_size);
       delete[] buffer;
    }
    catch (...)
    {
        std::cerr << "Skipping of first "<< start_frame << " frames failed"
                  << std::endl;
        ret_stat = false;
    }
    fdata.exceptions (oldExceptions);
    return ret_stat;
}
开发者ID:cheeyeo,项目名称:dirac,代码行数:21,代码来源:encmain.cpp

示例7: LoadFileToString

	void SettingsFile::LoadFileToString(std::ifstream& file, SettingsFile::StringVector& lines, const std::string& file_name)
	{
		// First, tell the file not to throw any exceptions.
		file.exceptions(std::ios_base::goodbit);
		// Now load each line from the file into a string.
		while(file.good() == true)
		{
			std::string line;
			std::getline(file, line);
			lines.push_back(line);
		}
		// If an error occurred while reading (other than reaching EOF), then throw a FileReadException.
		if(file.fail() == true && file.eof() == false)
		{
			file.close();
			throw FileReadException(file_name);
		}
	}
开发者ID:siotour,项目名称:avlEngine-old-,代码行数:18,代码来源:settings+file.cpp

示例8: OBJParser

 OBJParser(const char* filename, std::vector<glm::vec3>& positions,
                                 std::vector<glm::vec2>& texcoords,
                                 std::vector<glm::vec3>& normals,
                                 std::vector<GLuint>& position_indices,
                                 std::vector<GLuint>& texcoord_indices,
                                 std::vector<GLuint>& normal_indices)
         : filename(filename),
           positions(positions),
           texcoords(texcoords),
           normals(normals),
           position_indices(position_indices),
           texcoord_indices(texcoord_indices),
           normal_indices(normal_indices),
           ifs(filename, std::ifstream::in),
           lineno(1),
           charno(0),
           type(UNKNOWN) {
     ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
 }
开发者ID:jesajx,项目名称:experiments,代码行数:19,代码来源:obj.cpp

示例9: OpenInputStream

void WindowsFileOpener::OpenInputStream(  std::ifstream &stream, std::ios_base::openmode openModeRequired )
{
	stream.exceptions( std::ifstream::failbit | std::ifstream::badbit | std::ifstream::eofbit );
	stream.open( _filePath.c_str(), openModeRequired );
}
开发者ID:jonathan-markland,项目名称:Jynx,代码行数:5,代码来源:WindowsFileOpener.cpp


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