farsamiscutilities.h
Go to the documentation of this file.
1 /********************************************************************************
2  * FARSA Utilities Library *
3  * Copyright (C) 2007-2012 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
21  ********************************************************************************/
22 
23 #ifndef FARSAMISCUTILITIES_H
24 #define FARSAMISCUTILITIES_H
25 
26 #include "utilitiesconfig.h"
27 #include <QString>
28 #include <QList>
29 
39 #if defined(__GNUC__) || defined(__clang__)
40  #define FARSA_DEPRECATED __attribute__((deprecated))
41 #elif defined(_MSC_VER)
42  #define FARSA_DEPRECATED __declspec(deprecated)
43 #endif
44 
45 namespace farsa {
52  struct FARSA_UTIL_TEMPLATE CommentPosition
53  {
57  enum CommentType {
59  CppComment
60  };
61 
66  originalStart(0),
67  originalEnd(0),
68  parsedPosition(0),
69  type(CComment)
70  {
71  }
72 
84  CommentPosition(unsigned int s, unsigned int e, unsigned int p, CommentType t) :
85  originalStart(s),
86  originalEnd(e),
87  parsedPosition(p),
88  type(t)
89  {
90  }
91 
96  unsigned int originalStart;
97 
102  unsigned int originalEnd;
103 
108  unsigned int parsedPosition;
109 
114  };
115 
119  typedef QList<CommentPosition> CommentsPositions;
120 
129  struct FARSA_UTIL_TEMPLATE StringPosition
130  {
134  enum Type {
136  Character
137  };
138 
143  originalStart(0),
144  originalEnd(0),
145  parsedStart(0),
146  parsedEnd(0),
147  type(String)
148  {
149  }
150 
164  StringPosition(unsigned int os, unsigned int oe, unsigned int ps, unsigned int pe, Type t) :
165  originalStart(os),
166  originalEnd(oe),
167  parsedStart(ps),
168  parsedEnd(pe),
169  type(t)
170  {
171  }
172 
177  unsigned int originalStart;
178 
183  unsigned int originalEnd;
184 
189  unsigned int parsedStart;
190 
195  unsigned int parsedEnd;
196 
201  };
202 
206  typedef QList<StringPosition> StringsPositions;
207 
225  QString FARSA_UTIL_API removeComments(const QString& program, CommentsPositions* commentsPos = NULL, StringsPositions* stringsPos = NULL);
226 }
227 
228 #endif