geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

CatalogueModules.h
Go to the documentation of this file.
1// Scintilla source code edit control
2/** @file CatalogueModules.h
3 ** Lexer infrastructure.
4 ** Contains a list of LexerModules which can be searched to find a module appropriate for a
5 ** particular language.
6 **/
7// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
8// The License.txt file describes the conditions under which this software may be distributed.
9
10#ifndef CATALOGUEMODULES_H
11#define CATALOGUEMODULES_H
12
13namespace Scintilla {
14
16 std::vector<LexerModule *> lexerCatalogue;
17public:
18 const LexerModule *Find(int language) const {
19 for (const LexerModule *lm : lexerCatalogue) {
20 if (lm->GetLanguage() == language) {
21 return lm;
22 }
23 }
24 return nullptr;
25 }
26
27 const LexerModule *Find(const char *languageName) const noexcept {
28 if (languageName) {
29 for (const LexerModule *lm : lexerCatalogue) {
30 if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) {
31 return lm;
32 }
33 }
34 }
35 return nullptr;
36 }
37
39 lexerCatalogue.push_back(plm);
40 }
41
42 unsigned int Count() const noexcept {
43 return static_cast<unsigned int>(lexerCatalogue.size());
44 }
45
46 const char *Name(unsigned int index) const noexcept {
47 if (index < static_cast<unsigned int>(lexerCatalogue.size())) {
48 return lexerCatalogue[index]->languageName;
49 } else {
50 return "";
51 }
52 }
53
54 LexerFactoryFunction Factory(unsigned int index) const noexcept {
55 // Works for object lexers but not for function lexers
56 return lexerCatalogue[index]->fnFactory;
57 }
58
59 ILexer *Create(unsigned int index) const {
60 const LexerModule *plm = lexerCatalogue[index];
61 if (!plm) {
62 return nullptr;
63 }
64 return plm->Create();
65 }
66};
67
68}
69
70#endif
gint index
Definition: build.c:2680
const char * Name(unsigned int index) const noexcept
const LexerModule * Find(const char *languageName) const noexcept
void AddLexerModule(LexerModule *plm)
unsigned int Count() const noexcept
LexerFactoryFunction Factory(unsigned int index) const noexcept
const LexerModule * Find(int language) const
std::vector< LexerModule * > lexerCatalogue
ILexer * Create(unsigned int index) const
A LexerModule is responsible for lexing and folding a particular language.
Definition: LexerModule.h:27
ILexer * Create() const
Definition: LexerModule.cxx:93
Styling buffer using one element for each run rather than using a filled buffer.
Definition: Converter.h:9
ILexer *(* LexerFactoryFunction)()
Definition: LexerModule.h:19