?? chmxx_8h-source.html
字號:
00161 {00162 size_t result = 0;00163 <span class="keywordtype">int</span> shift = 0;00164 00165 <span class="keywordflow">while</span> (1) {00166 <span class="keywordtype">int</span> n = get();00167 result |= (n & 0x7f) << shift;00168 shift += 7;00169 <span class="keywordflow">if</span> ( !(n & 0x80) ) <span class="keywordflow">break</span>;00170 };00171 00172 <span class="keywordflow">return</span> result;00173 }00174 <a name="l00176"></a><a class="code" href="classchm_1_1chmistream.html#a4">00176</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classchm_1_1chmistream.html#a4">get_dword</a> ()00177 {00178 <span class="preprocessor">#if __BYTE_ORDER == __LITTLE_ENDIAN // convenience shortcut</span>00179 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> res = 0; <span class="comment">// long guatanteed to be 4 bytes</span>00180 read ((<span class="keywordtype">char</span> *)&res, 4);00181 <span class="keywordflow">return</span> res;00182 <span class="preprocessor">#else</span>00183 <span class="preprocessor"></span> <span class="keywordtype">char</span> buf[4];00184 read (buf, 4);00185 size_t res = buf[0];00186 res |= buf[1] << 8;00187 res |= buf[2] << 16;00188 res |= buf[3] << 24;00189 <span class="keywordflow">return</span> res;00190 <span class="preprocessor">#endif</span>00191 <span class="preprocessor"></span> }00192 <a name="l00195"></a><a class="code" href="classchm_1_1chmistream.html#a5">00195</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classchm_1_1chmistream.html#a5">get_word</a> ()00196 {00197 <span class="preprocessor">#if __BYTE_ORDER == __LITTLE_ENDIAN // convenience shortcut</span>00198 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> res = 0; <span class="comment">// int guaranteed to be 2 bytes</span>00199 read ((<span class="keywordtype">char</span> *)&res, 2);00200 <span class="keywordflow">return</span> res;00201 <span class="preprocessor">#else</span>00202 <span class="preprocessor"></span> <span class="keywordtype">char</span> buf[2];00203 read (buf, 2);00204 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> res = buf[0];00205 res |= buf[1] << 8;00206 <span class="keywordflow">return</span> res;00207 <span class="preprocessor">#endif</span>00208 <span class="preprocessor"></span> }00209 <a name="l00213"></a><a class="code" href="classchm_1_1chmistream.html#a6">00213</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classchm_1_1chmistream.html#a6">get_sr</a> (<span class="keywordtype">int</span> s, <span class="keywordtype">int</span> r, <span class="keywordtype">int</span>& pos)00214 {00215 <span class="keywordtype">int</span> b = peek();00216 <span class="keywordtype">int</span> p = 0;00217 <span class="keywordflow">while</span> ( (1 << pos) & b ) {00218 p++;00219 pos++;00220 <span class="keywordflow">if</span> ( pos == 8 ) {00221 get();00222 b = peek ();00223 pos = 0;00224 }00225 }00226 00227 pos++; <span class="comment">// skip the 0 of p</span>00228 <span class="keywordflow">if</span> ( pos == 8 ) {00229 get ();00230 b = peek ();00231 pos = 0;00232 }00233 00234 <span class="keywordflow">if</span> ( p > 1 ) r += p - 1; <span class="comment">// r now has number of bits for q</span>00235 00236 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> res = 0;00237 00238 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < r; i++ ) {00239 res |= ((1 << pos) & b) ? (1 << i) : 0;00240 pos++;00241 <span class="keywordflow">if</span> ( pos == 8 ) {00242 get ();00243 b = peek ();00244 pos = 0;00245 }00246 }00247 00248 res |= 1 << r;00249 00250 <span class="keywordflow">return</span> res;00251 }00252 <a name="l00253"></a><a class="code" href="classchm_1_1chmistream.html#a7">00253</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classchm_1_1chmistream.html#a7">get_sr_finish</a> (<span class="keywordtype">int</span> &pos)00254 {00255 <span class="keywordflow">if</span> ( pos ) {00256 get();00257 pos = 0;00258 }00259 }00260 00261 <span class="keyword">private</span>:00262 std::streambuf *buf;00263 <span class="keywordtype">bool</span> release;00264 };00265 00266 }00267 00268 <span class="preprocessor">#endif // __chm_h__</span>00269 <span class="preprocessor"></span></pre></div><hr>Copyright © 2003 Indrek Mandre <script language="JavaScript"> document.write ('<<a href="mailto:indrek' + '@' + 'mare.ee">indrek' + '@' + 'mare.ee</a>>');</script><p> </p>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -