The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MarkupFilterMgr Class Reference

#include <markupfiltmgr.h>

+ Inheritance diagram for MarkupFilterMgr:
+ Collaboration diagram for MarkupFilterMgr:

Public Member Functions

virtual void addEncodingFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addGlobalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
 
virtual void addLocalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
 
virtual void addRawFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addRenderFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addStripFilters (SWModule *module, ConfigEntMap &section)
 
char Encoding (char enc)
 
char getEncoding () const
 
char getMarkup () const
 
virtual SWMgrgetParentMgr ()
 
SWDEPRECATED char Markup (char m=FMT_UNKNOWN)
 
 MarkupFilterMgr (char markup=FMT_THML, char encoding=ENC_UTF8)
 
void setEncoding (char enc)
 
void setMarkup (char m)
 
virtual void setParentMgr (SWMgr *parentMgr)
 
 ~MarkupFilterMgr ()
 

Protected Member Functions

void createFilters (char markup)
 

Protected Attributes

char encoding
 
SWFilterfromgbf
 
SWFilterfromosis
 
SWFilterfromplain
 
SWFilterfromtei
 
SWFilterfromthml
 
SWFilterlatin1utf8
 
char markup
 
SWFilterscsuutf8
 
SWFiltertargetenc
 
SWFilterutf16utf8
 

Detailed Description

This class is like a normal SWEncodingMgr, but you can additonally specify which markup you want to use.

Definition at line 34 of file markupfiltmgr.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START MarkupFilterMgr::MarkupFilterMgr ( char  markup = FMT_THML,
char  encoding = ENC_UTF8 
)

Constructor of SWMarkupMgr.

Parameters
encodingThe desired encoding.
markupThe desired markup format.

Definition at line 73 of file markupfiltmgr.cpp.

74  : EncodingFilterMgr(enc) {
75 
76  markup = mark;
77 
79 }
void createFilters(char markup)
EncodingFilterMgr(char encoding=ENC_UTF8)
Definition: encfiltmgr.cpp:55
MarkupFilterMgr::~MarkupFilterMgr ( )

The destructor of SWMarkupMgr.

Definition at line 86 of file markupfiltmgr.cpp.

86  {
87  delete fromthml;
88  delete fromgbf;
89  delete fromplain;
90  delete fromosis;
91  delete fromtei;
92 }
SWFilter * fromosis
Definition: markupfiltmgr.h:40
SWFilter * fromthml
Definition: markupfiltmgr.h:37
SWFilter * fromgbf
Definition: markupfiltmgr.h:38
SWFilter * fromplain
Definition: markupfiltmgr.h:39
SWFilter * fromtei
Definition: markupfiltmgr.h:41

Member Function Documentation

void EncodingFilterMgr::addEncodingFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the encoding filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the encoding filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 106 of file encfiltmgr.cpp.

106  {
107  if (targetenc)
108  module->addEncodingFilter(targetenc);
109 }
virtual SWModule & addEncodingFilter(SWFilter *newFilter)
Definition: swmodule.h:627
SWFilter * targetenc
Definition: encfiltmgr.h:46
void SWFilterMgr::addGlobalOptions ( SWModule module,
ConfigEntMap section,
ConfigEntMap::iterator  start,
ConfigEntMap::iterator  end 
)
virtualinherited

Definition at line 48 of file swfiltermgr.cpp.

48  {
49 }
void SWFilterMgr::addLocalOptions ( SWModule module,
ConfigEntMap section,
ConfigEntMap::iterator  start,
ConfigEntMap::iterator  end 
)
virtualinherited

Definition at line 52 of file swfiltermgr.cpp.

52  {
53 }
void EncodingFilterMgr::addRawFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the raw filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the raw filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 89 of file encfiltmgr.cpp.

89  {
90 
91  ConfigEntMap::iterator entry;
92 
93  SWBuf encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (SWBuf)"";
94  if (!encoding.length() || !stricmp(encoding.c_str(), "Latin-1")) {
95  module->addRawFilter(latin1utf8);
96  }
97  else if (!stricmp(encoding.c_str(), "SCSU")) {
98  module->addRawFilter(scsuutf8);
99  }
100  else if (!stricmp(encoding.c_str(), "UTF-16")) {
101  module->addRawFilter(utf16utf8);
102  }
103 }
SWFilter * utf16utf8
Definition: encfiltmgr.h:45
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
const char * c_str() const
Definition: swbuf.h:158
SWFilter * latin1utf8
Definition: encfiltmgr.h:43
virtual SWModule & addRawFilter(SWFilter *newFilter)
Definition: swmodule.h:694
SWFilter * scsuutf8
Definition: encfiltmgr.h:44
void MarkupFilterMgr::addRenderFilters ( SWModule module,
ConfigEntMap section 
)
virtual

