Source-highlight Library
textstyleformatter.h
1 
8 #ifndef _TEXTSTYLEFORMATTER_H_
9 #define _TEXTSTYLEFORMATTER_H_
10 
11 #include "textstyle.h"
12 #include "formatter.h"
13 
14 namespace srchilite {
15 
16 class BufferedOutput;
17 class PreFormatter;
18 class CTagsFormatter;
19 
23 class TextStyleFormatter : public Formatter {
24 private:
27 
30 
33 
36 
37 public:
38  TextStyleFormatter(const TextStyle &style, BufferedOutput *o = 0);
39  TextStyleFormatter(const std::string &repr = "$text",
40  BufferedOutput *o = 0);
41 
42  virtual ~TextStyleFormatter() {
43  }
44 
45  virtual void
46  format(const std::string &s, const FormatterParams *params = 0);
47 
48  BufferedOutput *getBufferedOutput() const {
49  return output;
50  }
51 
52  CTagsFormatter *getCTagsFormatter() const {
53  return ctagsFormatter;
54  }
55 
56  void setBufferedOutput(BufferedOutput *o) {
57  output = o;
58  }
59 
60  void setPreFormatter(PreFormatter *p) {
61  preFormatter = p;
62  }
63 
64  void setCTagsFormatter(CTagsFormatter *f) {
65  ctagsFormatter = f;
66  }
67 
71  const std::string &toString() const {
72  return textstyle.toString();
73  }
74 
75 protected:
82  void doFormat(const std::string &s, bool preformat = true);
83 
90  bool formatReferences(const std::string &s, const FormatterParams *params);
91 
92 };
93 
94 }
95 
96 #endif /* _TEXTSTYLEFORMATTER_H_ */
The base abstract class for formatting strings.
Definition: formatter.h:25
An implementation of Formatter, based on source-highlight TextStyle.
Definition: textstyleformatter.h:23
Preformats text to be generated.
Definition: preformatter.h:31
CTagsFormatter * ctagsFormatter
the possible formatter for ctags (references and anchors)
Definition: textstyleformatter.h:35
const std::string & toString() const
Definition: textstyleformatter.h:71
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
Represents a formatting template where there can be some variables (starting with $...
Definition: textstyle.h:36
Formatter for information gathered from ctags.
Definition: ctagsformatter.h:50
bool formatReferences(const std::string &s, const FormatterParams *params)
Performs reference formatting (by relying on the CTagsFormatter)
Definition: textstyleformatter.cpp:48
const std::string & toString() const
Definition: textstyle.h:93
void doFormat(const std::string &s, bool preformat=true)
Actually performs formatting (no reference formatting); this is used internally.
Definition: textstyleformatter.cpp:37
Additional parameters that can be passed to a formatter.
Definition: formatterparams.h:18
BufferedOutput * output
where to output the formatting
Definition: textstyleformatter.h:29
The main class for writing into the output.
Definition: bufferedoutput.h:28
virtual void format(const std::string &s, const FormatterParams *params=0)
Formats the passed string.
Definition: textstyleformatter.cpp:31
TextStyle textstyle
the TextStyle for formatting
Definition: textstyleformatter.h:26
PreFormatter * preFormatter
the possible pre formatter for text
Definition: textstyleformatter.h:32