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

#include <encfiltmgr.h>

+ Inheritance diagram for EncodingFilterMgr:
+ Collaboration diagram for EncodingFilterMgr:

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)
 
 EncodingFilterMgr (char encoding=ENC_UTF8)
 
char getEncoding () const
 
virtual SWMgrgetParentMgr ()
 
void setEncoding (char enc)
 
virtual void setParentMgr (SWMgr *parentMgr)
 
 ~EncodingFilterMgr ()
 

Protected Attributes

char encoding
 
SWFilterlatin1utf8
 
SWFilterscsuutf8
 
SWFiltertargetenc
 
SWFilterutf16utf8
 

Detailed Description

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

Definition at line 40 of file encfiltmgr.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START EncodingFilterMgr::EncodingFilterMgr ( char  encoding = ENC_UTF8)

Constructor of SWEncodingMgr.

Parameters
encodingThe desired encoding.

Definition at line 55 of file encfiltmgr.cpp.

56  : SWFilterMgr() {
57 
58  scsuutf8 = new SCSUUTF8();
59  latin1utf8 = new Latin1UTF8();
60  utf16utf8 = new UTF16UTF8();
61 
62  encoding = enc;
63 
64  switch (encoding) {
65  case ENC_LATIN1: targetenc = new UTF8Latin1(); break;
66  case ENC_UTF16: targetenc = new UTF8UTF16(); break;
67  case ENC_RTF: targetenc = new UnicodeRTF(); break;
68  case ENC_HTML: targetenc = new UTF8HTML(); break;
69 #ifdef _ICU_
70  case ENC_SCSU: targetenc = new UTF8SCSU(); break;
71 #endif
72  default: // i.e. case ENC_UTF8
73  targetenc = NULL;
74  }
75 }
SWFilter * utf16utf8
Definition: encfiltmgr.h:45
SWFilter * targetenc
Definition: encfiltmgr.h:46
return NULL
Definition: regex.c:7953
SWFilter * latin1utf8
Definition: encfiltmgr.h:43
SWFilter * scsuutf8
Definition: encfiltmgr.h:44
EncodingFilterMgr::~EncodingFilterMgr ( )

The destructor of SWEncodingMgr.

Definition at line 81 of file encfiltmgr.cpp.

81  {
82  delete scsuutf8;
83  delete latin1utf8;
84  delete utf16utf8;
85  delete targetenc;
86 }
SWFilter * utf16utf8
Definition: encfiltmgr.h:45
SWFilter * targetenc
Definition: encfiltmgr.h:46
SWFilter * latin1utf8
Definition: encfiltmgr.h:43
SWFilter * scsuutf8
Definition: encfiltmgr.h:44

Member Function Documentation

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

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 
)
virtual

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 SWFilterMgr::addRenderFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

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 in MarkupFilterMgr, and DiathekeFilterMgr.

Definition at line 72 of file swfiltermgr.cpp.

72  {
73 }
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 }
char EncodingFilterMgr::Encoding ( char  enc)
inline

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
inline

getEncoding gets the encoding after initialization

Returns
The current encoding format.

Definition at line 81 of file encfiltmgr.h.

81 { return encoding; }
SWMgr * SWFilterMgr::getParentMgr ( )
virtualinherited

Definition at line 43 of file swfiltermgr.cpp.

43  {
44  return parentMgr;
45 }
SWMgr * parentMgr
Definition: swfiltermgr.h:39
void EncodingFilterMgr::setEncoding ( char  enc)

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 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
protected

Definition at line 52 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::latin1utf8
protected

Definition at line 43 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::scsuutf8
protected

Definition at line 44 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::targetenc
protected

Definition at line 46 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::utf16utf8
protected

Definition at line 45 of file encfiltmgr.h.


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