File: macroexpansion.cpp

package info (click to toggle)
qsstv 9.5.8-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,928 kB
  • sloc: cpp: 47,579; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "macroexpansion.h"


macroExpansion::macroExpansion()
{
  convertList.clear();
}



QString macroExpansion::convert(QString txt)
{
  int i,j;
  bool special=false;
  QChar c;
  QString convertedText;
  {
    for (i=0;i<txt.length();i++)
    {
      if (special)
        {
          special=false;
          c=txt.at(i);
          if(c=='%')
          {
            convertedText.append('%');
            continue;
          }
          for (j=0;j<convertList.count();j++)
            {
              if(c==convertList.at(j).tag)
              {
                convertedText.append(convertList.at(j).replacement);
              }
            }
        }
      else
        {
          if(txt.at(i)!='%') convertedText.append(txt.at(i));
          else special=true;
        }
    }

  }
  return convertedText;
}


void macroExpansion::addConversion(QChar tag,QString value)
{
  sconvert cnv;
  cnv.tag=tag;
  cnv.replacement=value;
  convertList.append(cnv);
}