本文整理汇总了C++中idStr::ExtractFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ idStr::ExtractFilePath方法的具体用法?C++ idStr::ExtractFilePath怎么用?C++ idStr::ExtractFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idStr
的用法示例。
在下文中一共展示了idStr::ExtractFilePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_LoadPreprocessed
static idStr R_LoadPreprocessed( const idStr& filename, idList<idStr>& previoulsyLoadedFiles, idList<idStr>& includeStack ) {
includeStack.Append( filename );
previoulsyLoadedFiles.Append( filename );
const int fileIndex = previoulsyLoadedFiles.Num() - 1;
idStr content = R_ReadFile(filename.c_str());
idStr ret;
fhStrRef ptr = fhStrRef( content.c_str(), content.Length() );
fhStrRef remaining = ptr;
int currentLine = 1;
int currentColumn = 1;
bool isLineComment = false;
for (; !ptr.IsEmpty(); ++ptr) {
if (ptr[0] == '\n') {
++currentLine;
currentColumn = 1;
isLineComment = false;
continue;
}
if (isLineComment) {
continue;
}
if (ptr.StartsWith( "//" )) {
isLineComment = true;
continue;
}
static const fhStrRef includeDirective = "#include \"";
if (currentColumn == 1 && ptr.StartsWith( includeDirective )) {
fhStrRef includeFilename = ptr.Substr( includeDirective.Length() );
for (int i = 0; i < includeFilename.Length() + 1; ++i) {
if (i == includeFilename.Length())
throw fhParseException( filename, currentLine, currentColumn, "unexpected end-of-file in preprocessor include" );
if (includeFilename[i] == '\n')
throw fhParseException( filename, currentLine, currentColumn, "unexpected end-of-line in preprocessor include" );
if (includeFilename[i] == '"') {
includeFilename = includeFilename.Substr( 0, i );
break;
}
}
if (includeFilename.IsEmpty())
throw fhParseException( filename, currentLine, currentColumn, "empty filename in preprocessor include" );
if (includeStack.FindIndex( includeFilename.ToString() ) >= 0)
throw fhParseException( filename, currentLine, currentColumn, "circular preprocessor include" );
idStr includeContent;
//try to load included shader relative to current file. If that fails try to load included shader from root directory.
try {
idStr includeFilePath;
filename.ExtractFilePath(includeFilePath);
includeFilePath.AppendPath( includeFilename.c_str(), includeFilename.Length() );
includeContent = R_LoadPreprocessed( includeFilePath, previoulsyLoadedFiles, includeStack );
ret.Append( remaining.c_str(), ptr.c_str() - remaining.c_str() );
ret.Append( includeContent );
//ret.Append( "\n#line " + toString( currentLine + 1 ) + " \"" + filename + "\"" );
} catch (const fhFileNotFoundException& e) {
try {
includeContent = R_LoadPreprocessed( includeFilename.ToString(), previoulsyLoadedFiles, includeStack );
ret.Append( remaining.c_str(), ptr.c_str() - remaining.c_str() );
ret.Append( includeContent );
//ret.append( "\n#line " + ToString( currentLine + 1 ) + " \"" + filename + "\"" );
} catch (const fhFileNotFoundException& e) {
throw fhParseException( filename, currentLine, currentColumn, idStr( "include file not found: " ) + includeFilename.ToString() );
}
}
//skip rest of the line
while (!ptr.IsEmpty() && ptr[0] != '\n') {
++ptr;
}
++currentLine;
currentColumn = 1;
remaining = ptr;
continue;
}
currentColumn++;
}
ret.Append( remaining.ToString() );
includeStack.RemoveIndex(includeStack.Num() - 1);
return ret;
}