Adds the render filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the render filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 208 of file markupfiltmgr.cpp.

208  {
209  switch (module->getMarkup()) {
210  case FMT_THML:
211  if (fromthml)
212  module->addRenderFilter(fromthml);
213  break;
214  case FMT_GBF:
215  if (fromgbf)
216  module->addRenderFilter(fromgbf);
217  break;
218  case FMT_PLAIN:
219  if (fromplain)
220  module->addRenderFilter(fromplain);
221  break;
222  case FMT_OSIS:
223  if (fromosis)
224  module->addRenderFilter(fromosis);
225  break;
226  case FMT_TEI:
227  if (fromtei)
228  module->addRenderFilter(fromtei);
229  break;
230  }
231 }
SWFilter * fromosis
Definition: markupfiltmgr.h:40
SWFilter * fromthml
Definition: markupfiltmgr.h:37
virtual SWModule & addRenderFilter(SWFilter *newFilter)
Definition: swmodule.h:564
char getMarkup() const
Definition: swmodule.h:427
SWFilter * fromgbf
Definition: markupfiltmgr.h:38
SWFilter * fromplain
Definition: markupfiltmgr.h:39
SWFilter * fromtei
Definition: markupfiltmgr.h:41
void SWFilterMgr::addStripFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the strip filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the strip filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Definition at line 82 of file swfiltermgr.cpp.

82  {
83 }
void MarkupFilterMgr::createFilters ( char  markup)
protected

Definition at line 234 of file markupfiltmgr.cpp.

234  {
235 
236  switch (markup) {
237  case FMT_PLAIN:
238  fromplain = NULL;
239  fromthml = new ThMLPlain();
240  fromgbf = new GBFPlain();
241  fromosis = new OSISPlain();
242  fromtei = new TEIPlain();
243  break;
244 
245  case FMT_THML:
246  fromplain = NULL;
247  fromthml = NULL;
248  fromgbf = new GBFThML();
249  fromosis = NULL;
250  fromtei = NULL;
251  break;
252 
253  case FMT_GBF:
254  fromplain = NULL;
255  fromthml = new ThMLGBF();
256  fromgbf = NULL;
257  fromosis = NULL;
258  fromtei = NULL;
259  break;
260 
261  case FMT_HTML:
262  fromplain = NULL;
263  fromthml = new ThMLHTML();
264  fromgbf = new GBFHTML();
265  fromosis = NULL;
266  fromtei = NULL;
267  break;
268 
269  case FMT_HTMLHREF:
270  fromplain = NULL;
271  fromthml = new ThMLHTMLHREF();
272  fromgbf = new GBFHTMLHREF();
273  fromosis = new OSISHTMLHREF();
274  fromtei = new TEIHTMLHREF();
275  break;
276 
277  case FMT_RTF:
278  fromplain = NULL;
279  fromthml = new ThMLRTF();
280  fromgbf = new GBFRTF();
281  fromosis = new OSISRTF();
282  fromtei = new TEIRTF();
283  break;
284 
285  case FMT_LATEX:
286  fromplain = NULL;
287  fromthml = new ThMLLaTeX();
288  fromgbf = new GBFLaTeX();
289  fromosis = new OSISLaTeX();
290  fromtei = new TEILaTeX();
291  break;
292 
293  case FMT_OSIS:
294  fromplain = NULL;
295  fromthml = new ThMLOSIS();
296  fromgbf = new GBFOSIS();
297  fromosis = new OSISOSIS();
298  fromtei = NULL;
299  break;
300 
301  case FMT_WEBIF:
302  fromplain = NULL;
303  fromthml = new ThMLWEBIF();
304  fromgbf = new GBFWEBIF();
305  fromosis = new OSISWEBIF();
306  fromtei = new TEIXHTML();
307  break;
308 
309  case FMT_TEI:
310  fromplain = NULL;
311  fromthml = NULL;
312  fromgbf = NULL;
313  fromosis = NULL;
314  fromtei = NULL;
315  break;
316 
317  case FMT_XHTML:
318  fromplain = NULL;
319  fromthml = new ThMLXHTML();
320  fromgbf = new GBFXHTML();
321  fromosis = new OSISXHTML();
322  fromtei = new TEIXHTML();
323  break;
324  }
325 
326 }
Definition: gbfrtf.h:33
SWFilter * fromosis
Definition: markupfiltmgr.h:40
SWFilter * fromthml
Definition: markupfiltmgr.h:37
SWFilter * fromgbf
Definition: markupfiltmgr.h:38
SWFilter * fromplain
Definition: markupfiltmgr.h:39
Definition: teirtf.h:33
return NULL
Definition: regex.c:7953
SWFilter * fromtei
Definition: markupfiltmgr.h:41
char EncodingFilterMgr::Encoding ( char  enc)
inlineinherited

