﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-hdqqq-随笔分类-c/c++</title><link>http://www.cppblog.com/hdqqq/category/909.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 03 Jul 2015 09:20:16 GMT</lastBuildDate><pubDate>Fri, 03 Jul 2015 09:20:16 GMT</pubDate><ttl>60</ttl><item><title>模板实现的红黑树</title><link>http://www.cppblog.com/hdqqq/archive/2009/11/20/101450.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 20 Nov 2009 01:53:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2009/11/20/101450.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/101450.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2009/11/20/101450.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/101450.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/101450.html</trackback:ping><description><![CDATA[&nbsp; 自己用模板实现的红黑树,算是对红黑树有了一个深入的了解.<br>&nbsp; 测试代码如下:<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">iostream</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">rb_tree.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;test()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;rb_tree</span><span style="color: #000000;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">,&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;ltree;<br>&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">the&nbsp;tree&nbsp;is&nbsp;empty:&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;(ltree.empty()&nbsp;</span><span style="color: #000000;">?</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">true</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;:&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">false</span><span style="color: #000000;">"</span><span style="color: #000000;">)&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;std::endl;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">15</span><span style="color: #000000;">;&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ltree.insert(i,&nbsp;i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;ltree.show_tree();<br>}<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;main(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;argc,&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;argv[])<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;test();<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}<br></span></div>
&nbsp; 红黑树的代码位置:<br>&nbsp; http://www.cppblog.com/Files/hdqqq/rb_tree.zip<br><img src ="http://www.cppblog.com/hdqqq/aggbug/101450.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2009-11-20 09:53 <a href="http://www.cppblog.com/hdqqq/archive/2009/11/20/101450.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个自画的list control</title><link>http://www.cppblog.com/hdqqq/archive/2008/07/14/56084.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Mon, 14 Jul 2008 04:05:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2008/07/14/56084.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/56084.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2008/07/14/56084.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/56084.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/56084.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 界面开发 自定义 list control&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2008/07/14/56084.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/56084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2008-07-14 12:05 <a href="http://www.cppblog.com/hdqqq/archive/2008/07/14/56084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在IE中增加文字内容收集功能</title><link>http://www.cppblog.com/hdqqq/archive/2007/12/21/39180.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 21 Dec 2007 01:18:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/12/21/39180.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/39180.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/12/21/39180.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/39180.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/39180.html</trackback:ping><description><![CDATA[<p>这几天在网上下电子书,准备放到手机上看,在网页上ctrl+c ,然后ctrl+v到记事本,太麻烦了,<br>于是写了个ie的右键菜单处理,直接在ie里面存到文本文件里面<br><br>把下面的javascript存成一个htm文件<br><br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">script&nbsp;language</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">javascript</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;&nbsp;fso,ForAppending,ts;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;fso</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;&nbsp;ActiveXObject(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Scripting.FileSystemObject</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;ForAppending&nbsp;&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;&nbsp;</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;ts&nbsp;&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">fso.OpenTextFile(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">c:\\collect.txt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,ForAppending,</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">在这里是一个决对路经，用的时候必须修改&nbsp;&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;ts.WriteLine(external.menuArguments.document.selection.createRange().text);<br>&nbsp;&nbsp;&nbsp;ts.WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#########################</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;ts.close();&nbsp;&nbsp;<br></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span></div>
<p><br><br>然后在注册表中添加下面的项<br>HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\信息收集(&amp;Q)</p>
<p>&nbsp;</p>
<p>设置两个键值</p>
<p>默认 D:\rocket\Download\pagehook.htm&nbsp;&nbsp; //即先前存的htm文件,需要绝对路径<br>contexts 243</p>
<p>就可以了,以后就可以在ie里面收集你要的文本了.<br>使用的时候,先用鼠标选择你需要的文字,然后右键选"信息收集"菜单,就可以把选择的文字<br>存储到c:\collect.txt 中了.</p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/39180.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-12-21 09:18 <a href="http://www.cppblog.com/hdqqq/archive/2007/12/21/39180.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gcc 中std::list 的size()成员函数</title><link>http://www.cppblog.com/hdqqq/archive/2007/12/11/38216.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Tue, 11 Dec 2007 03:56:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/12/11/38216.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/38216.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/12/11/38216.html#Feedback</comments><slash:comments>18</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/38216.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/38216.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: gcc 的STL 中 list ::size() 使用需要注意的问题&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2007/12/11/38216.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/38216.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-12-11 11:56 <a href="http://www.cppblog.com/hdqqq/archive/2007/12/11/38216.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关闭xp文件保护</title><link>http://www.cppblog.com/hdqqq/archive/2007/11/15/36662.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Thu, 15 Nov 2007 03:13:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/11/15/36662.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/36662.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/11/15/36662.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/36662.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/36662.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: windows 关闭文件保护功能.&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2007/11/15/36662.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/36662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-11-15 11:13 <a href="http://www.cppblog.com/hdqqq/archive/2007/11/15/36662.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>手工编译boost的bjam</title><link>http://www.cppblog.com/hdqqq/archive/2007/09/20/32541.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Thu, 20 Sep 2007 06:00:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/09/20/32541.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/32541.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/09/20/32541.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/32541.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/32541.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: boost bjam&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2007/09/20/32541.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/32541.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-09-20 14:00 <a href="http://www.cppblog.com/hdqqq/archive/2007/09/20/32541.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>显示字符串的函数</title><link>http://www.cppblog.com/hdqqq/archive/2007/07/31/29063.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Tue, 31 Jul 2007 02:51:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/07/31/29063.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/29063.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/07/31/29063.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/29063.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/29063.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 简单的模板显示字符串函数,简化使用.&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2007/07/31/29063.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/29063.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-07-31 10:51 <a href="http://www.cppblog.com/hdqqq/archive/2007/07/31/29063.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建一个基于模板的数据库记录集操作类(四)</title><link>http://www.cppblog.com/hdqqq/archive/2007/03/26/20597.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Mon, 26 Mar 2007 03:18:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/03/26/20597.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/20597.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/03/26/20597.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/20597.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/20597.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 模板, ADO 数据库操作&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2007/03/26/20597.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/20597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-03-26 11:18 <a href="http://www.cppblog.com/hdqqq/archive/2007/03/26/20597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建一个基于模板的数据库记录集操作类(三)</title><link>http://www.cppblog.com/hdqqq/archive/2007/01/31/18195.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Wed, 31 Jan 2007 01:15:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/01/31/18195.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/18195.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/01/31/18195.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/18195.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/18195.html</trackback:ping><description><![CDATA[
		<p>创建一个基于模板的数据库记录集操作类(三)</p>
		<p>
				<br />ado封装<br />前面讲了建立一个记录的结构和对variant数据结构进行转换,在这篇里面,对ado接口进行封装.微软的ado数据操作接口是以com的形式发布的,在用import指令对com的动态库进行导入之后,会在工程的输出目录下生成tlh和tli两个文件,tlh是于c和c++用于操作com接口的头文件,在其中声明了一些 com接口和com对象的 IID和CLSID,还有接口的属性和方法,都以c/c++可以用的形式做了转换,那个tli文件其实就是tlh文件中声明的一些结构的成员函数的实现,被tlh文件包含.在tlh文件中,通过宏_COM_SMARTPTR_TYPEDEF用模板类_com_ptr_t对接口进行了包装,</p>
		<p>
				<br />_COM_SMARTPTR_TYPEDEF是一个很奇怪的宏,最终生成的是一个以Ptr结尾的类如:<br />_COM_SMARTPTR_TYPEDEF(Field15, __uuidof(Field15));<br />实际上生成的类的名称是Field15Ptr类, 类型是_com_ptr_t&lt;Field15, __uuidof(Field15)&gt;</p>
		<p>在我实现的模板类中,没有打算在类的整个生命周期中拥有一个ADO接口的记录集成员或者或者ADO连接,我只打算在一些成员函数中,通过局部变量来使用ADO接口.所以对ado进行了部分的封装.<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">#define MAKE_ADO_COM_CLASS_TYPEDEF(e) typedef CComWrapper</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> e##Ptr </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> CCom##e<br /><br />template </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #0000ff">typename</span>
				<span style="COLOR: #000000"> com_class</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />class CComWrapper : </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> com_class<br />{<br /></span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000">:<br />    void CreateInstance() {<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">;<br />    }<br /></span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:    <br />    <br />    com_class </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> operator</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> com_class</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> cp) {<br />        com_class::operator</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">(cp);<br />        return </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">this;<br />    }<br />    <br />    CComWrapper() {}<br />    <br />    CComWrapper(CLSID uid) {<br />        ::CoInitialize(</span>
				<span style="COLOR: #0000ff">NULL</span>
				<span style="COLOR: #000000">);<br />        HRESULT hr </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> com_class::CreateInstance(uid);<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (FAILED(hr)) {<br />            </span>
				<span style="COLOR: #000000">//</span>
				<span style="COLOR: #000000">AfxMessageBox(_T(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Create Com Object Error!</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">));<br />            TRACE(_T(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Create Com Object Error!\n</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">));<br />        }<br />    }<br />    <br />    ~CComWrapper() {<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (GetInterfacePtr())<br />            com_class::Release();<br />    }<br />};<br /><br /><br />MAKE_ADO_COM_CLASS_TYPEDEF(_Collection);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_DynaCollection);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_ADO);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Properties);<br />MAKE_ADO_COM_CLASS_TYPEDEF(</span>
				<span style="COLOR: #0000ff">Property</span>
				<span style="COLOR: #000000">);<br />MAKE_ADO_COM_CLASS_TYPEDEF(</span>
				<span style="COLOR: #0000ff">Error</span>
				<span style="COLOR: #000000">);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Errors);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Command15);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Connection15);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Connection);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Recordset15);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Recordset20);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Recordset21);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Recordset);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Fields15);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Fields20);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Fields);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Field20);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Field);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Parameter);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Parameters);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Command25);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Command);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ConnectionEventsVt);<br />MAKE_ADO_COM_CLASS_TYPEDEF(RecordsetEventsVt);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ConnectionEvents);<br />MAKE_ADO_COM_CLASS_TYPEDEF(RecordsetEvents);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADOConnectionConstruction15);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADOConnectionConstruction);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Record);<br />MAKE_ADO_COM_CLASS_TYPEDEF(_Stream);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADORecordConstruction);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADOStreamConstruction);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADOCommandConstruction);<br />MAKE_ADO_COM_CLASS_TYPEDEF(ADORecordsetConstruction);<br />MAKE_ADO_COM_CLASS_TYPEDEF(Field15);</span>
		</div>
		<br />在上面的代码中,通过一个模板类CComWrapper,对ado生成的Ptr类型作了继承,主要是在析构函数中自动释放接口.同时,我把tlh和tli着两个文件改成了一个h文件和一个inl文件,这样在使用的时候,就不用再使用import指令了.<br /><img src ="http://www.cppblog.com/hdqqq/aggbug/18195.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-01-31 09:15 <a href="http://www.cppblog.com/hdqqq/archive/2007/01/31/18195.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建一个基于模板的数据库记录集操作类(二)</title><link>http://www.cppblog.com/hdqqq/archive/2007/01/22/17894.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Mon, 22 Jan 2007 09:33:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/01/22/17894.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/17894.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/01/22/17894.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/17894.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/17894.html</trackback:ping><description><![CDATA[       上一篇讲到了根据一个typelist实现一个结构,这个结构带有typelist中所有类型的成员,同时,可以通过Field0,Field1等接口访问和赋值.在这个基础上,我们可以构建对应一条记录的结构data_row,<br /><br />二.一条记录<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#define ROW_NO_CHANGE </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"><br />#define ROW_ADD </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><br />#define ROW_UPDATE </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"><br />#define ROW_DELETE </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000"><br /><br />template</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">typename</span><span style="COLOR: #000000"> _tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />class data_op_record_row : </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> struct_mem</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />{<br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    enum _enum_RowState {<br />        _en_Row_NoChange </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ROW_NO_CHANGE,    </span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">未修改<br />        _en_Row_Add </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ROW_ADD,            </span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">新增记录<br />        _en_Row_Update </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ROW_UPDATE,        </span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">更新<br />        _en_Row_Del </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ROW_DELETE,        </span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">删除<br />    } m_en_State;<br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    void SetState(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> newstate) {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (m_en_State !</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> newstate) {<br />            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (newstate </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> _en_Row_NoChange || <br />                newstate </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> _en_Row_Add || <br />                newstate </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> _en_Row_Update || <br />                newstate </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> _en_Row_Del) <br />            {<br />                m_en_State </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (_enum_RowState)newstate;<br />            }<br />        }<br />    }<br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    data_op_record_row () : m_en_State(_en_Row_NoChange) {}<br />    ~data_op_record_row (){}<br />protected:<br /></span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000">:<br />};</span></div>上面的类增加了一个枚举,标识这条记录当前的状态,在记录集中,将根据记录的状态进行相关的操作.这个其实类似与.net中的DataRow,不过.net中的DataRow可以用wizzard生成需要的类,而这里是用模板生成的.<br /><br />三.数据类型转换<br />      数据库中的表对应的字段有不同的数据类型,ADO操作接口中用不同的数据类型与之对应,其中Field接口的GetType就是返回字段类型的,但是ADO的GetValue返回的是_variant_t类型,为了实际业务的需要,还需要转换成不同的类型,因此,需要对_variant_t类型进行转换.为此需要提供模板转换函数<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">typename</span><span style="COLOR: #000000"> _type</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />void DbData_Change(_type</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> ret, _variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field)<br />{<br />   AfxMessageBox(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">未定义的数据转换</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />}<br /><br /><br />template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br />void DbData_Change</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> ret, _variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field)<br />{<br />    ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> field.lVal;<br />}<br /><br />template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br />void DbData_Change</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">(std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> ret, _variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field)<br />{<br />    _bstr_t temp;<br /><br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (field.vt !</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> VT_NULL) {<br />        temp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> field.bstrVal;<br />        ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> temp.operator </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">();<br />    }<br />}<br /><br />template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br />void DbData_Change</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">bool</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">(bool</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> ret, _variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field)<br />{<br />    ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (field.boolVal </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> (short)0xFFFF ? </span><span style="COLOR: #0000ff">TRUE</span><span style="COLOR: #000000"> : </span><span style="COLOR: #0000ff">FALSE</span><span style="COLOR: #000000">);<br />}<br /><br />template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br />void DbData_Change</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> ret, _variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field)<br />{<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (field.vt !</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> VT_NULL) {<br />        </span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> field.cyVal;<br />        ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> field.dblVal;<br />    }</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br />        ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    }<br />}</span></div><br />上面的模板函数的功能是从_variant_t转换到某中数据类型,对于其它类型还可以进行扩充,对于没有进行特化的函数,编译器会使用缺省模板,在运行时候就会出现提示.有了上面的函数,现在我们需要一个数据类型的封装类,使得被封装的类型可以自动进行从_variant_t类型的需要类型的转换,所以有了下面的封装类.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">//</span><span style="COLOR: #000000">数据库数据类型封装<br />template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">typename</span><span style="COLOR: #000000"> _type</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />class _db_data_wrapper<br />{<br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    _type</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> Value() {<br />        return m_Data;<br />    }<br /><br />    </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> _type</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> operator </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> _type</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> value) {<br />        m_Data </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> value;<br />        return value;<br />    }<br /><br />    _db_data_wrapper</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> operator </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> _db_data_wrapper</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> other) {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (this !</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">other) {<br />            m_Data </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> other.m_Data;<br />        }<br />        return </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">this;<br />    }<br /><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    virtual void GetDbValue(_variant_t</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> field_value) {<br />        DbData_Change(m_Data, field_value);<br />    }<br /><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br />    _db_data_wrapper(){}<br />    _db_data_wrapper(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> _type</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> value) : m_Data(value) {}<br />    ~_db_data_wrapper(){}<br /></span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000">:<br />    _type m_Data;<br />};<br /><br />typedef _db_data_wrapper</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> DB_INT;<br />typedef _db_data_wrapper</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> DB_STRING;<br />typedef _db_data_wrapper</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> bool </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> DB_BOOL;<br />typedef _db_data_wrapper</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> DB_DOUBLE;</span></div><br /><br /><br />上面的代码预定义了几种常用的数据类型,这个数据的封装类支持 = 操作符,因此可以直接用被封装的数据对其赋值.象下面<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">;<br />DB_INT di;<br />di </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i;<br />i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> di.Value();</span></div><p><br />同时通过成员函数GetDbValue(_variant_t&amp; field_value), 支持从_variant_t转换为自身封装的类型.</p><p>现在,可以用上面的数据类型构建记录结构了</p><p>typedef data_op_record_row&lt; TYPELIST_2(DB_INT,DB_STRING) &gt; my_DataRow;</p><p>在上面的my_DataRow类型中,有两个成员Field0, Field1,类型分别为 DB_INT,DB_STRING, 支持_variant_t类型转换.</p><p>当然,用wrapper对数据进行封装在实际的使用中毕竟有些麻烦, 如数据必须通过 Value() 函数来取得,如果直接使用象 int, std::string 等类型作为 记录结构的成员,也可以实现_variant自动转换,但是需要在上一层的记录集类中加入相关的转换操作,实现起来比较麻烦,所以我这里选择了对数据进行封装.</p><p><br /> </p><img src ="http://www.cppblog.com/hdqqq/aggbug/17894.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-01-22 17:33 <a href="http://www.cppblog.com/hdqqq/archive/2007/01/22/17894.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建一个基于模板的数据库记录集操作类(一)</title><link>http://www.cppblog.com/hdqqq/archive/2007/01/19/17774.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 19 Jan 2007 02:35:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2007/01/19/17774.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/17774.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2007/01/19/17774.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/17774.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/17774.html</trackback:ping><description><![CDATA[
		<p>     c++在数据库开发这种需要进行快速开发的地方一直是以效率低下著称,borland 的c++ build 依赖vcl提供的组件勉强可以实现,但是由于用的是pascal的东西,根基不行,一直叫不响.再看看现在流行的数据库,sql server 和mysql 等虽然提供本地开发的头文件和库,但是对于一些可能使用不同数据库的应用来说,选择特定某种数据库开发显然是不妥,因此,象ado这种数据操作接口大行其道.这又给用c++开发带来了麻烦,象vb等工具可以自动转换variant类型,但是在vc使用的时候却很麻烦.网上那些使用ado接口的c++的例子,大多数都从#import 那个dll开始, 然后就是繁琐的创建instance,打开记录集,最后还要进行一个variant到c++类型的转换,确实是够麻烦的,难怪效率低下.<br />  <br />    在很多情况下,一些数据查询和数据操作往往是在开发的时候就确定下来了,比如说你有个用户表要操作,你在开发的时候就知道这个表中的所有字段名称和字段类型,但是你用ado,你却还是要和繁琐的variant打交道,把它转换为你想要的数据类型. 如果能实现一个类,在知晓数据表字段类型的情况下,可以方便地使用c++数据类型,并且可以进行诸如插入,删除,更新等操作,那就方便多了.  这就是本文想实现的目标.  但是对于那些在运行时候才确定的数据操作,如用户输入一个 sql 查询,然后再来进行操作,对于象c++ 这种强类型的语言来说,可能除了使用 variant别无他法, 对于这方面,本文没有给出解决办法.</p>
		<p>本文中的代码在vc6下编译通过<br />需要的库 loki for vc6, boost</p>
		<p>一. 构造记录结构</p>
		<p>   通常来说,数据集由一条条的记录组成,记录下有字段,记录是数据操作的基本单元.照c++的习惯,最好是一条记录一个结构,字段就是这个结构的成员,然后用列表或者vector组合一下就是记录集了.但是一条记录的字段是有可能变动的,还好,有loki 的 typelist.</p>
		<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">#if</span><span style="COLOR: #000000"> !defined(INCLUDE_40697E96_B6DE_449D_A516_B0376650A488)</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> INCLUDE_40697E96_B6DE_449D_A516_B0376650A488</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#if</span><span style="COLOR: #000000"> _MSC_VER &gt; 1000</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000">#pragma once<br /></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#endif</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typelist.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">functor.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">boost</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">preprocessor</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">dec.hpp</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> HELP_2(a , b) a(b)</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> MEM_STRUCT_MAKE_IMPL(n) template &lt;typename _tlist&gt; \</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> In : </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> _str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::template In</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typename _tlist::Tail</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> \<br /></span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">{ \<br /></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">    typedef _str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::template In</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typename _tlist::Tail</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> _Base; \<br /></span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">enum</span><span style="COLOR: #000000"> {    en_member_count </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> _Base::en_member_count</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, }; \<br /></span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">    typedef typename ::Loki::TL::TypeAt</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result _type##n; \<br /></span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">    _type##n m_P##n; \<br /></span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">    __declspec(property(</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> GetF##n, put </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> PutF##n)) \<br /></span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">    _type##n Field##n; \<br /></span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">    _type##n GetF##n() { </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> m_P##n; } \<br /></span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> PutF##n(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> _type##n val) { m_P##n </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> val; } \<br /></span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">}; \<br /></span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> MEM_STRUCT_MAKE(n) template &lt;&gt; \</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">29</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> _str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> { \<br /></span><span style="COLOR: #008080">30</span> <span style="COLOR: #000000">    HELP_2(MEM_STRUCT_MAKE_IMPL, BOOST_PP_DEC(n))<br /></span><span style="COLOR: #008080">31</span> <span style="COLOR: #000000">    <br /></span><span style="COLOR: #008080">32</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">33</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> impl_help<br /></span><span style="COLOR: #008080">34</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">35</span> <span style="COLOR: #000000">    template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> _p</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">36</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> _str_impl_help;<br /></span><span style="COLOR: #008080">37</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">38</span> <span style="COLOR: #000000">    template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">39</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> _str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> {};<br /></span><span style="COLOR: #008080">40</span> <span style="COLOR: #000000">    template </span><span style="COLOR: #000000">&lt;&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">41</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> _str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080">42</span> <span style="COLOR: #000000">        template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typename _tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">43</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> In {<br /></span><span style="COLOR: #008080">44</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">enum</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080">45</span> <span style="COLOR: #000000">                en_member_count </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,<br /></span><span style="COLOR: #008080">46</span> <span style="COLOR: #000000">            };<br /></span><span style="COLOR: #008080">47</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">48</span> <span style="COLOR: #000000">            typename ::Loki::TL::TypeAt</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result m_P0;<br /></span><span style="COLOR: #008080">49</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">50</span> <span style="COLOR: #000000">            __declspec(property(</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">GetF0, put</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">PutF0))<br /></span><span style="COLOR: #008080">51</span> <span style="COLOR: #000000">            typename ::Loki::TL::TypeAt</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result Field0;<br /></span><span style="COLOR: #008080">52</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">53</span> <span style="COLOR: #000000">            typename ::Loki::TL::TypeAt</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result GetF0() { <br /></span><span style="COLOR: #008080">54</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> m_P0; <br /></span><span style="COLOR: #008080">55</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">56</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">57</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> PutF0(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> typename ::Loki::TL::TypeAt</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result val) {<br /></span><span style="COLOR: #008080">58</span> <span style="COLOR: #000000">                m_P0 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> val;<br /></span><span style="COLOR: #008080">59</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">60</span> <span style="COLOR: #000000">        };<br /></span><span style="COLOR: #008080">61</span> <span style="COLOR: #000000">    };<br /></span><span style="COLOR: #008080">62</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">63</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">64</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">65</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">66</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">67</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">68</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">69</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">70</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">71</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">72</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">11</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">73</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">74</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">13</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">75</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">14</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">76</span> <span style="COLOR: #000000">    MEM_STRUCT_MAKE(</span><span style="COLOR: #000000">15</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">77</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">78</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">79</span> <span style="COLOR: #000000">template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typename _tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">80</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> struct_mem : </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> impl_help::_str_impl_help</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> ::Loki::TL::Length</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::value </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">:: <br /></span><span style="COLOR: #008080">81</span> <span style="COLOR: #000000">    template In</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> ::Loki::TL::Reverse</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">_tlist</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::Result </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">82</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">83</span> <span style="COLOR: #000000">};<br /></span><span style="COLOR: #008080">84</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">85</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">86</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">#endif</span><span style="COLOR: #000000"> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">!defined(INCLUDE_40697E96_B6DE_449d_A516_B0376650A488)</span></div>
		<p>上面是模板实现根据指定typelist,生成拥有相应成员的结构.</p>
		<font style="BACKGROUND-COLOR: #ffffff">
		</font>
		<p>typedef struct_mem&lt; TYPELIST_6(DB_STRING, DB_STRING, DB_STRING, DB_STRING, DB_STRING, DB_STRING) &gt; CustomerRow; 就可以声明一个有6个成员的结构了.<br />上面的代码使用template的特化到有15个成员的结构,全部写出来的话,重复而且麻烦,所以使用了宏来帮助生成.</p>
		<p>
				<br /> </p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/17774.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2007-01-19 10:35 <a href="http://www.cppblog.com/hdqqq/archive/2007/01/19/17774.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>?:操作符的新用法</title><link>http://www.cppblog.com/hdqqq/archive/2006/12/29/16988.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 29 Dec 2006 09:06:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/12/29/16988.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/16988.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/12/29/16988.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/16988.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/16988.html</trackback:ping><description><![CDATA[
		<p>?:操作符是一个条件赋值的操作符号,常用来对变量进行条件赋值如:<br /><br />int i = 1, j = 2;<br />int c_max = ( i &gt; j ? i : j );<br /><br />不过今天看了网上的一段代码,是这样用的<br /><br />(i-&gt;second.left ? file.leechers : file.seeders)--;<br /><br />上面的三个都是变量,也可以编译通过,所以写了段代码试了一下<br /><br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> show_1(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> val)<br /></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">    cout </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">function show_1 called!</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> endl;<br /></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> show_2(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> val)<br /></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">    cout </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">function show_2 called!</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> endl;<br /></span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> quest_test()<br /></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> c </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, b </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">    (c</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">?</span><span style="COLOR: #000000"> a : b)</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    cout </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> a  </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> and </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> b </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> endl;<br /></span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">    (c </span><span style="COLOR: #000000">?</span><span style="COLOR: #000000"> a : b)</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">    cout </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> a  </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> and </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> b </span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> endl;<br /></span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">    (c </span><span style="COLOR: #000000">?</span><span style="COLOR: #000000"> show_1 : show_2)(</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">最后的输出是<br /></span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> and </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000"></span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> and </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000">function show_1 called</span><span style="COLOR: #000000">!</span></div>
		<p>
				<br />最怪的是?:操作符号,居然也可以用在函数上.</p>
		<p>(c ? show_1 : show_2)(100);</p>
		<p>其实等同于</p>
		<p>if (c)<br />  show_1(100);<br />else<br />  show_2(100);</p>
		<p>不过简练了很多.</p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/16988.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-12-29 17:06 <a href="http://www.cppblog.com/hdqqq/archive/2006/12/29/16988.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>windows下的banner</title><link>http://www.cppblog.com/hdqqq/archive/2006/12/22/16716.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 22 Dec 2006 02:13:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/12/22/16716.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/16716.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/12/22/16716.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/16716.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/16716.html</trackback:ping><description><![CDATA[
		<p>
				<font color="#008000">unix系统下的banner是用于显示点阵字体的程序cygwin下有类似的程序可以在windows下跑,但是不支持中文.</font>
		</p>
		<p>
				<font color="#008000">所以自己写了一个windows下的类似程序,自己建一个控制台工程(需支持mfc)后,把下面的代码复制一下就可以了.同时,新年快到了,祝大家:<br /><br /><font face="Courier New" size="1">     #      ##       ##            #    ##         #    ####  <br />  ###### ###        #########      # #   #         #######    <br />    # #  #        ##   ##        # # ########      #   ##     <br />  ###### #######   ##########    # #     #  #     ##   ##     <br /> #  ##  ## ## #    ##  ##        # #     ####     ############<br />  ###### # ##    ###############   # ##########      # ###    <br />   ### ### ##    ##    ##  ####    #    # #  #      ## ## ##  <br />  #### ##  ##          ##          #   ## ##      ###  ##  ####<br /> #  ##  #  ##          ##          # ###   ##    #   # ##    ##<br />            #          ##          ##                 ##       </font></font>
		</p>
		<p>
				<font color="#008000">
						<font face="Courier New" size="1">      8  88            8               8  8                88   <br />   8888888888     88888888888      88  8 88       88888    88   <br />      8  8         888888888       8   8          8 8 8 88888888<br />  8888 888888       8888888        888888888      8 8 8    8888 <br />     888  88        88   88           88888       8 8 8   888   <br />   88  8   888        8888            88 88       8 8 8  8888   <br />8888 8 8888 888  88888888888888     88  88        888 8888 88   <br />    8  88 88 8      88888888     8888  88 888      8888    88   <br />   8 888 8 8        88    88        8888   8888  888  88 8888   <br />      88            88888888                 8             8    <br /></font>
				</font>
		</p>
		<p>
				<font color="#008000">使用方式</font>
		</p>
		<p>
				<font color="#008000">wbanner [-c 填充字符] [-f 字体名称] [-s 字体大小] 显示文本<br /><br />/////////////////<br /><br /></font>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> wbanner_6.cpp : Defines the entry point for the console application.<br /></span>
				<span style="COLOR: #008000">//<br /></span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">stdafx.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">wbanner_6.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef _DEBUG<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> new DEBUG_NEW</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#undef</span>
				<span style="COLOR: #000000"> THIS_FILE</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> THIS_FILE[] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> __FILE__;<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #808080">///////////////////////////////////////////////////////////////////////////</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> The one and only application object</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">
						<br />CWinApp theApp;<br /><br /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><br /><br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> BMP_WIDTH    100</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> BMP_HEIGHT    30</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> ParseArg(CString</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> info, CString</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> fill_str,CString</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> font_name, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> font_size, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> argc,TCHAR</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> argv[])<br />{<br />    </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i;<br />    </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">; i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> argc; i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">) {<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (strcmp(argv[i], </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">-c</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;&amp;</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> argc) {<br />            fill_str </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> argv[</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">i];<br />            </span>
				<span style="COLOR: #0000ff">continue</span>
				<span style="COLOR: #000000">;<br />        }<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (strcmp(argv[i], </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">-f</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;&amp;</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> argc) {<br />            font_name </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> argv[</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">i];<br />            </span>
				<span style="COLOR: #0000ff">continue</span>
				<span style="COLOR: #000000">;<br />        }<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (strcmp(argv[i], </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">-s</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;&amp;</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> argc) {<br />            font_size </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> atoi(argv[</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">i]);<br />            </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (font_size </span>
				<span style="COLOR: #000000">&lt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">120</span>
				<span style="COLOR: #000000">) <br />                font_size </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">120</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">continue</span>
				<span style="COLOR: #000000">;<br />        }<br /><br />        info </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> argv[i];<br />        </span>
				<span style="COLOR: #0000ff">break</span>
				<span style="COLOR: #000000">;<br />    }<br />}<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> ShowBanner(LPCTSTR fill_str, LPCTSTR info, LPCTSTR font_name, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> font_size)<br />{<br />    CFont lfont;<br />    CDC ldc;<br />    CBitmap lbmp;<br />    ldc.CreateCompatibleDC(NULL);<br />    lbmp.CreateCompatibleBitmap(</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">ldc, BMP_WIDTH, BMP_HEIGHT);<br />    CBitmap</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> pold </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (CBitmap</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">)ldc.SelectObject(</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">lbmp);<br />    <br />    lfont.CreatePointFont(font_size, font_name, </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">ldc);<br />    <br />    CFont</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> poldfont </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (CFont</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">)ldc.SelectObject(</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">lfont);<br />    <br />    CRect lrect(</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">, BMP_WIDTH,BMP_HEIGHT);<br />    <br />    ldc.FillSolidRect(</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">, BMP_WIDTH, BMP_HEIGHT, RGB(</span>
				<span style="COLOR: #000000">255</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">255</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">255</span>
				<span style="COLOR: #000000">));<br />    ldc.DrawText(info, </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">lrect, DT_LEFT);<br />    <br />    BITMAP bmp_head;<br />    <br />    lbmp.GetBitmap(</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">bmp_head);<br />    <br />    <br />    DWORD bufsize </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> bmp_head.bmWidthBytes</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">bmp_head.bmHeight;<br />    </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> buf </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000">[bufsize];<br />    <br />    memset(buf, </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">, bufsize);<br />    <br />    DWORD get_ret </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> lbmp.GetBitmapBits(bufsize, (</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">)buf);<br />    <br />    </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i,j;<br />    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (get_ret </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) {<br />        </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> ret[</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> { </span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">};<br />        CString </span>
				<span style="COLOR: #0000ff">out</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> {fill_str, </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">};<br />        </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> bmp_head.bmHeight; i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">)<br />        {<br />            </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> charcount </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (j </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; j </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> bmp_head.bmWidth; j</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">) {<br />                </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> offset </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> bmp_head.bmWidthBytes</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">i</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">j</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">;<br />                </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> cur;<br />                cur </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> buf[offset];<br />                </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> tt </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> cur </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #000000">0x80</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;&gt;</span>
				<span style="COLOR: #000000"> (j </span>
				<span style="COLOR: #000000">%</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">));<br />                CString temp;<br />                </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (tt </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) {<br />                    temp </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">out</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">];<br />                }</span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />                    temp </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">out</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">];<br />                }<br />                cout </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> (LPCTSTR)temp;<br />                charcount</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">;<br />            }<br />            cout </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> endl;<br />        }<br />    }<br />        <br />    ldc.SelectObject(pold);<br />    ldc.SelectObject(poldfont);<br />    delete [] buf;<br />}<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> PrintUsage(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> argc, TCHAR</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> argv[])<br />{<br />    cout </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">not enough arguments</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> endl;<br />    cout </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Usage:</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> endl;<br />    cout </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> argv[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> [-c #] [-f font_name] [-s font_size] A string to print</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> endl;<br />}<br /><br /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> _tmain(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> argc, TCHAR</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> argv[], TCHAR</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> envp[])<br />{<br />    </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> nRetCode </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /><br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> initialize MFC and print and error on failure</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">))<br />    {<br />        </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> TODO: change error code to suit your needs</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">
						<br />        CString info </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">wbanner</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />        CString font_name </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">宋体</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />        CString fill_str </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">#</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> font_size </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">120</span>
				<span style="COLOR: #000000">;<br />        <br />        <br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (argc </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">) {<br />            PrintUsage(argc, argv);<br />        }</span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />            ParseArg(info, fill_str, font_name, font_size, argc, argv);<br />            ShowBanner(fill_str, info, font_name, font_size);<br />        }<br />    }</span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />        cerr </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> _T(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Fatal Error: MFC initialization failed</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000"> endl;<br />        nRetCode </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br />    }<br />    </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> nRetCode;<br />}<br /><br /><br /></span>
		</div>
<img src ="http://www.cppblog.com/hdqqq/aggbug/16716.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-12-22 10:13 <a href="http://www.cppblog.com/hdqqq/archive/2006/12/22/16716.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>unix 下的文件名大小写相关</title><link>http://www.cppblog.com/hdqqq/archive/2006/12/11/16277.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Mon, 11 Dec 2006 08:44:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/12/11/16277.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/16277.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/12/11/16277.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/16277.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/16277.html</trackback:ping><description><![CDATA[  今天写了一个ace 的proactor的测试程序,代码是在windows下编辑的,在windows下测试成功后,将代码传到一台linux机器上进行测试,配置了相关的configure.in和Makefile.am文件后,用autoconf,automake和configure生成makefile然后make开始编译,但是程序报错,开始以为是ace的配置的问题,重新设置了ace的linux下的配置头文件,并重新编译,不行,然后重新设置configure.in文件和Makefile.am文件,还是不行,搞了半天,最后仔细看了gcc的报错信息,是有一些头文件无法包含,看了编译的参数, incldue设置正确, 最后终于发现,原来是因为在windows下编辑的代码,头文件用了小写名称,导致在linux下包含的头文件找不到,这个是在类unix下开发应该注意的小细节,一个疏忽,往往容易阴沟里翻船.特此记录一下.<br /><img src ="http://www.cppblog.com/hdqqq/aggbug/16277.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-12-11 16:44 <a href="http://www.cppblog.com/hdqqq/archive/2006/12/11/16277.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用vs2003打开vs2005的工程文件</title><link>http://www.cppblog.com/hdqqq/archive/2006/12/09/16156.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 08 Dec 2006 16:27:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/12/09/16156.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/16156.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/12/09/16156.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/16156.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/16156.html</trackback:ping><description><![CDATA[
		<font size="1">      今天在网上下载了一个c++的代码,项目文件是sln的文件.<br />我双击打开,vs2003报告说,这个项目文件是高版本的vs生成的,目前不支持,搞了半天这个项目文件是vs2005生成的,这种高级货我当然没用过,装vs2005或者重新构建项目工程都比较麻烦,所以从项目文件上着手,看看是否可以修改一下,让我的vs2003可以用. 随便找了一个vs2003生成的sln文件,和vs2005生成的看看,都是类似xml的文件,差别只是一个版本号不同,把两个文件修改为vs2003的8.0 sln版本,vs2003还是不认.估计是vcproj的差别,然后查看2003和2005vcproj文件的差别,也差不多,只是版本号上的差别,所以想办法实验了一下, 把 vs2005的sln文件删除,用文本编辑程序打开vcproj文件,vs2005生成的文件,版本号是8,00 我直接改成了vs2003的7.10 然后保存vcproj文件,再双击打开,vs2003通过了,可以直接编译运行了,vs2003还会自动生成新的sln文件.</font>
<img src ="http://www.cppblog.com/hdqqq/aggbug/16156.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-12-09 00:27 <a href="http://www.cppblog.com/hdqqq/archive/2006/12/09/16156.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>hello world 汇编版</title><link>http://www.cppblog.com/hdqqq/archive/2006/09/21/12792.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Thu, 21 Sep 2006 06:25:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/09/21/12792.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/12792.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/09/21/12792.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/12792.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/12792.html</trackback:ping><description><![CDATA[
		<p>
				<font color="#009900">;一个汇编版本的 hello world<br />;test.asm <br />;a hello world program with asm<br /></font>.386P<br />.model FLAT</p>
		<p>include listing.inc</p>
		<p>INCLUDELIB LIBCD<br />INCLUDELIB OLDNAMES</p>
		<p>PUBLIC _main<br />PUBLIC szHelloWorld<br />EXTERN _printf:NEAR</p>
		<p>
				<br />CONST SEGMENT<br /> szHelloWorld DB 'Hello World!', 0aH, 00H<br />CONST ENDS</p>
		<p>_TEXT SEGMENT</p>
		<p>_argc$ = 8<br />_argv$ = 12<br />_main PROC NEAR<br /> push OFFSET FLAT:szHelloWorld<br /> call _printf<br /> add esp, 4<br /> xor eax, eax <br /> ret 0<br />_main ENDP<br />_TEXT ENDS</p>
		<p>END<br /> <br />;编译命令<br />;ml.exe    /c   /coff    test.asm<br />;link /out:test.exe /subsystem:console kernel32.lib test.obj<br /><br /></p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/12792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-09-21 14:25 <a href="http://www.cppblog.com/hdqqq/archive/2006/09/21/12792.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL, Loki,Boost 中Functor比较之Boost库(一)</title><link>http://www.cppblog.com/hdqqq/archive/2006/09/13/12424.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Wed, 13 Sep 2006 13:39:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/09/13/12424.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/12424.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/09/13/12424.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/12424.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/12424.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center">
				<span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-size: 12.0pt">STL, Loki,Boost </span>
				<span style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</span>
				<span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-size: 12.0pt">Functor</span>
				<span style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比较之</span>
				<span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-size: 12.0pt">Boost</span>
				<span style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库</span>
				<span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-size: 12.0pt">(</span>
				<span style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一</span>
				<span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-size: 12.0pt">)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在这一部分中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要讨论的是</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库中的</span>
				<span lang="EN-US">Function</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的有关功能</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">于前面两篇不同的是</span>
				<span lang="EN-US">,Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库的规模相对于</span>
				<span lang="EN-US">Loki</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US">STL</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来说</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在规模上大了很多</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这篇文章中讨论的是</span>
				<span lang="EN-US">boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span>
				<span lang="EN-US">functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部分</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写的不好之处</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">欢迎提出意见</span>
				<span lang="EN-US">. </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写作本文使用的是</span>
				<span lang="EN-US">Boost 1_33_1</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">同时参考了</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文档的</span>
				<span lang="EN-US">function</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部分的说明</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
						<strong>写在前面</strong>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">Function</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用到了</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">Preprocessor,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在这部分中</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供的宏预处理功能是很强大的</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主要的宏功能有</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">重复生成</span>
				<span lang="EN-US">(BOOST_PP_REPEAT_FROM_TO), </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">条件判断</span>
				<span lang="EN-US">(BOOST_PP_IF), </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">连接</span>
				<span lang="EN-US">(BOOST_PP_CAT),</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数值比较</span>
				<span lang="EN-US">(BOOST_PP_GREATER),</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数枚举</span>
				<span lang="EN-US">(BOOST_PP_ENUM_PARAMS)</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用这些宏</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以按照自己的需要用宏生成模板类或者代码</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实在是一个很有效而且很创新的功能</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以说把预处理器的功能用到了登峰造极的地步</span>
				<span lang="EN-US">.</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不过</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代价是要花更多的时间在编译上</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我有一个</span>
				<span lang="EN-US">18000</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行代码的工程</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在一个头文件中使用了</span>
				<span lang="EN-US">Preprocessor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">产生一些模板代码后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译时间从原先的</span>
				<span lang="EN-US">4</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分钟一下子升到了</span>
				<span lang="EN-US">8</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分多秒</span>
				<span lang="EN-US">(</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我的机器比较老</span>
				<span lang="EN-US">),</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最后不得不写了个功能</span>
				<span lang="EN-US">Proxy</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">隔绝</span>
				<span lang="EN-US">cpp</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件对该头文件的依赖关系才缩短了编译时间</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt">
				<span lang="EN-US">TypeTraits typetraits</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的功能是在给定一个数据类型后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通过</span>
				<span lang="EN-US">c++</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的模板能力</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来取得这个关于这个数据类型的相关信息</span>
				<span lang="EN-US">.</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">Loki</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也提供了</span>
				<span lang="EN-US">TypeTrait</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能</span>
				<span lang="EN-US">.</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">常用的有</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断是否为指针</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断是否为常量</span>
				<span lang="EN-US">, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断是否为引用</span>
				<span lang="EN-US">, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断是否为数值等</span>
				<span lang="EN-US">. </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在创建模板类或者函数的时候</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有时候需要根据模板参数的类型对模板进行特化</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这是一个很重要的辅助功能</span>
				<span lang="EN-US">,boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中也有</span>
				<span lang="EN-US">typetrait</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">生成的过程中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也使用了一些</span>
				<span lang="EN-US">typetrait</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的功能</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt">
				<span lang="EN-US">
				</span> </p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的的</span>
				<span lang="EN-US">Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的头文件位于</span>
				<span lang="EN-US">&lt;boost/function.hpp&gt;</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有一个很重要的宏</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">BOOST_FUNCTION_MAX_ARGS 用于</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义</span>
				<span lang="EN-US">boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的预处理器展开的</span>
				<span lang="EN-US">Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最多的参数个数</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">缺省的定义为</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font color="#0033ff">#define</font>
						<span style="mso-spacerun: yes">  </span>
						<font color="#cc6600">BOOST_FUNCTION_MAX_ARGS</font>
						<span style="mso-spacerun: yes">  </span>
						<font color="#ff99ff">10</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果有需要扩充</span>
				<span lang="EN-US">Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的参数个数</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以在包含</span>
				<span lang="EN-US">Boost Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">头文件之前</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">自己定义这个宏的数值</span>
				<span lang="EN-US">, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">但是</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最多可以到</span>
				<span lang="EN-US">50, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">超过这个数值后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要手工修改</span>
				<span lang="EN-US">&lt;boost/function/detail/maybe_include.hpp&gt;</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的代码</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</span>
				<span lang="EN-US">Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以使用的参数再进行扩充</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<strong>
						<span lang="EN-US">Boost</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
						<span lang="EN-US">Functor</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的展开</span>
				</strong>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">Boost</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中使用了预处理元编程提供的叠代头文件的功能</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">反复叠代</span>
				<span lang="EN-US">&lt;boost/function/function_template.hpp&gt;,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最终生成使用所需要的模板类</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<code>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 黑体"> <o:p></o:p></span>
				</code>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<code>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 黑体">
								<a title="Class template function" href="file:///F:backupc_cpp_libboost_1_33_1dochtmlboostfunction.html">
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体">boost::function</span>
								</a>
						</span>
				</code>
				<span lang="EN-US">&lt;</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回值</span>
				<span lang="EN-US"> (</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数</span>
				<span lang="EN-US"> [,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数</span>
				<span lang="EN-US">]…)&gt;,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用户可以使用编译器的</span>
				<span lang="EN-US"> /P(</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">微软</span>
				<span lang="EN-US">c++</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器</span>
				<span lang="EN-US">),<span style="mso-spacerun: yes">  </span>-save-temps(gcc</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器</span>
				<span lang="EN-US">)</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开查看宏展开后的文件</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有关</span>
				<span lang="EN-US">STL </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US"> Loki</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span>
				<span lang="EN-US">Functor</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的前面两篇位于我的另外一个</span>
				<span lang="EN-US">blog</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">http://blog.csdn.net/hdqqq/archive/2006/02/07/593877.aspx</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">http://blog.csdn.net/hdqqq/archive/2006/01/25/588348.aspx</span>
		</p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/12424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-09-13 21:39 <a href="http://www.cppblog.com/hdqqq/archive/2006/09/13/12424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>shell 脚本</title><link>http://www.cppblog.com/hdqqq/archive/2006/09/06/12096.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Wed, 06 Sep 2006 09:18:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/09/06/12096.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/12096.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/09/06/12096.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/12096.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/12096.html</trackback:ping><description><![CDATA[
		<p>
				<font color="#009900">/*<br /> 这几天在编译firefox,顺便学一下unix下的shell的脚本编写,unix下的管道和工具<br />结合起来用的话,功能确实强大.写了个测试的脚本,功能是把c/cpp/h文件中所有包含的头文件<br />找出来,支持通配符.<br /> 可以把下面的文字复制到某个文件,然后另存为.sh后缀的文件放到/bin目录下就可以运行了,在<br />cygwin环境下测试通过.<br />*/</font>
		</p>
		<p>## list_head.sh</p>
		<p>ARR_NUM=1</p>
		<p>if [ $# -lt $ARR_NUM ]<br />then<br />echo "使用方式:"<br />echo "$0 文件名"<br />echo "文件名: C/CPP/H 文件 或 通配符 *.c(*.cpp)"<br />else<br /><br />cat $@ | grep include | grep \# | sort | uniq | awk -Finclude '{ print $2 }' | tr -d \" | tr -d \' | tr -d \&lt; | tr -d \&gt; | sort | uniq | awk '{ print $1 }'<br /></p>
		<p>fi</p>
		<p>exit 0<br /></p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/12096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-09-06 17:18 <a href="http://www.cppblog.com/hdqqq/archive/2006/09/06/12096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编译firefox</title><link>http://www.cppblog.com/hdqqq/archive/2006/09/03/11997.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Sun, 03 Sep 2006 10:14:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/09/03/11997.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/11997.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/09/03/11997.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/11997.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/11997.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前几天心血来潮</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">想自己编译一个</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试试看</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">折腾了好几天</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">终于完成了</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写篇文章总结一下</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我编译的环境</span>
				<span lang="EN-US">:</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt">
				<span lang="EN-US">1.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="EN-US">VC6 + sp5</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt">
				<span lang="EN-US">2.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译需要的辅助工具</span>
				<span lang="EN-US">wintools.zip</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt">
				<span lang="EN-US">3.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span lang="EN-US">cygwin </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<strong>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">准备工作</span>
						<span lang="EN-US">:</span>
				</strong>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt">
				<span lang="EN-US">1.<span style="FONT: 7pt 'Times New Roman'">       <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">下载</font></span></span></span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序代码，在</span>
				<span lang="EN-US">mozilla</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的站点上可以下载到，我编译的是</span>
				<span lang="EN-US">firefox 1.5.0.6</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt">
				<span lang="EN-US">2.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下载编译需要的</span>
				<span lang="EN-US">wintools.zip</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">工具</span>
				<span lang="EN-US">,1.73MB</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大小</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中带有</span>
				<span lang="EN-US">glib </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US">libidl</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在下载解压缩后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立一个环境变量</span>
				<span lang="EN-US">MOZ_TOOLS</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">到某个目录</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后进入解压缩后的</span>
				<span lang="EN-US">windows</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行</span>
				<span lang="EN-US">install.bat</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装相关需要的文件</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt">
				<span lang="EN-US">3.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个</span>
				<span lang="EN-US">window</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下的类</span>
				<span lang="EN-US">unix</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里需要注意的是</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最新的</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装的</span>
				<span lang="EN-US">make</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本是</span>
				<span lang="EN-US">3.81</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而编译</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要的是</span>
				<span lang="EN-US">3.80</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本的</span>
				<span lang="EN-US">make,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">解决的方法是到</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的某个</span>
				<span lang="EN-US">ftp</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">镜像站点上去下一个</span>
				<span lang="EN-US">3.80</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本的文件</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装到</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装目录下的</span>
				<span lang="EN-US">/bin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录下就可以了</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中编译</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要的基本工具</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">ash -- UNIX-like command line interpreter shell (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">coreutils -- GNU core utilities (includes fileutils, install, sh-utils, and textutils) (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">cvs -- concurrent versions system (Devel category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">diffutils -- file comparison utility (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">findutils (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">gawk -- pattern matching language (Base and Interpretors categories) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">grep -- text search tool (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">libiconv -- character set conversion (Devel category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">make 3.80 (not 3.81!) -- dependency analyzer for software builds (Devel category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">patchutils -- a small collection of programs that operate on patch files (Devel category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">perl -- a scripting language used to control parts of the build (Interpreters category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">sed -- a search and replace language (Base category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">unzip -- zip file extraction (Archive category) </span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">zip -- zip file creation (Archive category)</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以在</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">命令窗口中输入相关命令检测是否安装了相关的程序</span>
				<span lang="EN-US">.,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其实如果下载了</span>
				<span lang="EN-US">firefxo</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">源代码的话</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">象</span>
				<span lang="EN-US">cvs</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的都不是必须的</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt">
				<span lang="EN-US">4.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装</span>
				<span lang="EN-US">vc6 + sp5, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译</span>
				<span lang="EN-US">firefox 1.5.0.6,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐的是</span>
				<span lang="EN-US">vc6 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">cpp</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编译器</span>
				<span lang="EN-US">.</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">vs6</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会自动设置相关的</span>
				<span lang="EN-US">path,include</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US">lib</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境变量</span>
				<span lang="EN-US">.</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有一个需要注意的是</span>
				<span lang="EN-US">, vc6</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">link.exe</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span>
				<span lang="EN-US">link.exe</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是相同的名字</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为了避免在编译的时候</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">调用错误的</span>
				<span lang="EN-US">link</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行文件</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以把</span>
				<span lang="EN-US">cygwin/bin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span>
				<span lang="EN-US">link.exe</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">改名为</span>
				<span lang="EN-US">glink.exe</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">避免冲突</span>
				<span lang="EN-US">. Vs</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
				<span lang="EN-US">sp5</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">补丁也需要打一下</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">否则</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">生成的</span>
				<span lang="EN-US">xpldl.exe(firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用来编译</span>
				<span lang="EN-US">idl</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件的工具</span>
				<span lang="EN-US">)</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在编译</span>
				<span lang="EN-US">idl</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">过程中会报错</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt">
				<span lang="EN-US">5.<span style="FONT: 7pt 'Times New Roman'">       </span></span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置文件</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在环境和编译工具准备好后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">解压缩</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的代码</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后在</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码目录的</span>
				<span lang="EN-US">mozilla</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录下</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立一个名为</span>
				<span lang="EN-US">.mozconfig</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的文件</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并在其中编辑文本</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">. $topsrcdir/browser/config/mozconfig</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">ac_add_options --enable-optimize</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">ac_add_options --disable-debug</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">ac_add_options --enable-static</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">ac_add_options --disable-shared</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">ac_add_options --disable-test</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
						<strong>开工</strong>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上面所有工作完成之后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">启动</span>
				<span lang="EN-US">cygwin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">命令窗口</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进入</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码的</span>
				<span lang="EN-US">mozilla</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">输入</span>
				<span lang="EN-US">make –f client.mk build </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">命令开始编译</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一切顺利的话</span>
				<span lang="EN-US">, </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">几十分钟后</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就会有一个</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的执行文件生成到</span>
				<span lang="EN-US">mozilla/dist/bin</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录下</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要注意的是</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在生成一个</span>
				<span lang="EN-US">test</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的模块的时候</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会报一个</span>
				<span lang="EN-US">jsint</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型未定义</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这个无关紧要</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">因为</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">已经生成了</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这是一个测试模块</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我的解决方法是</span>
				<span lang="EN-US">,</span> 打开那个出错的cpp文件,<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">加入</span></p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">#ifdef<span style="mso-spacerun: yes">   _</span><i>MSC</i>VER</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">typedef<span style="mso-spacerun: yes">  </span>int<span style="mso-spacerun: yes">  int32</span>;</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span lang="EN-US">#endif</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后再编译就可以了</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所谓自动动手</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">丰衣足食</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有的时候</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实在不行的话</span>
				<span lang="EN-US">,</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要把</span>
				<span lang="EN-US">firefox</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的代码自己动手改一下</span>
				<span lang="EN-US">.</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/11997.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-09-03 18:14 <a href="http://www.cppblog.com/hdqqq/archive/2006/09/03/11997.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>zlib 压缩管道</title><link>http://www.cppblog.com/hdqqq/archive/2006/09/01/11920.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 01 Sep 2006 05:03:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/09/01/11920.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/11920.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/09/01/11920.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/11920.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/11920.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">
				</span> </p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">/*<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>Zlib 是常用的压缩库,在很多平台上使用,是用c和部分汇编完成的,提供的是基于c接口的使用函数<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">在<span lang="EN-US">zlib 的contrib中提供了三种基于iostream的使用方式.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">   </span>在MFC中,经常使用CFile进行文件的读写操作,在这种时候,如果想使用Zlib的话,要么使用zlib自身<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">提供的操作函数<span lang="EN-US">,要么使用zlib contrib中iostream操作流.或者自己对zlib进行封装.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">所以我对zlib进行了封装,便于使用.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">Filter 功能类<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">zlib_compress_filter&lt;int 压缩级别&gt; 实现压缩功能类,根据模板参数实现不同的压缩程度.<o:p></o:p></span>  </p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">zlib_uncompress_filter&lt;int &gt;<span style="mso-spacerun: yes">  </span>实现解压功能类,模板参数总为 1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">
						<br />Filter类自身带有 缓冲区, 可以存储处理后的数据,用户可以直接通过这两个Filter类对数据进行<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">压缩和解压缩操作<span lang="EN-US">.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">Pipe类<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>为了和MFC中的CFile类进行配接,对数据进行处理后,把CFile作为最后接受数据的容器,类似于<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">Boost库中的Sink,提供了一个模板实现的BufferPipe模板类.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">template &lt;typename filter,typename buffer_type, typename next_pipe&gt; class BufferPipe;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">模板参数<span lang="EN-US">:<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">filter<span style="mso-spacerun: yes">  </span>数据处理用filter<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">buffer_type 缓冲类型<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">next_pipe 后面接的pipe,可以是CFile,用于最终写入磁盘.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">Pipe后还可以接一个Pipe,可以象一个管子连接起来,并且,以后通过扩充filter可以实现不同的数据操作功能.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">提供了一个测试代码<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">编译后一个对话框 四个 按钮<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">按钮<span lang="EN-US">1 将 c:\a.bmp<span style="mso-spacerun: yes">  </span>压缩为 c:\b.cr<span style="mso-spacerun: yes">     </span>使用filter<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">按钮<span lang="EN-US">2 将 c:\b.cr<span style="mso-spacerun: yes">  </span>解压缩为 c:\c.bmp<span style="mso-spacerun: yes">   </span>使用filter<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">按钮<span lang="EN-US">3 将 c:\a.bmp 压缩为 c:\d.cr<span style="mso-spacerun: yes">   </span>使用pipe功能<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">按钮<span lang="EN-US">4 将 c:\a.bmp<span style="mso-spacerun: yes">  </span>通过压缩和解压缩管道, 存储为 e.bmp应该和a.bmp相同,用于测试管道的连接功能.<o:p></o:p></span></span> <br /><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt"> <o:p></o:p></span></p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">代码位置<span lang="EN-US">:<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">http://www.cppblog.com/files/hdqqq/z_file.rar<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">编译需要的<span lang="EN-US">zlib 请自行到该库的网站下载.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">这个文章实现的和<span lang="EN-US">boost中的filter类似的功能,可以和MFC配合使用.</span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">不足<span lang="EN-US">:<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">fiter 使用的 buf_holder写得比较粗糙,以后有机会的话,改进.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Fixedsys; mso-font-kerning: 0pt">*/<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US"> <o:p></o:p></span>
		</p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/11920.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-09-01 13:03 <a href="http://www.cppblog.com/hdqqq/archive/2006/09/01/11920.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数组取大小</title><link>http://www.cppblog.com/hdqqq/archive/2006/08/24/11641.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Thu, 24 Aug 2006 05:35:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/08/24/11641.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/11641.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/08/24/11641.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/11641.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/11641.html</trackback:ping><description><![CDATA[
		<p>在有些时候,需要对预设的数组进行循环操作</p>
		<p>如</p>
		<p>char char_array[] = {'a','b','c','d'};<br />int i;<br />for (i = 0; i &lt; sizeof(char_array)/sizeof(char); i++) {<br />    cout &lt;&lt; char_array[i] &lt;&lt; endl;<br />}</p>
		<p>所以写了个宏,取得数组的大小</p>
		<p>template &lt;typename T&gt;<br />T get_size(T value[]);</p>
		<p>#define ASIZEOF(a) sizeof(a)/sizeof(get_size(a))</p>
		<p>然后就可以这样写了.<br />for (i = 0; i &lt; ASIZEOF(char_array); i++) {<br />    cout &lt;&lt; char_array[i] &lt;&lt; endl;<br />}</p>
		<p>但是缺点就是不能正确的分别传入的是一个指针类型,还是一个类型的数组.</p>
		<p>
				<br />代码在vc6 和 devcpp 4.9 中测试通过</p>
		<p>
				<br /> </p>
<img src ="http://www.cppblog.com/hdqqq/aggbug/11641.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-08-24 13:35 <a href="http://www.cppblog.com/hdqqq/archive/2006/08/24/11641.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个读取xml配置文件的通用模板</title><link>http://www.cppblog.com/hdqqq/archive/2006/02/13/3234.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Mon, 13 Feb 2006 08:17:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2006/02/13/3234.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/3234.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2006/02/13/3234.html#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/3234.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/3234.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 现在				,				越来越多的程序使用				xml				文件作为应用程序的配置文件				,				在				windows				平台上				,				一般的程序使用微软的				msxml				接口来读写				xml				文件				.								xml				文件原则上可以存储任意形式的数据		...&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2006/02/13/3234.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/3234.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2006-02-13 16:17 <a href="http://www.cppblog.com/hdqqq/archive/2006/02/13/3234.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>