本文整理汇总了C++中SourceFile::open方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::open方法的具体用法?C++ SourceFile::open怎么用?C++ SourceFile::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: semantic_error
//! \param sourceName Pointer to string containing the name of the source to look up.
//! May be NULL, in which case the default source is used.
//! \param line The line number on which the source name was located.
//!
//! \result A source file object that was previously created in the processSources()
//! stage.
//!
//! \exception std::runtime_error Thrown if the source name is invalid, or if it
//! was NULL and there is no default source (i.e., we're not inside a from
//! statement).
SourceFile * ConversionController::getSourceFromName(std::string * sourceName, int line)
{
SourceFile * sourceFile = NULL;
if (sourceName)
{
// look up source in map
source_map_t::iterator it = m_sources.find(*sourceName);
if (it == m_sources.end())
{
source_name_vector_t::const_iterator findIt = std::find<source_name_vector_t::const_iterator, std::string>(m_failedSources.begin(), m_failedSources.end(), *sourceName);
if (findIt != m_failedSources.end())
{
throw semantic_error(format_string("line %d: error opening source '%s'", line, sourceName->c_str()));
}
else
{
throw semantic_error(format_string("line %d: invalid source name '%s'", line, sourceName->c_str()));
}
}
sourceFile = it->second;
}
else
{
// no name provided - use default source
sourceFile = m_defaultSource;
if (!sourceFile)
{
throw semantic_error(format_string("line %d: source required but no default source is available", line));
}
}
// open the file if it hasn't already been
if (!sourceFile->isOpen())
{
sourceFile->open();
}
return sourceFile;
}