Encoding sets/gets the encoding after initialization

DEPRECATED: use setEncoding / getEncoding

Returns
The current encoding format.

Definition at line 75 of file encfiltmgr.h.

75 { if (enc != ENC_UNKNOWN) setEncoding(enc); return getEncoding(); }
char getEncoding() const
Definition: encfiltmgr.h:81
void setEncoding(char enc)
Definition: encfiltmgr.cpp:119
char EncodingFilterMgr::getEncoding ( ) const
inlineinherited

getEncoding gets the encoding after initialization

Returns
The current encoding format.

Definition at line 81 of file encfiltmgr.h.

81 { return encoding; }
char MarkupFilterMgr::getMarkup ( ) const
inline

getMarkup gets the markup after initialization

Returns
The current markup format.

Definition at line 76 of file markupfiltmgr.h.

76 { return markup; }
SWMgr * SWFilterMgr::getParentMgr ( )
virtualinherited

Definition at line 43 of file swfiltermgr.cpp.

43  {
44  return parentMgr;
45 }
SWMgr * parentMgr
Definition: swfiltermgr.h:39
SWDEPRECATED char MarkupFilterMgr::Markup ( char  m = FMT_UNKNOWN)
inline

Markup sets/gets the markup after initialization

Deprecated:
Use setMarkup / getMarkup
Parameters
mThe new markup
Returns
The current (possibly changed) markup format.

Definition at line 70 of file markupfiltmgr.h.

70 { if (m != FMT_UNKNOWN) setMarkup(m); return getMarkup(); }
char getMarkup() const
Definition: markupfiltmgr.h:76
void setMarkup(char m)
void EncodingFilterMgr::setEncoding ( char  enc)
inherited

setEncoding sets the encoding after initialization

Parameters
encThe new encoding or ENC_UNKNOWN if you just want to get the current markup.

Definition at line 119 of file encfiltmgr.cpp.

119  {
120  if (enc && enc != encoding) {
121  encoding = enc;
122  SWFilter *oldfilter = targetenc;
123 
124  switch (encoding) {
125  case ENC_LATIN1: targetenc = new UTF8Latin1(); break;
126  case ENC_UTF16: targetenc = new UTF8UTF16(); break;
127  case ENC_RTF: targetenc = new UnicodeRTF(); break;
128  case ENC_HTML: targetenc = new UTF8HTML(); break;
129 #ifdef _ICU_
130  case ENC_SCSU: targetenc = new UTF8SCSU(); break;
131 #endif
132  default: // i.e. case ENC_UTF8
133  targetenc = NULL;
134  }
135 
136  ModMap::const_iterator module;
137 
138  if (oldfilter != targetenc) {
139  if (oldfilter) {
140  if (!targetenc) {
141  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
142  module->second->removeRenderFilter(oldfilter);
143  }
144  else {
145  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
146  module->second->replaceRenderFilter(oldfilter, targetenc);
147  }
148  delete oldfilter;
149  }
150  else if (targetenc) {
151  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
152  module->second->addRenderFilter(targetenc);
153  }
154  }
155  }
156 }
ModMap Modules
Definition: swmgr.h:322
SWText * module
Definition: osis2mod.cpp:105
SWFilter * targetenc
Definition: encfiltmgr.h:46
return NULL
Definition: regex.c:7953
virtual SWModule & removeRenderFilter(SWFilter *oldFilter)
Definition: swmodule.h:585
virtual SWMgr * getParentMgr()
Definition: swfiltermgr.cpp:43
virtual SWModule & replaceRenderFilter(SWFilter *oldFilter, SWFilter *newFilter)
Definition: swmodule.h:599
void MarkupFilterMgr::setMarkup ( char  m)

setMarkup sets the markup after initialization

Parameters
mThe new markup

Definition at line 102 of file markupfiltmgr.cpp.

