All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LexerFactory.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2011 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file LexerFactory.cpp
22 
23  \brief A factory method for language lexers.
24 */
25 
26 // TerraLib
27 #include "LexerFactory.h"
28 
29 // Qt
30 #include <QtCore/QString.h>
31 
32 // QScintilla
33 #include <Qsci/qscilexercpp.h>
34 #include <Qsci/qscilexerd.h>
35 #include <Qsci/qscilexerjava.h>
36 #include <Qsci/qscilexerjavascript.h>
37 #include <Qsci/qscilexerlua.h>
38 #include <Qsci/qscilexerpython.h>
39 #include <Qsci/qscilexerruby.h>
40 
41 QsciLexer* te::qt::widgets::LexerFactory::make(const QString& lang, QObject* parent)
42 {
43  const QString ulang = lang.toUpper();
44 
45  if(ulang == "LUA")
46  {
47  return new QsciLexerLua(parent);
48  }
49  else if((ulang == "JS") || (ulang == "JAVASCRIPT") || (ulang == "JSCRIPT"))
50  {
51  return new QsciLexerJavaScript(parent);
52  }
53  else if((ulang == "H") || (ulang == "HPP") || (ulang == "C") || (ulang == "CPP") || (ulang == "CXX"))
54  {
55  return new QsciLexerCPP(parent);
56  }
57  else if((ulang == "J") || (ulang == "JAVA"))
58  {
59  return new QsciLexerJava(parent);
60  }
61  else if((ulang == "D"))
62  {
63  return new QsciLexerD(parent);
64  }
65  else if((ulang == "PY") || (ulang == "PYTHON"))
66  {
67  return new QsciLexerPython(parent);
68  }
69  else if((ulang == "RUBY") || (ulang == "RBY"))
70  {
71  return new QsciLexerRuby(parent);
72  }
73  else
74  {
75  return 0;
76  }
77 }
78 
static QsciLexer * make(const QString &lang, QObject *parent=0)
A factory method for language lexers.