blob: caa1466e6d48c64588eae31b2c4b2abcbb73a63b (
plain) (
tree)
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>encfiltmgr.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>encfiltmgr.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * swencodingmgr.cpp - implementaion of class EncodingFilterMgr, subclass of</font>
00003 <font class="comment"> * used to transcode all module text to a requested</font>
00004 <font class="comment"> * encoding.</font>
00005 <font class="comment"> *</font>
00006 <font class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</font>
00007 <font class="comment"> * CrossWire Bible Society</font>
00008 <font class="comment"> * P. O. Box 2528</font>
00009 <font class="comment"> * Tempe, AZ 85280-2528</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * This program is free software; you can redistribute it and/or modify it</font>
00012 <font class="comment"> * under the terms of the GNU General Public License as published by the</font>
00013 <font class="comment"> * Free Software Foundation version 2.</font>
00014 <font class="comment"> *</font>
00015 <font class="comment"> * This program is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"> *</font>
00020 <font class="comment"> */</font>
00021
00022 <font class="preprocessor">#include <encfiltmgr.h></font>
00023
00024 <font class="preprocessor">#include <scsuutf8.h></font>
00025 <font class="preprocessor">#include <latin1utf8.h></font>
00026
00027 <font class="preprocessor">#include <unicodertf.h></font>
00028 <font class="preprocessor">#include <utf8latin1.h></font>
00029 <font class="preprocessor">#include <utf8utf16.h></font>
00030 <font class="preprocessor">#include <utf8html.h></font>
00031
00032 <font class="preprocessor">#include <swmgr.h></font>
00033
00034 <font class="comment">/******************************************************************************</font>
00035 <font class="comment"> * EncodingFilterMgr Constructor - initializes instance of EncodingFilterMgr</font>
00036 <font class="comment"> *</font>
00037 <font class="comment"> * ENT:</font>
00038 <font class="comment"> * enc - Encoding format to emit</font>
00039 <font class="comment"> */</font>
00040
<a name="l00041"></a><a class="code" href="class_encoding_filter_mgr.html#a0">00041</a> <a class="code" href="class_encoding_filter_mgr.html#a0">EncodingFilterMgr::EncodingFilterMgr</a> (<font class="keywordtype">char</font> enc)
00042 : SWFilterMgr() {
00043
00044 scsuutf8 = <font class="keyword">new</font> <a class="code" href="class_s_c_s_u_u_t_f8.html">SCSUUTF8</a>();
00045 latin1utf8 = <font class="keyword">new</font> <a class="code" href="class_latin1_u_t_f8.html">Latin1UTF8</a>();
00046
00047 encoding = enc;
00048
00049 <font class="keywordflow">switch</font> (encoding) {
00050 <font class="keywordflow">case</font> ENC_LATIN1:
00051 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_latin1.html">UTF8Latin1</a>();
00052 <font class="keywordflow">break</font>;
00053 <font class="keywordflow">case</font> ENC_UTF16:
00054 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_u_t_f16.html">UTF8UTF16</a>();
00055 <font class="keywordflow">break</font>;
00056 <font class="keywordflow">case</font> ENC_RTF:
00057 targetenc = <font class="keyword">new</font> <a class="code" href="class_unicode_r_t_f.html">UnicodeRTF</a>();
00058 <font class="keywordflow">break</font>;
00059 <font class="keywordflow">case</font> ENC_HTML:
00060 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_h_t_m_l.html">UTF8HTML</a>();
00061 <font class="keywordflow">break</font>;
00062 <font class="keywordflow">default</font>: <font class="comment">// i.e. case ENC_UTF8</font>
00063 targetenc = NULL;
00064 }
00065 }
00066
00067 <font class="comment">/******************************************************************************</font>
00068 <font class="comment"> * EncodingFilterMgr Destructor - Cleans up instance of EncodingFilterMgr</font>
00069 <font class="comment"> */</font>
<a name="l00070"></a><a class="code" href="class_encoding_filter_mgr.html#a1">00070</a> <a class="code" href="class_encoding_filter_mgr.html#a1">EncodingFilterMgr::~EncodingFilterMgr</a>() {
00071 <font class="keywordflow">if</font> (scsuutf8)
00072 <font class="keyword">delete</font> scsuutf8;
00073 <font class="keywordflow">if</font> (latin1utf8)
00074 <font class="keyword">delete</font> latin1utf8;
00075 <font class="keywordflow">if</font> (targetenc)
00076 <font class="keyword">delete</font> targetenc;
00077 }
00078
<a name="l00079"></a><a class="code" href="class_encoding_filter_mgr.html#a3">00079</a> <font class="keywordtype">void</font> <a class="code" href="class_encoding_filter_mgr.html#a3">EncodingFilterMgr::AddRawFilters</a>(<a class="code" href="class_s_w_module.html">SWModule</a> *module, ConfigEntMap &section) {
00080
00081 ConfigEntMap::iterator entry;
00082
00083 string encoding = ((entry = section.find(<font class="stringliteral">"Encoding"</font>)) != section.end()) ? (*entry).second : (string)<font class="stringliteral">""</font>;
00084 <font class="keywordflow">if</font> (encoding.empty() || !stricmp(encoding.c_str(), <font class="stringliteral">"Latin-1"</font>)) {
00085 module-><a class="code" href="class_s_w_module.html#a51">AddRawFilter</a>(latin1utf8);
00086 }
00087 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!stricmp(encoding.c_str(), <font class="stringliteral">"SCSU"</font>)) {
00088 module-><a class="code" href="class_s_w_module.html#a51">AddRawFilter</a>(scsuutf8);
00089 }
00090 }
00091
<a name="l00092"></a><a class="code" href="class_encoding_filter_mgr.html#a4">00092</a> <font class="keywordtype">void</font> <a class="code" href="class_encoding_filter_mgr.html#a4">EncodingFilterMgr::AddEncodingFilters</a>(<a class="code" href="class_s_w_module.html">SWModule</a> *module, ConfigEntMap &section) {
00093 <font class="keywordflow">if</font> (targetenc)
00094 module-><a class="code" href="class_s_w_module.html#a45">AddEncodingFilter</a>(targetenc);
00095 }
00096
00097 <font class="comment">/******************************************************************************</font>
00098 <font class="comment"> * EncodingFilterMgr::Encoding - sets/gets encoding</font>
00099 <font class="comment"> *</font>
00100 <font class="comment"> * ENT: enc - new encoding or 0 to simply get the current encoding</font>
00101 <font class="comment"> *</font>
00102 <font class="comment"> * RET: encoding</font>
00103 <font class="comment"> */</font>
<a name="l00104"></a><a class="code" href="class_encoding_filter_mgr.html#a2">00104</a> <font class="keywordtype">char</font> <a class="code" href="class_encoding_filter_mgr.html#a2">EncodingFilterMgr::Encoding</a>(<font class="keywordtype">char</font> enc) {
00105 <font class="keywordflow">if</font> (enc && enc != encoding) {
00106 encoding = enc;
00107 SWFilter * oldfilter = targetenc;
00108
00109 <font class="keywordflow">switch</font> (encoding) {
00110 <font class="keywordflow">case</font> ENC_LATIN1:
00111 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_latin1.html">UTF8Latin1</a>();
00112 <font class="keywordflow">break</font>;
00113 <font class="keywordflow">case</font> ENC_UTF16:
00114 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_u_t_f16.html">UTF8UTF16</a>();
00115 <font class="keywordflow">break</font>;
00116 <font class="keywordflow">case</font> ENC_RTF:
00117 targetenc = <font class="keyword">new</font> <a class="code" href="class_unicode_r_t_f.html">UnicodeRTF</a>();
00118 <font class="keywordflow">break</font>;
00119 <font class="keywordflow">case</font> ENC_HTML:
00120 targetenc = <font class="keyword">new</font> <a class="code" href="class_u_t_f8_h_t_m_l.html">UTF8HTML</a>();
00121 <font class="keywordflow">break</font>;
00122 <font class="keywordflow">default</font>: <font class="comment">// i.e. case ENC_UTF8</font>
00123 targetenc = NULL;
00124 }
00125
00126 ModMap::const_iterator module;
00127
00128 <font class="keywordflow">if</font> (oldfilter != targetenc) {
00129 <font class="keywordflow">if</font> (oldfilter) {
00130 <font class="keywordflow">if</font> (!targetenc) {
00131 <font class="keywordflow">for</font> (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00132 module->second->RemoveRenderFilter(oldfilter);
00133 }
00134 <font class="keywordflow">else</font> {
00135 <font class="keywordflow">for</font> (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00136 module->second->ReplaceRenderFilter(oldfilter, targetenc);
00137 }
00138 <font class="keyword">delete</font> oldfilter;
00139 }
00140 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (targetenc) {
00141 <font class="keywordflow">for</font> (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
00142 module->second->AddRenderFilter(targetenc);
00143 }
00144 }
00145
00146 }
00147 <font class="keywordflow">return</font> encoding;
00148 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:58 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>
|