102  {
103  if (mark && mark != markup) {
104  markup = mark;
105  ModMap::const_iterator module;
106 
107  SWFilter *oldplain = fromplain;
108  SWFilter *oldthml = fromthml;
109  SWFilter *oldgbf = fromgbf;
110  SWFilter *oldosis = fromosis;
111  SWFilter *oldtei = fromtei;
112 
114 
115  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); ++module) {
116  switch (module->second->getMarkup()) {
117  case FMT_THML:
118  if (oldthml != fromthml) {
119  if (oldthml) {
120  if (!fromthml) {
121  module->second->removeRenderFilter(oldthml);
122  }
123  else {
124  module->second->replaceRenderFilter(oldthml, fromthml);
125  }
126  }
127  else if (fromthml) {
128  module->second->addRenderFilter(fromthml);
129  }
130  }
131  break;
132 
133  case FMT_GBF:
134  if (oldgbf != fromgbf) {
135  if (oldgbf) {
136  if (!fromgbf) {
137  module->second->removeRenderFilter(oldgbf);
138  }
139  else {
140  module->second->replaceRenderFilter(oldgbf, fromgbf);
141  }
142  }
143  else if (fromgbf) {
144  module->second->addRenderFilter(fromgbf);
145  }
146  }
147  break;
148 
149  case FMT_PLAIN:
150  if (oldplain != fromplain) {
151  if (oldplain) {
152  if (!fromplain) {
153  module->second->removeRenderFilter(oldplain);
154  }
155  else {
156  module->second->replaceRenderFilter(oldplain, fromplain);
157  }
158  }
159  else if (fromplain) {
160  module->second->addRenderFilter(fromplain);
161  }
162  }
163  break;
164 
165  case FMT_OSIS:
166  if (oldosis != fromosis) {
167  if (oldosis) {
168  if (!fromosis) {
169  module->second->removeRenderFilter(oldosis);
170  }
171  else {
172  module->second->replaceRenderFilter(oldosis, fromosis);
173  }
174  }
175  else if (fromosis) {
176  module->second->addRenderFilter(fromosis);
177  }
178  }
179  break;
180 
181  case FMT_TEI:
182  if (oldtei != fromtei) {
183  if (oldtei) {
184  if (!fromtei) {
185  module->second->removeRenderFilter(oldtei);
186  }
187  else {
188  module->second->replaceRenderFilter(oldtei, fromtei);
189  }
190  }
191  else if (fromtei) {
192  module->second->addRenderFilter(fromtei);
193  }
194  }
195  break;
196  }
197  }
198 
199  delete oldthml;
200  delete oldgbf;
201  delete oldplain;
202  delete oldosis;
203  delete oldtei;
204  }
205 }
SWFilter * fromosis
Definition: markupfiltmgr.h:40
SWFilter * fromthml
Definition: markupfiltmgr.h:37
ModMap Modules
Definition: swmgr.h:322
SWText * module
Definition: osis2mod.cpp:105
void createFilters(char markup)
SWFilter * fromgbf
Definition: markupfiltmgr.h:38
SWFilter * fromplain
Definition: markupfiltmgr.h:39
SWFilter * fromtei
Definition: markupfiltmgr.h:41
virtual SWMgr * getParentMgr()
Definition: swfiltermgr.cpp:43
void SWFilterMgr::setParentMgr ( SWMgr parentMgr)
virtualinherited

Definition at line 38 of file swfiltermgr.cpp.

38  {
39  this->parentMgr = parentMgr;
40 }
SWMgr * parentMgr
Definition: swfiltermgr.h:39

Member Data Documentation

char EncodingFilterMgr::encoding
protectedinherited

Definition at line 52 of file encfiltmgr.h.

SWFilter* MarkupFilterMgr::fromgbf
protected

Definition at line 38 of file markupfiltmgr.h.

SWFilter* MarkupFilterMgr::fromosis
protected

Definition at line 40 of file markupfiltmgr.h.

SWFilter* MarkupFilterMgr::fromplain
protected

Definition at line 39 of file markupfiltmgr.h.

SWFilter* MarkupFilterMgr::fromtei
protected

Definition at line 41 of file markupfiltmgr.h.

SWFilter* MarkupFilterMgr::fromthml
protected

Definition at line 37 of file markupfiltmgr.h.

SWFilter* EncodingFilterMgr::latin1utf8
protectedinherited

Definition at line 43 of file encfiltmgr.h.

char MarkupFilterMgr::markup
protected

current markup value

Definition at line 46 of file markupfiltmgr.h.

SWFilter* EncodingFilterMgr::scsuutf8
protectedinherited

Definition at line 44 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::targetenc
protectedinherited

Definition at line 46 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::utf16utf8
protectedinherited

Definition at line 45 of file encfiltmgr.h.


The documentation for this class was generated from the following files: