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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
<!-- HTML header for doxygen 1.8.3.1-->
<!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.3.1"/>
<title>Templates -- Meow: meowpp/oo/ObjDictionary.h 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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<link href="custom.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="projectlogo"><img alt="Logo" src="logo.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">Templates -- Meow
 <span id="projectnumber">1.1.2</span>
</div>
<div id="projectbrief">不能,也不應該先編譯成obj-file的templates</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('ObjDictionary_8h_source.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">ObjDictionary.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="ObjDictionary_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#ifndef oo_ObjDictionary_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="preprocessor"></span><span class="preprocessor">#define oo_ObjDictionary_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="preprocessor">#include "<a class="code" href="ObjBase_8h.html">ObjBase.h</a>"</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="preprocessor">#include "../Self.h"</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#include <string></span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#include <typeinfo></span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="preprocessor">#include <map></span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> </div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="preprocessor">#include <cstdio></span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="preprocessor">#include <cstdlib></span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> </div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="keyword">namespace </span>meow {</div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="keyword">template</span><<span class="keyword">class</span> Key, <span class="keyword">class</span> Value></div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html"> 23</a></span> <span class="keyword">class </span><a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a>: <span class="keyword">public</span> <a class="code" href="classmeow_1_1ObjBase.html" title="一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能">ObjBase</a> {</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="keyword">private</span>:</div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  <span class="keyword">struct </span>Myself {</div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  std::map<Key, Value> dictionary_;</div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  Myself() {</div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  }</div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  ~Myself() {</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  }</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  Myself& <a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285">copyFrom</a>(Myself <span class="keyword">const</span>& b) {</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  dictionary_ = b.dictionary_;</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  }</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  };</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <a class="code" href="classmeow_1_1Self.html">Self<Myself></a> <span class="keyword">const</span> <span class="keyword">self</span>;</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="keyword">public</span>:</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a1055d36aa3d4551def2abd9aa86b7662"> 38</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html#a1055d36aa3d4551def2abd9aa86b7662">ObjDictionary</a>(): self(true) {</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  }</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> </div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ab29251c7ae6e13058912106075ebe161"> 41</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html#ab29251c7ae6e13058912106075ebe161">ObjDictionary</a>(<a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a> <span class="keyword">const</span>& d): self(false) {</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keyword">self</span>.copyFrom(b.self);</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  }</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a59cf39f8704134a64090ecb59fff01aa"> 45</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html#a59cf39f8704134a64090ecb59fff01aa">ObjDictionary</a>(std::map<Key, Value> <span class="keyword">const</span>& d): self(true) {</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="keyword">self</span>()->dictionary_ = d;</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  }</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div>
<div class="line"><a name="l00049"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ab8eb8496153b57598e81e089eef89e08"> 49</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html#ab8eb8496153b57598e81e089eef89e08">~ObjDictionary</a>() {</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  }</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span> </div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285"> 52</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a>& <a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285">copyFrom</a>(<a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a> <span class="keyword">const</span>& d) {</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="keyword">self</span>().<a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285">copyFrom</a>(d.self);</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  }</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> </div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ab0a4c64950a5a89012a913202fac027b"> 57</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a>& <a class="code" href="classmeow_1_1ObjDictionary.html#ab0a4c64950a5a89012a913202fac027b">referenceFrom</a>(<a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a> <span class="keyword">const</span>& d) {</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="keyword">self</span>().<a class="code" href="classmeow_1_1ObjDictionary.html#ab0a4c64950a5a89012a913202fac027b">referenceFrom</a>(d.self);</div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</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"><a class="code" href="classmeow_1_1ObjDictionary.html#a0e265133214bd6b9f0dce6ce6dc6ca23"> 62</a></span>  <span class="keywordtype">size_t</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a0e265133214bd6b9f0dce6ce6dc6ca23">size</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>->dictionary_.size();</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  }</div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#afedaaaf1ed8b066a43d8e12081f6c878"> 65</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classmeow_1_1ObjDictionary.html#afedaaaf1ed8b066a43d8e12081f6c878">empty</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>->dictionary_.empty();</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> </div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a081d3cf0d190e6dd02208c1c49653ed7"> 69</a></span>  <span class="keywordtype">void</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a081d3cf0d190e6dd02208c1c49653ed7">clear</a>() {</div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <span class="keyword">self</span>()->dictionary_.clear();</div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  }</div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div>
<div class="line"><a name="l00073"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ae5f44ae004be8f10a1c9f5e65eeebc75"> 73</a></span>  std::map<Key, Value>::const_iterator <a class="code" href="classmeow_1_1ObjDictionary.html#ae5f44ae004be8f10a1c9f5e65eeebc75">end</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>->dictionary_.end();</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"><a class="code" href="classmeow_1_1ObjDictionary.html#aeb8765e90349daee27bcf9e6c2672676"> 77</a></span>  std::map<Key, Value>::iterator <a class="code" href="classmeow_1_1ObjDictionary.html#aeb8765e90349daee27bcf9e6c2672676">end</a>() {</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>()->dictionary_.end();</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  }</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span> </div>
<div class="line"><a name="l00081"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a1979f646a23bffdd01a9fe52e5a8aca1"> 81</a></span>  std::map<Key, Value>::const_iterator <a class="code" href="classmeow_1_1ObjDictionary.html#a1979f646a23bffdd01a9fe52e5a8aca1">find</a>(Key <span class="keyword">const</span>& k)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>->dictionary_.find(k);</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  }</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span> </div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a8f73bbc1d934566dd8a2087b145e3f48"> 85</a></span>  std::map<Key, Value>::iterator <a class="code" href="classmeow_1_1ObjDictionary.html#a8f73bbc1d934566dd8a2087b145e3f48">find</a>(Key <span class="keyword">const</span>& k) {</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>()->dictionary_.find(k);</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  }</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span> </div>
<div class="line"><a name="l00089"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ae60f2a947516d6d6f037cc106c00d3be"> 89</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classmeow_1_1ObjDictionary.html#ae60f2a947516d6d6f037cc106c00d3be">exist</a>(Key <span class="keyword">const</span>& k)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  <span class="keywordflow">return</span> (<a class="code" href="classmeow_1_1ObjDictionary.html#a1979f646a23bffdd01a9fe52e5a8aca1">find</a>() != <a class="code" href="classmeow_1_1ObjDictionary.html#ae5f44ae004be8f10a1c9f5e65eeebc75">end</a>());</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  }</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span> </div>
<div class="line"><a name="l00093"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a9784fbd0eaab219216abdcba4f326ead"> 93</a></span>  <span class="keywordtype">void</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a9784fbd0eaab219216abdcba4f326ead">insert</a>(Key <span class="keyword">const</span>& k, Value <span class="keyword">const</span>& v) {</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="keyword">self</span>->dictionary_.insert(std::pair<Key, Value>(k, v));</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  }</div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span> </div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a87b0f4542b07951f207a1c9d3e327c81"> 97</a></span>  <a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a>& <a class="code" href="classmeow_1_1ObjDictionary.html#a87b0f4542b07951f207a1c9d3e327c81">operator=</a>(<a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a> <span class="keyword">const</span>& a) {</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="keywordflow">return</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285">copyFrom</a>(a);</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  }</div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  </div>
<div class="line"><a name="l00101"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#ad22d7c7dc4d35417e9657eb88ca0dfbb"> 101</a></span>  Value& <a class="code" href="classmeow_1_1ObjDictionary.html#ad22d7c7dc4d35417e9657eb88ca0dfbb">operator[]</a>(Key <span class="keyword">const</span>& k) {</div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keywordflow">return</span> <span class="keyword">self</span>()->dictionary_[k];</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  }</div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span> </div>
<div class="line"><a name="l00105"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a2393452e9533fab679565068545f109c"> 105</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a2393452e9533fab679565068545f109c" title="將物件寫入檔案, 預設implement為直接回傳 false ">write</a>(FILE* f, <span class="keywordtype">bool</span> bin, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> fg)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="keywordtype">size_t</span> sz = <a class="code" href="classmeow_1_1ObjDictionary.html#a0e265133214bd6b9f0dce6ce6dc6ca23">size</a>();</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordflow">if</span> (bin) {</div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  <span class="keywordflow">if</span> (fwrite(&sz, <span class="keyword">sizeof</span>(<span class="keywordtype">size_t</span>), 1, f) < 1) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  }</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  <span class="keywordflow">if</span> (fprintf(f, <span class="stringliteral">"%lu\n"</span>, sz) < 1) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  }</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  <span class="keywordflow">for</span> (std::map<Key, Value>::const_iterator</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  it = self->dictionary_.begin(); it != <span class="keyword">self</span>->dictionary_.end(); ++it) {</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="keywordflow">if</span> (it->first .write(f, bin, fg) == <span class="keyword">false</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  <span class="keywordflow">if</span> (it->second.write(f, bin, fg) == <span class="keyword">false</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  }</div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  }</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span> </div>
<div class="line"><a name="l00121"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a0b1bd9fe09676aca74aec34bf5ea7137"> 121</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a0b1bd9fe09676aca74aec34bf5ea7137" title="將物件從檔案讀出, 預設implement為直接回傳 false ">read</a>(FILE* f, <span class="keywordtype">bool</span> bin, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> fg) {</div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="keywordtype">size_t</span> sz;</div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="keywordflow">if</span> (bin) {</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="keywordflow">if</span> (fread(&sz, <span class="keyword">sizeof</span>(<span class="keywordtype">size_t</span>), 1, f) < 1) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  }</div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="keywordflow">if</span> (fscanf(f, <span class="stringliteral">"%lu\n"</span>, &sz) < 0) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  }</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < sz; i++) {</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  Key k;</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  Value v;</div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keywordflow">if</span> (k.read(f, bin, fg) == <span class="keyword">false</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keywordflow">if</span> (v.read(f, bin, fg) == <span class="keyword">false</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <a class="code" href="classmeow_1_1ObjDictionary.html#a9784fbd0eaab219216abdcba4f326ead">insert</a>(k, v);</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  }</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  }</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  </div>
<div class="line"><a name="l00139"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a14ce0fcedf7619c0b442588e185a7eeb"> 139</a></span>  <a class="code" href="classmeow_1_1ObjBase.html" title="一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能">ObjBase</a>* <a class="code" href="classmeow_1_1ObjDictionary.html#a14ce0fcedf7619c0b442588e185a7eeb" title="回傳一個new出來的物件, 預設implement為直接回傳 NULL ">create</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classmeow_1_1ObjDictionary.html#a1055d36aa3d4551def2abd9aa86b7662">ObjDictionary</a>();</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  }</div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  </div>
<div class="line"><a name="l00143"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#a8f2e32f6eb11904c2547fae0ff9ab3d6"> 143</a></span>  <a class="code" href="classmeow_1_1ObjBase.html" title="一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能">ObjBase</a>* <a class="code" href="classmeow_1_1ObjDictionary.html#a8f2e32f6eb11904c2547fae0ff9ab3d6" title="複製, 預設使用operator=">copyFrom</a>(<a class="code" href="classmeow_1_1ObjBase.html" title="一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能">ObjBase</a> <span class="keyword">const</span>* b) {</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keywordflow">return</span> &(<a class="code" href="classmeow_1_1ObjDictionary.html#a7e50cbeeead963d95d661783ee2a9285">copyFrom</a>(*(<a class="code" href="classmeow_1_1ObjDictionary.html" title="純粹把 std::map 包起來, 變成繼承自 ObjBase">ObjDictionary</a>*)b));</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  }</div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  </div>
<div class="line"><a name="l00147"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#aee3a1722f6061987a242b9b33e5fcc64"> 147</a></span>  <span class="keywordtype">char</span> <span class="keyword">const</span>* <a class="code" href="classmeow_1_1ObjDictionary.html#aee3a1722f6061987a242b9b33e5fcc64" title="用C-style string回傳這個class的type name">ctype</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keywordflow">return</span> <span class="keyword">typeid</span>(*this).name();</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  }</div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  </div>
<div class="line"><a name="l00151"></a><span class="lineno"><a class="code" href="classmeow_1_1ObjDictionary.html#af5114823fcc2476aa45a965e4af66d6c"> 151</a></span>  std::string <a class="code" href="classmeow_1_1ObjDictionary.html#af5114823fcc2476aa45a965e4af66d6c" title="用std::string回傳這個class的type name">type</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  <span class="keywordflow">return</span> std::string(<a class="code" href="classmeow_1_1ObjDictionary.html#aee3a1722f6061987a242b9b33e5fcc64" title="用C-style string回傳這個class的type name">ctype</a>());</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  }</div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span> };</div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span> </div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span> }</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span> </div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="preprocessor">#endif // oo_ObjDictionary_H__</span></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_92fecd8d02dd5e7a67429447fdf0f60f.html">meowpp</a></li><li class="navelem"><a class="el" href="dir_540a4c8f2977878a343351220ffba92b.html">oo</a></li><li class="navelem"><a class="el" href="ObjDictionary_8h.html">ObjDictionary.h</a></li>
<li class="footer">Generated on Fri Jun 6 2014 17:51:46 for Templates -- Meow by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
</ul>
</div>
</body>
</html>
|