Source-highlight Library
formattermanager.h
1//
2// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
3//
4// Copyright: See COPYING file that comes with this distribution
5//
6
7#ifndef FORMATTERMANAGER_H_
8#define FORMATTERMANAGER_H_
9
10#include <string>
11#include <map>
12
13#include "formatter.h"
14
15namespace srchilite {
16
18typedef std::map<std::string, FormatterPtr> FormatterMap;
19
27
31public:
36 FormatterManager(FormatterPtr _defaultFormatter);
38
46 FormatterPtr getFormatter(const std::string &elem) const;
47
48 FormatterPtr getDefaultFormatter() const {
49 return defaultFormatter;
50 }
51
52 void setDefaultFormatter(FormatterPtr def) {
53 defaultFormatter = def;
54 }
55
62 FormatterPtr hasFormatter(const std::string &elem) const;
63
70 void addFormatter(const std::string &elem, FormatterPtr formatter);
71
75 void reset() {
76 formatterMap.clear();
77 }
78
83 return formatterMap;
84 }
85};
86
87}
88
89#endif /*FORMATTERMANAGER_H_*/
Associates to an element name the corresponding formatter.
Definition: formattermanager.h:24
FormatterPtr hasFormatter(const std::string &elem) const
Returns the formatter for the specific element or an empty pointer if there's no such formatter.
Definition: formattermanager.cpp:32
FormatterPtr defaultFormatter
the default formatter, i.e., the one that is used when there's no formatter associated to an element ...
Definition: formattermanager.h:30
FormatterManager(FormatterPtr _defaultFormatter)
Definition: formattermanager.cpp:15
void reset()
Resets this formatter manager: it removes all the current associations.
Definition: formattermanager.h:75
FormatterPtr getFormatter(const std::string &elem) const
Returns the formatter for the specific element (this function always returns a valid pointer,...
Definition: formattermanager.cpp:22
void addFormatter(const std::string &elem, FormatterPtr formatter)
Associates the formatter to the element name (possible previous associated formatter is discarded).
Definition: formattermanager.cpp:41
const FormatterMap & getFormatterMap() const
Definition: formattermanager.h:82
FormatterMap formatterMap
the map associating to each element name a formatter
Definition: formattermanager.h:26
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
boost::shared_ptr< Formatter > FormatterPtr
shared pointer for Formatter
Definition: formatter.h:41
std::map< std::string, FormatterPtr > FormatterMap
the map for formatters
Definition: formattermanager.h:18