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 
15 namespace srchilite {
16 
18 typedef std::map<std::string, FormatterPtr> FormatterMap;
19 
26  mutable FormatterMap formatterMap;
27 
31 public:
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 
82  const FormatterMap &getFormatterMap() const {
83  return formatterMap;
84  }
85 };
86 
87 }
88 
89 #endif /*FORMATTERMANAGER_H_*/
const FormatterMap & getFormatterMap() const
Definition: formattermanager.h:82
std::map< std::string, FormatterPtr > FormatterMap
the map for formatters
Definition: formattermanager.h:18
Associates to an element name the corresponding formatter.
Definition: formattermanager.h:24
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
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
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
void reset()
Resets this formatter manager: it removes all the current associations.
Definition: formattermanager.h:75
FormatterMap formatterMap
the map associating to each element name a formatter
Definition: formattermanager.h:26
boost::shared_ptr< Formatter > FormatterPtr
shared pointer for Formatter
Definition: formatter.h:41
FormatterManager(FormatterPtr _defaultFormatter)
Definition: formattermanager.cpp:15
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