File: langdefmanager.h

package info (click to toggle)
source-highlight 3.1.7-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,332 kB
  • ctags: 5,233
  • sloc: sh: 11,270; cpp: 10,206; ansic: 9,515; makefile: 1,865; lex: 1,200; yacc: 1,021; php: 213; perl: 211; awk: 98; erlang: 94; lisp: 90; java: 75; ruby: 69; python: 61; asm: 43; ml: 38; ada: 36; haskell: 27; xml: 23; cs: 11; sql: 8; tcl: 6; sed: 4
file content (85 lines) | stat: -rw-r--r-- 2,885 bytes parent folder | download | duplicates (8)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
//
// Copyright: See COPYING file that comes with this distribution
//

#ifndef LANGDEFMANAGER_H_
#define LANGDEFMANAGER_H_

#include <map>

#include "highlightstate.h"

namespace srchilite {

/// store already generated HighlightState specific to a given file name
typedef std::map<std::string, HighlightStatePtr> HighlightStateCache;

class HighlightRuleFactory;
class LangElems;

/**
 * Handles langdef language definition files
 */
class LangDefManager {
    /// the factory for creating highlight rules
    HighlightRuleFactory *ruleFactory;

    /// store already generated HighlightState specific to a given file name
    HighlightStateCache highlightStateCache;
public:
    /**
     * @param ruleFactory the factory for creating highlight rules
     */
    LangDefManager(HighlightRuleFactory *ruleFactory);
    ~LangDefManager();

    /**
     * Builds the HighlightState corresponding to the
     * language definition by the specified file, using the specified path.
     * @param path the path that is used for searching for the file and included files
     * @param file the name of the language definition file
     * @return the HighlightState built using the language definitions
     */
    HighlightStatePtr buildHighlightState(const std::string &path,
            const std::string &file);

    /**
     * Gets the HighlightState corresponding to the
     * language definition file, using the specified
     * path.  If the language definition file was already inspected, then it
     * won't rebuild the HighlightState, but it will reuse the previously built one.
     * @param path the path that is used for searching for the file and included files
     * @param file the name of the language definition file
     * @return the HighlightState built using the language definitions
     */
    HighlightStatePtr getHighlightState(const std::string &path,
            const std::string &file);

    /**
     * Gets the HighlightState corresponding to the
     * language definition by the specified file, using the default path
     * for language definition files (either stored in the user home setting
     * configuration file or the default hardcoded one).
     * @param file the name of the language definition file
     * @return the HighlightState built using the language definitions
     */
    HighlightStatePtr getHighlightState(const std::string &file);

    /**
     * Returns the language elements of the specified language definition file.
     * @param path
     * @param file
     * @return the language elements of the specified language definition file.
     */
    LangElems *getLangElems(const std::string &path, const std::string &file);

    const HighlightRuleFactory *getRuleFactory() const {
        return ruleFactory;
    }
};

}

#endif /*LANGDEFMANAGER_H_*/