本文整理汇总了C++中BFFIterator::GetPosInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ BFFIterator::GetPosInfo方法的具体用法?C++ BFFIterator::GetPosInfo怎么用?C++ BFFIterator::GetPosInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFFIterator
的用法示例。
在下文中一共展示了BFFIterator::GetPosInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormatError
// FormatError
//------------------------------------------------------------------------------
void Error::FormatError( const BFFIterator & iter,
uint32_t errNum,
const Function * function,
const char * message, ... )
{
ASSERT( message );
AStackString< 4096 > buffer;
va_list args;
va_start(args, message);
buffer.VFormat( message, args );
va_end( args );
// get human readable info about the position of the error
uint32_t line = 0;
uint32_t column = 0;
const char * lineStart = nullptr;
iter.GetPosInfo( line, column, lineStart );
// convert to full path and '/'->'\' cleanup
const AStackString<> fileName( iter.GetFileName() );
AStackString<> fullPath;
NodeGraph::CleanPath( fileName, fullPath );
// deliberately using OUTPUT here to avoid "Error:" in front
OUTPUT( "%s(%u,%u): FASTBuild Error #%04u - %s%s%s\n",
fullPath.Get(),
line,
column,
errNum,
function ? function->GetName().Get() : "",
function ? "() - " : "",
buffer.Get() );
// find the line end
BFFIterator lineEnd( iter );
while ( !lineEnd.IsAtEnd() )
{
if (( *lineEnd != '\r' ) && ( *lineEnd != '\n' ))
{
lineEnd++;
continue;
}
break;
}
// if line is too crazy to be useful, don't print anything more
size_t lineLength = lineEnd.GetCurrent() - lineStart;
if ( lineLength >= 256 )
{
return;
}
// print the problematic line
AString::Copy( lineStart, buffer.Get(), lineLength );
FLOG_ERROR( "%s", buffer.Get() );
// point to the specific pos where parsing broke
// (taking into account tabs)
char * c = buffer.Get();
const char * end = c + column - 1;
for ( ; c < end; ++c )
{
if ( *c != '\t' )
{
*c = ' ';
}
}
AString::Copy( "^", c, 1 );
FLOG_ERROR( buffer.Get() );
AString::Copy( "\\--here", c, 8 );
FLOG_ERROR( buffer.Get() );
}