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


C++ TStringList::at方法代码示例

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


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

示例1: ReadArgText

//***************************************************
void Logic::ReadArgText()
 // do not use for string - does not take quotes into account
{
  string::size_type pos1,pos2;

  SkipSpaces();
  pos1 = pos2 = LinePos;

  if(LowerCaseLine[pos1]=='"'){
    ArgText = "\""+ReadString(&pos2,LowerCaseLine)+"\"";
    pos2 = LowerCaseLine.find_first_of(",)",pos2);
  }
  else{
    pos2 = LowerCaseLine.find_first_of(",)",pos1);
  }
  if(pos2==string::npos){
    LinePos=LineLength;
    ArgText = ReplaceDefine(TrimEndWhitespaces(
      EditLines.at(CurLine).substr(pos1)));
  }
  else{
    LinePos=pos2;
    ArgText = ReplaceDefine(TrimEndWhitespaces(
      EditLines.at(CurLine).substr(pos1,pos2-pos1)));
  }

  LowerCaseArgText = ArgText;
  toLower(&LowerCaseArgText);
  ArgTextLength = ArgText.length();
  ArgTextPos=0;
}
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:32,代码来源:logcompile.cpp

示例2: ShowError

//*************************************************
void Logic::ShowError(int Line, string ErrorMsg)
{

  int LineNum = RealLineNum[Line];
  if(LineFile[Line] == 0 || Line > EditLines.num){
    // error is in logic in editor window
    sprintf(tmp,"Line %d: %s\n",RealLineNum[Line],ErrorMsg.c_str());
  }
  else{ //error in include file
    if (LineFile[Line] > IncludeFilenames.num){
      sprintf(tmp,"[unknown include file] Line ???: %s\n",ErrorMsg.c_str());
    }
    else{
      sprintf(tmp,"File %s Line %d: %s\n",IncludeFilenames.at(LineFile[Line]-1).c_str(),LineNum,ErrorMsg.c_str());
    }
  }

  ErrorList.append(tmp);
  ErrorOccured=true;

}
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:22,代码来源:logcompile.cpp

示例3: NextLine

//***************************************************
void Logic::NextLine()
{

  int NumLines = EditLines.num;

  CurLine++;
  if(CurLine>NumLines){
    FinishedReading = true;
    return;
  }
  do{
    LowerCaseLine = EditLines.at(CurLine);
    if(LowerCaseLine == empty_tmp || (LinePos=LowerCaseLine.find_first_not_of(" ")) == string::npos){
      CurLine++;
      continue;
    }
    //printf("Line %d: %s\n",CurLine,LowerCaseLine.c_str());
    toLower(&LowerCaseLine);
    LineLength = LowerCaseLine.length();
    return;
  }while(CurLine<NumLines);
  FinishedReading = true;

}
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:25,代码来源:logcompile.cpp

示例4: RemoveComments

//***************************************************
int Logic::RemoveComments(TStringList Lines)
{
  int CommentDepth = 0;
  for(CurLine=0;CurLine<Lines.num;CurLine++){
    string Line = Lines.at(CurLine);
    string NewLine;
    bool InQuotes = false;
    for ( unsigned i=0; i<Line.size(); ++i ){
      if ( !InQuotes ){
        if (CommentDepth==0 && Line[i] == '[')
          break;
        if (i<Line.size()-1){
          if (CommentDepth==0 && Line.substr(i,2) == "//")
            break;
          else if ( Line.substr(i,2) == "/*"){
            ++CommentDepth;
            ++i;
            continue;
          }
        }
        else if (CommentDepth>0 && Line.substr(i,2) == "*/" ){
          --CommentDepth;
          ++i;
          continue;
        }
      }
      if ( CommentDepth == 0 ){
        if(Line[i]=='\"' && (i==0 || Line[i-1] != '\\'))
          InQuotes = !InQuotes;
        NewLine += Line[i];
      }
    }
    Lines.replace(CurLine,NewLine);
  }
  return 0;
}
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:37,代码来源:logcompile.cpp

