Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

EncodingFilterMgr Class Reference

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

#include <encfiltmgr.h>

Inheritance diagram for EncodingFilterMgr:

Inheritance graph
[legend]
List of all members.

Public Methods

 EncodingFilterMgr (char encoding=ENC_UTF8)
 Constructor of SWEncodingMgr. More...

 ~EncodingFilterMgr ()
 The destructor of SWEncodingMgr.

char Encoding (char enc)
 Markup sets/gets the encoding after initialization. More...

virtual void AddRawFilters (SWModule *module, ConfigEntMap &section)
 Adds the raw filters which are defined in "section" to the SWModule object "module". More...

virtual void AddEncodingFilters (SWModule *module, ConfigEntMap &section)
 Adds the encoding filters which are defined in "section" to the SWModule object "module". More...


Protected Attributes

SWFilter * latin1utf8
SWFilter * scsuutf8
SWFilter * targetenc
char encoding

Detailed Description

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

Definition at line 33 of file encfiltmgr.h.


Constructor & Destructor Documentation

EncodingFilterMgr::EncodingFilterMgr char    encoding = ENC_UTF8
 

Constructor of SWEncodingMgr.

Parameters:
iconfig 
isysconfig 
autoload  If this bool is true the constructor starts loading the installed modules. If you reimplemented SWMgr you can set autoload=false to load the modules with your own reimplemented function.
encoding  The desired encoding.

Definition at line 41 of file encfiltmgr.cpp.

00042                    : SWFilterMgr() {
00043 
00044         scsuutf8 = new SCSUUTF8();
00045         latin1utf8 = new Latin1UTF8();
00046 
00047         encoding = enc;
00048 
00049         switch (encoding) {
00050         case ENC_LATIN1:
00051                 targetenc = new UTF8Latin1();
00052                 break;
00053         case ENC_UTF16:
00054                 targetenc = new UTF8UTF16();
00055                 break;
00056         case ENC_RTF:
00057                 targetenc = new UnicodeRTF();
00058                 break;
00059         case ENC_HTML:
00060                 targetenc = new UTF8HTML();
00061                 break;
00062         default: // i.e. case ENC_UTF8
00063                 targetenc = NULL;
00064         }
00065 }


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:
module  To this module the encoding filter(s) are added
section  We use this section to get a list of filters we should apply to the module

Definition at line 92 of file encfiltmgr.cpp.

References SWModule::AddEncodingFilter().

00092                                                                                   {
00093         if (targetenc)
00094                 module->AddEncodingFilter(targetenc);
00095 }

void EncodingFilterMgr::AddRawFilters SWModule   module,
ConfigEntMap &    section
[virtual]
 

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

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

Definition at line 79 of file encfiltmgr.cpp.

References SWModule::AddRawFilter().

00079                                                                              {
00080 
00081         ConfigEntMap::iterator entry;
00082 
00083         string encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (string)"";
00084         if (encoding.empty() || !stricmp(encoding.c_str(), "Latin-1")) {
00085                 module->AddRawFilter(latin1utf8);
00086         }
00087         else if (!stricmp(encoding.c_str(), "SCSU")) {
00088                 module->AddRawFilter(scsuutf8);
00089         }
00090 }

char EncodingFilterMgr::Encoding char    enc
 

Markup sets/gets the encoding after initialization.

Parameters:
m  The new encoding or ENC_UNKNOWN if you just want to get the current markup.
Returns:
The current (possibly changed) encoding format.

Definition at line 104 of file encfiltmgr.cpp.

00104                                          {
00105         if (enc && enc != encoding) {
00106                 encoding = enc;
00107                 SWFilter * oldfilter = targetenc;
00108                 
00109                 switch (encoding) {
00110                 case ENC_LATIN1:
00111                         targetenc = new UTF8Latin1();
00112                         break;
00113                 case ENC_UTF16:
00114                         targetenc = new UTF8UTF16();
00115                         break;
00116                 case ENC_RTF:
00117                         targetenc = new UnicodeRTF();
00118                         break;
00119                 case ENC_HTML:
00120                         targetenc = new UTF8HTML();
00121                         break;
00122                 default: // i.e. case ENC_UTF8
00123                         targetenc = NULL;
00124                 }
00125 
00126                 ModMap::const_iterator module;
00127 
00128                 if (oldfilter != targetenc) {
00129                         if (oldfilter) {
00130                                 if (!targetenc) {
00131                                         for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00132                                                 module->second->RemoveRenderFilter(oldfilter);
00133                                 }
00134                                 else {
00135                                         for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00136                                                 module->second->ReplaceRenderFilter(oldfilter, targetenc);
00137                                 }
00138                                 delete oldfilter;
00139                         }
00140                         else if (targetenc) {
00141                                 for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00142                                         module->second->AddRenderFilter(targetenc);
00143                         }
00144                 }
00145 
00146         }
00147         return encoding;
00148 }


The documentation for this class was generated from the following files:
Generated on Thu Jun 20 22:13:02 2002 for The Sword Project by doxygen1.2.15