本文整理汇总了C++中LocationVector::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ LocationVector::clear方法的具体用法?C++ LocationVector::clear怎么用?C++ LocationVector::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocationVector
的用法示例。
在下文中一共展示了LocationVector::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AsmCallBack
bool AsmCallBack(MessageEnum MessageType, const string &sMessage, const LocationVector &LocationStack)
{
unsigned int i, j, Length, PreLength, OrigPreLength, CutOff, Temp, StackLength = 0, StackNumber = LocationStack.size()-1;
ostrstream sMsg;
const char *Buffer;
char DBuffer[MAX_CONSOLE_WIDTH+1];
char Space[MAX_CONSOLE_WIDTH/2+1];
memset(Space, ' ', ConsoleWidth/2);
//store the last locationstack so that we don't reprint a possibly long "From included file" list
//when the current error happens in the same file as the one we just printed.
static LocationVector LastLocation;
if(!LocationStack.empty())
{
for(i = 0; i < StackNumber; i++)
{
if(LastLocation.size() > i+1 && LocationStack[i] == LastLocation[i])
continue;
else
LastLocation.clear();
sMsg << InputList[LocationStack[i].first].c_str() << "(" << LocationStack[i].second <<"): Info: From included file:\n";
}
LastLocation = LocationStack;
StackLength = sMsg.pcount();
}
switch(MessageType)
{
case Info:
if(!LocationStack.empty())
sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "): Info: ";
break;
case Warning:
Warnings++;
if(LocationStack.empty())
throw "Empty location stack for Warning!";
sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "): Warning: ";
break;
case Error:
Errors++;
if(LocationStack.empty())
throw "Empty location stack for Error!";
sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "): Error: ";
break;
case Fatal:
Errors++;
if(!LocationStack.empty())
sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "): ";
sMsg << "Fatal: ";
break;
}
//Print the pre-message
if(LocationStack.empty())
OrigPreLength = PreLength = 0;
else
OrigPreLength = PreLength = sMsg.pcount() - StackLength;
//If the pre-message is longer than half the width of the console,
//add a newline and spaces so that it looks like the pre-message
//ended at half-width.
if(PreLength > ConsoleWidth/2)
{
sMsg << "\n";
Space[ConsoleWidth/2] = 0;
PreLength = ConsoleWidth/2;
sMsg << Space;
}
else
Space[PreLength] = 0;
Length = sMessage.size();
Buffer = sMessage.c_str();
//Check for tabs, which increases the effective length of the string
for(i = 0; Buffer[i]; i++)
if(Buffer[i] == '\t')
PreLength += CONSOLE_TAB_SIZE - 1;
//Print lines of the message
while(true)
{
//Determine where to partition this message so that it fits in the console
//The -1 is there so that there is room for the newline character.
Temp = CutOff = MIN(Length, ConsoleWidth-PreLength-1);
if(Temp != Length)
{ //Adjust the cutoff so that it doesn't break words
while(Buffer[Temp] != ' ' && Buffer[Temp] != '\n' && Buffer[Temp] != '\t' && Buffer[Temp] != '\r' && Temp > 0)
Temp--;
if(Temp > 0)
CutOff = Temp;
}
for(i = 0, j = 0; i < CutOff; i++)
{
if(Buffer[i] != '\n')
{
if(Buffer[i] == '\t')
PreLength -= CONSOLE_TAB_SIZE - 1;
DBuffer[j++] = Buffer[i];
//.........这里部分代码省略.........