示例5: AddSpecialSyntax

//***************************************************
bool Logic::AddSpecialSyntax()
{
  int arg1,arg2,arg3;
  bool arg2isvar=false,arg3isvar=false,arg2isstar=false;
  string ArgText="",expr,expr2;
  int OldLinePos;

  OldLinePos = LinePos;
  LinePos -= CommandName.length();
  if(CommandName[0]=='*'){
    LinePos++;
    ArgText = "*" + ReplaceDefine(ReadPlainText());
  }
  else ArgText = ReplaceDefine(ReadPlainText());

  if(ArgText[0]=='v'){

    arg1 = Val(ArgText.substr(1));
    if(arg1<0 || arg1>255)
      ShowError(CurLine,"Invalid number given or error in expression syntax.");
    else{
      SkipSpaces();
      expr = ReadExprText();
      if(expr == "++"){
         WriteByte(0x01); // increment
         WriteByte(arg1);
         return true;
      }
      else if (expr == "--"){
         WriteByte(0x02); // decrement
         WriteByte(arg1);
         return true;
      }
      else{
        if(expr[0]=='*'){
          expr = expr.substr(1);
          LinePos++;
        }
        SkipSpaces();
        arg2isstar = false;
        ArgText = ReadPlainText();
        if(ReadPlainText() == "" && LowerCaseLine[LinePos-ArgText.length()]=='*'){
          LinePos++;
          ArgText = "*" + ReplaceDefine(ReadPlainText());
        }
        else ArgText = ReplaceDefine(ArgText);

        if(ArgText[0] == 'v' && !arg2isstar)arg2isvar=true;
        else if (ArgText.substr(0,2) == "*v" && !arg2isstar) arg2isstar = true;

        if(arg2isvar)arg2 = Val(ArgText.substr(1));
        else if(arg2isstar)arg2 = Val(ArgText.substr(2));
        else arg2 = Val(ArgText);

        if(arg2 <0 || arg2 >255)
          ShowError(CurLine,"Invalid number given or error in expression syntax.");
        else{
          if(expr == "+=" && !arg2isstar){
            if(arg2isvar)WriteByte(0x06);  //addv
            else WriteByte(0x05);          //addn
            WriteByte(arg1);
            WriteByte(arg2);
            return true;
          }
          else if(expr == "-=" && !arg2isstar){
            if(arg2isvar)WriteByte(0x08);  //subv
            else WriteByte(0x07);          //subn
            WriteByte(arg1);
            WriteByte(arg2);
            return true;
          }
          else if(expr == "*=" && !arg2isstar){
            if(arg2isvar)WriteByte(0xa6);  //mul.v
            else WriteByte(0xa5);          //mul.n
            WriteByte(arg1);
            WriteByte(arg2);
            return true;
          }
          else if(expr == "/=" && !arg2isstar){
            if(arg2isvar)WriteByte(0xa8);  //div.v
            else WriteByte(0xa7);          //div.n
            WriteByte(arg1);
            WriteByte(arg2);
            return true;
          }
          else if(expr == "="){
            if(LinePos < LineLength && EditLines.at(CurLine)[LinePos] == ';'){
              //must be assignn, assignv or rindirect
              if (arg2isvar) WriteByte(0x04); // assignv
              else if (arg2isstar) WriteByte(0x0A); // rindirect
              else WriteByte(0x03); // assignv
              WriteByte(arg1);
              WriteByte(arg2);
              return true;
            }
            else if(arg2 != arg1) ShowError(CurLine,"Expression syntax error");
            else{
              SkipSpaces();
              expr2 = ReadExprText();
//.........这里部分代码省略.........
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:101,代码来源:logcompile.cpp

示例6: ReadArgs

//***************************************************
void Logic::ReadArgs(bool CommandIsIf, byte CmdNum)
{
  char *ThisArgTypePrefix;
  bool FinishedReadingSaidArgs=false;
  int ArgValue,NumSaidArgs;
  string ThisWord;
#define MaxSaidArgs 40
  int SaidArgs[MaxSaidArgs];
  int CurArg;
  CommandStruct ThisCommand;
  string ThisMessage;
  int ThisMessageNum;
  string ThisInvObjectName;
  int ThisInvObjectNum;
  int i;

  SkipSpaces();
  if(LinePos >= LineLength || EditLines.at(CurLine)[LinePos] != '('){
    ShowError(CurLine,"'(' expected.");
    return;
  }
  LinePos++;
  if(CmdNum==14 && CommandIsIf){ //said test command
    NumSaidArgs = -1;
    FinishedReadingSaidArgs = false;
    do{
      ReadArgText();
      NumSaidArgs++;
      if(ArgText[0]=='"'){
        ArgValue=0;
        ArgTextPos=0;
        ThisWord=ReadString(&ArgTextPos,ArgText);
        if(ErrorOccured)
          ShowError(CurLine,"\" required at end of word.");
        else{
          //find word group number
          bool found=false;
          for(int k=0;k<wordlist->NumGroups;k++){
            for(int i=0;i<wordlist->WordGroup[k].Words.num;i++){
              if( wordlist->WordGroup[k].Words.at(i) == ThisWord){
                ArgValue = wordlist->WordGroup[k].GroupNum;
                found=true;
                break;
              }
            }
            if(found)break;
          }
          if(!found){
            ShowError(CurLine,"Unknown word "+ThisWord+".");
            return;
          }
        }
      }
      else ArgValue = ReadArgValue();
      SaidArgs[NumSaidArgs] = ArgValue;
      if (SaidArgs[NumSaidArgs] < 0 || SaidArgs[NumSaidArgs] > 65535){
        ShowError(CurLine,"Invalid word number for argument " +IntToStr(NumSaidArgs)+ " (must be 0-65535).");
         SaidArgs[NumSaidArgs] = 0;
      }
      if ((LinePos < LineLength) & (LowerCaseLine[LinePos] == ',')){
        if  (NumSaidArgs > MaxSaidArgs){
          ShowError(CurLine,"Too many arguments for said command.");
          FinishedReadingSaidArgs = true;
        }
      }
      else if(LinePos < LineLength && LowerCaseLine[LinePos] == ')'){
        FinishedReadingSaidArgs = true;
      }
      else
         ShowError(CurLine,"',' or ')' expected after argument "+IntToStr(NumSaidArgs)+".");
      LinePos++;
    }while(!FinishedReadingSaidArgs||ErrorOccured);
    WriteByte(NumSaidArgs+1);
    for (int i=0;i<=NumSaidArgs;i++){
      WriteByte(SaidArgs[i] % 256);
      WriteByte(SaidArgs[i] / 256);
    }
  }//if said test command
  else{ //other command
    if (CommandIsIf) ThisCommand = TestCommand[CmdNum];
    else  ThisCommand = AGICommand[CmdNum];
    for (CurArg = 0;CurArg<ThisCommand.NumArgs;CurArg++){
      SkipSpaces();
      ReadArgText();
      if (ThisCommand.argTypes[CurArg] == atMsg && ArgTextLength >=1 && ArgText[0]=='"'){
         // argument is message and given as string
        ArgTextPos=0;
        ThisMessage = "";
        //splitting the message into lines if it doesn't fit the screen
        do{
          if(ThisMessage != "" && ThisMessage[ThisMessage.length()-1]!=' ')ThisMessage += " ";
          ThisMessage += ReadString(&ArgTextPos,ArgText);
          if(LinePos+1>=LineLength || LowerCaseLine.find_first_not_of(" ",LinePos+1)==string::npos){

            NextLine();
            SkipSpaces();
            ReadArgText();
          }
          else break;
//.........这里部分代码省略.........
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:101,代码来源:logcompile.cpp

示例7: AddIncludes

//***************************************************
int Logic::AddIncludes()
{
  TStringList IncludeStrings,IncludeLines;
  int  CurInputLine,CurIncludeLine;
  string filename;
  int err=0;
  string::size_type pos1,pos2;
  int CurLine;
  char *ptr;

  IncludeFilenames = TStringList();
  IncludeStrings = TStringList();
  EditLines = TStringList();
  IncludeLines = TStringList();
  CurLine = 0;
  for(CurInputLine = 0;CurInputLine<InputLines.num;CurInputLine++){
    EditLines.add(InputLines.at(CurInputLine));
    CurLine = EditLines.num -1;
    RealLineNum[CurLine] = CurInputLine;
    LineFile[CurLine] = 0;
#ifdef _WIN32
    if(_strnicmp(InputLines.at(CurInputLine).c_str(),"#include",8)) {
#else
    if(strncasecmp(InputLines.at(CurInputLine).c_str(),"#include",8)){
#endif
      continue;
    }
    string str = InputLines.at(CurInputLine).substr(8);
    if(str.length()<4){
      ShowError(CurLine,"Missing include filename !");
      err=1;
      continue;
    }
    if(str[0] != ' '){
      ShowError(CurLine,"' ' expected after #include.");
      err=1;
      continue;
    }
    pos1 = str.find_first_of("\"",1);
    pos2 = str.find_first_of("\"",pos1+1);
    if(pos1 == string::npos || pos2 == string::npos){
      ShowError(CurLine,"Include filenames need quote marks around them.");
      err=1;
      continue;
    }
    filename = str.substr(pos1+1,pos2-pos1-1);
    if(filename.find_first_of("/")!=string::npos){
      ShowError(CurLine,"Only files in the src directory can be included.");
      err=1;
      continue;
    }
    sprintf(tmp,"%s/src/%s",game->dir.c_str(),filename.c_str());
    FILE *fptr = fopen(tmp,"rb");
    if(fptr==NULL){
      sprintf(tmp,"Can't open include file: %s/src/%s",game->dir.c_str(),filename.c_str());
      ShowError(CurLine,tmp);
      err=1;
      continue;
    }
    IncludeLines.lfree();

    while(fgets(tmp,MAX_TMP,fptr)!=NULL){
      if((ptr=strchr(tmp,0x0a)))*ptr=0;
      if((ptr=strchr(tmp,0x0d)))*ptr=0;
      IncludeLines.add(tmp);
    }
    fclose(fptr);
    if(IncludeLines.num==0)continue;
    IncludeFilenames.add(filename);
    RemoveComments(IncludeLines);
    EditLines.replace(CurLine,empty_tmp);
    for(CurIncludeLine=0;CurIncludeLine<IncludeLines.num;CurIncludeLine++){
      EditLines.add(IncludeLines.at(CurIncludeLine));
      CurLine=EditLines.num-1;
      RealLineNum[CurLine] = CurIncludeLine;
      LineFile[CurLine] = IncludeFilenames.num;
    }
  }

  IncludeLines.lfree();
  InputLines.lfree();
  return err;

}

//***************************************************
int Logic::ReadDefines()
{
  int err=0,i;
  string::size_type pos1,pos2;
  string ThisDefineName,ThisDefineValue;
  int CurLine;

  NumDefines = 0;
  for(CurLine = 0;CurLine<EditLines.num;CurLine++){
#ifdef _WIN32
    if(_strnicmp(EditLines.at(CurLine).c_str(),"#define",7)){
#else
    if(strncasecmp(EditLines.at(CurLine).c_str(),"#define",7)){
//.........这里部分代码省略.........
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:101,代码来源:logcompile.cpp

示例8: CompileCommands

//***************************************************
int Logic::CompileCommands()
{
  int err=0;
  short BlockDepth;
  short BlockStartDataLoc[MaxBlockDepth+1];
  short BlockLength[MaxBlockDepth+1];
  bool BlockIsIf[MaxBlockDepth+1];
  bool InIf,LastCommandWasReturn,InIfBrackets=false,AwaitingNextTestCommand=false,EncounteredLabel;
  int NumCommandsInIfStatement=0,NumCommandsInIfBrackets=0;

  typedef struct{
    byte LabelNum;
    int DataLoc;
  }TLogicGoto;
  TLogicGoto Gotos[MaxGotos+1];
  short NumGotos,GotoData,CurGoto;

  memset( BlockIsIf,0,sizeof( BlockIsIf));
  InIf = false;
  BlockDepth = 0;
  NumGotos = 0;
  FinishedReading = false;
  CurLine = -1;
  NextLine();
  if(FinishedReading){
    ShowError(CurLine,"Nothing to compile !");
    return 1;
  }
  do{
    LastCommandWasReturn = false;
    if(!InIf){
      if(LinePos < LineLength && LowerCaseLine[LinePos] == '}'){
        LinePos++;
        if(BlockDepth==0)
              ShowError(CurLine,"'}' not at end of any command blocks.");
        else{
//          if (ResPos == BlockStartDataLoc[BlockDepth] + 2)
//                ShowError(CurLine,"Command block must contain at least one command.");
          BlockLength[BlockDepth] = ResPos-BlockStartDataLoc[BlockDepth]-2;
          WriteByteAtLoc(BlockLength[BlockDepth] & 0xff,BlockStartDataLoc[BlockDepth]);
          WriteByteAtLoc((BlockLength[BlockDepth]>>8)&0xff,BlockStartDataLoc[BlockDepth]+1);
          BlockDepth--;
          SkipSpaces();
          if (LinePos >= LineLength && CurLine < EditLines.num-1)NextLine();
          if(LowerCaseLine.substr(LinePos,4) == "else"){
            LinePos+=4;
            SkipSpaces();
            if(! BlockIsIf[BlockDepth+1])
                  ShowError(CurLine,"'else' not allowed after command blocks that start with 'else'.");

            else if(LinePos >= LineLength || LowerCaseLine[LinePos] != '{')
                  ShowError(CurLine,"'{' expected after else.");

            else{
              LinePos++;
              BlockDepth++;
              BlockLength[BlockDepth] +=3;
              WriteByteAtLoc(BlockLength[BlockDepth]&0xff,BlockStartDataLoc[BlockDepth]);
              WriteByteAtLoc((BlockLength[BlockDepth]>>8)&0xff,BlockStartDataLoc[BlockDepth]+1);
              BlockIsIf[BlockDepth] = true;
              WriteByte(0xfe);
              BlockStartDataLoc[BlockDepth] = ResPos;
              WriteByte(0x00);  // block length filled in later.
              WriteByte(0x00);
            }
          }//if(LowerCaseLine.substr(LinePos,4) == "else"
        }//if BlockDepth > 0
      }//if LowerCaseLine[LinePos] == '}'
      else{
        ReadCommandName();
        if(CommandName == "if"){
          WriteByte(0xFF);
          InIf = true;
          SkipSpaces();
          if(LinePos >= LineLength || EditLines.at(CurLine)[LinePos] != '(')
                ShowError(CurLine,"'(' expected at start of if statement.");

          LinePos++;
          InIfBrackets = false;
          NumCommandsInIfStatement = 0;
          AwaitingNextTestCommand = true;
        }
        else if(CommandName == "else")
              ShowError(CurLine,"'}' required before 'else'.");

        else if(CommandName == "goto"){
          if(LinePos >= LineLength || LowerCaseLine[LinePos] != '(')
                ShowError(CurLine,"'(' expected.");
          else{
            LinePos++;
            ReadCommandName();
            CommandName = ReplaceDefine(CommandName);
            if (LabelNum(CommandName) == 0)
                  ShowError(CurLine,"Unknown label "+CommandName+".");
            else if (NumGotos >= MaxGotos)
                  ShowError(CurLine,"Too many labels (max "+IntToStr(MaxLabels)+").");
            else{
              NumGotos++;
              Gotos[NumGotos].LabelNum = LabelNum(CommandName);
//.........这里部分代码省略.........
开发者ID:saintfrater,项目名称:qt-agi-studio,代码行数:101,代码来源:logcompile.cpp


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