/usr/share/opencc/doc/html/_serializable_dict_8hpp_source.html is in libopencc2-data 1.0.4-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Open Chinese Convert: SerializableDict.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Open Chinese Convert
 <span id="projectnumber">1.0.4</span>
</div>
<div id="projectbrief">A project for conversion between Traditional and Simplified Chinese</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">SerializableDict.hpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Open Chinese Convert</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * Copyright 2010-2014 BYVoid <byvoid@byvoid.com></span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> *</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * You may obtain a copy of the License at</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> *</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> *</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * limitations under the License.</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> */</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> </div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> </div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include "Dict.hpp"</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="keyword">namespace </span><a class="code" href="namespaceopencc.html">opencc</a> {</div><div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="classopencc_1_1_serializable_dict.html"> 28</a></span> <span class="keyword">class </span>OPENCC_EXPORT <a class="code" href="classopencc_1_1_serializable_dict.html">SerializableDict</a> {</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> SerializeToFile(FILE* fp) <span class="keyword">const</span> = 0;</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> </div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="classopencc_1_1_serializable_dict.html#ac9b353c5ffd930744cdeed1d39431eb3"> 38</a></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classopencc_1_1_serializable_dict.html#ac9b353c5ffd930744cdeed1d39431eb3">SerializeToFile</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& fileName)<span class="keyword"> const </span>{</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  FILE* fp = fopen(fileName.c_str(), <span class="stringliteral">"wb"</span>);</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keywordflow">if</span> (fp == NULL) {</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="keywordflow">throw</span> <a class="code" href="classopencc_1_1_file_not_writable.html">FileNotWritable</a>(fileName);</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  }</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  SerializeToFile(fp);</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  fclose(fp);</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  }</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> </div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> DICT></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> TryLoadFromFile(<span class="keyword">const</span> <span class="keywordtype">string</span>& fileName,</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  std::shared_ptr<DICT>* dict) {</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  FILE* fp =</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span> <span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="comment">// well, the 'GetPlatformString' shall return a 'wstring'</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  _wfopen(UTF8Util::GetPlatformString(fileName).c_str(), L<span class="stringliteral">"rb"</span>)</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  fopen(UTF8Util::GetPlatformString(fileName).c_str(), <span class="stringliteral">"rb"</span>)</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="preprocessor">#endif // _MSC_VER</span></div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  ;</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keywordflow">if</span> (fp == NULL) {</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  }</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  std::shared_ptr<DICT> loadedDict = DICT::NewFromFile(fp);</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  fclose(fp);</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  *dict = loadedDict;</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  }</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> </div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> DICT></div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <span class="keyword">static</span> std::shared_ptr<DICT> NewFromFile(<span class="keyword">const</span> <span class="keywordtype">string</span>& fileName) {</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  std::shared_ptr<DICT> dict;</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="keywordflow">if</span> (!TryLoadFromFile<DICT>(fileName, &dict)) {</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keywordflow">throw</span> <a class="code" href="classopencc_1_1_file_not_found.html">FileNotFound</a>(fileName);</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  }</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <span class="keywordflow">return</span> dict;</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  }</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span> };</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> }</div><div class="ttc" id="classopencc_1_1_serializable_dict_html_ac9b353c5ffd930744cdeed1d39431eb3"><div class="ttname"><a href="classopencc_1_1_serializable_dict.html#ac9b353c5ffd930744cdeed1d39431eb3">opencc::SerializableDict::SerializeToFile</a></div><div class="ttdeci">virtual void SerializeToFile(const string &fileName) const</div><div class="ttdoc">Serializes the dictionary and writes in to a file. </div><div class="ttdef"><b>Definition:</b> SerializableDict.hpp:38</div></div>
<div class="ttc" id="classopencc_1_1_serializable_dict_html"><div class="ttname"><a href="classopencc_1_1_serializable_dict.html">opencc::SerializableDict</a></div><div class="ttdoc">Serializable dictionary interface. </div><div class="ttdef"><b>Definition:</b> SerializableDict.hpp:28</div></div>
<div class="ttc" id="classopencc_1_1_file_not_found_html"><div class="ttname"><a href="classopencc_1_1_file_not_found.html">opencc::FileNotFound</a></div><div class="ttdef"><b>Definition:</b> Exception.hpp:49</div></div>
<div class="ttc" id="namespaceopencc_html"><div class="ttname"><a href="namespaceopencc.html">opencc</a></div><div class="ttdef"><b>Definition:</b> BinaryDict.hpp:24</div></div>
<div class="ttc" id="classopencc_1_1_file_not_writable_html"><div class="ttname"><a href="classopencc_1_1_file_not_writable.html">opencc::FileNotWritable</a></div><div class="ttdef"><b>Definition:</b> Exception.hpp:55</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Jan 20 2017 07:15:35 for Open Chinese Convert by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
|