﻿<?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++博客-It Smils</title><link>http://www.cppblog.com/ronliu/</link><description>思绪的自留地</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 09:39:29 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 09:39:29 GMT</pubDate><ttl>60</ttl><item><title>告别低水平重复工作</title><link>http://www.cppblog.com/ronliu/archive/2009/06/21/88231.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Sun, 21 Jun 2009 12:18:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/06/21/88231.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/88231.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/06/21/88231.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/88231.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/88231.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2009年6月的一天，我在甲方办公室加班调试程序，笔记本的屏幕只有12英寸，我得不停地在调试器和编辑器之间切换，观察断点的执行情况，发现代码中的问题。在那一刻，我突然觉得所做的完全是<span style="FONT-WEIGHT: bold"><wbr>低水平重复工作</span><wbr>。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. 对业务流程不熟悉，对自己的代码不熟悉，编译运行后不能预测结果。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 做管理软件，重复性工作太多。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. 技术视野有限，不能从一个更广的角度去看待问题。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对于第一个问题，首要要求在写完代码后做review，把代码详细读一遍想一遍，确认无误后才编译。review要随时地做，写完一个函数完成一个功能块，都要检查，想一想这段代码在整个业务流程中的位置。对代码做到心中有数，而不至于不停的开调试器（调试器是一个效率低下的缘由之一）。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 重复性工作多，这个是管理软件固有属性，能否将重复性的工作抽离出来？在之前的项目中，做了很多这方面的尝试。有一定成效。但另一方面，由于经验不足，强扭地将一些个性化的东西抽离出来，最后代码组织结构混乱。要达到重用，有很多条路可以达到，但由于技术的积累不够，看到一条路就以为这条路是最好的，一往无前地闯过去。其实还有很多更好的选择，只是因为技术积累不够，而工期紧张，没得选了。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 视野有限，所看到仅仅是所写的，而不能引发更加广度的联想。比如说在asp.net中的master页面，自定义控件，管理软件三层架构的优势，mvc等等。没有深刻地了解和实际的体验，在项目中自然无法联想到。所以只能做一些简单的重复工作。
<img src ="http://www.cppblog.com/ronliu/aggbug/88231.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-06-21 20:18 <a href="http://www.cppblog.com/ronliu/archive/2009/06/21/88231.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>正则表达式（一）</title><link>http://www.cppblog.com/ronliu/archive/2009/03/11/76268.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Wed, 11 Mar 2009 12:01:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/03/11/76268.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/76268.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/03/11/76268.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/76268.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/76268.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp; 在日常生活中，经常有大量的文本需要处理，正则表达式正是基于此提出的。本文将结合一些具体的实例来解释它。虽然在不同的语言环境中，正则表达式有不同的语法规则，但其基本语义却是一致的。<a title="http://en.wikipedia.org/wiki/Regular_expression" href="http://en.wikipedia.org/wiki/Regular_expression">http://en.wikipedia.org/wiki/Regular_expression</a>。这将是一个系列教程。本节只是一个开胃菜:)</p> <p>&nbsp;&nbsp;&nbsp; 某一次同学很无聊，然后问我电脑上有无小说。这是显然的，我是网络小说迷嘛！从起点down下无数小说存在电脑上，名字都懒得改，都是以数字打头，然后以“.txt”结尾，比如23432.txt之类的。当然，文件查找还是得用<a href="http://xbeta.info/everything-search-tool.htm#h32">Everything</a>，要不然电脑上的上百万个文件，手会抽筋的。</p> <p>&nbsp;&nbsp;&nbsp; （注：我以为Everything是史上最快的文件查找工具，强烈推荐！）</p> <p>&nbsp;&nbsp; 先用"*.txt"尝试一下，:(，给出一大堆文本文件呀。范围太广。还是得用<strong>正则表达式</strong>来。</p> <p>&nbsp; <font color="#800000">^[0-9]*\.txt</font></p> <p>&nbsp;&nbsp;&nbsp; Yes！给出了我电脑上存储的所有小说了。</p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EverythingVIMPython_113E4/image_2.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EverythingVIMPython_113E4/image_thumb.png" width="335" height="132"></a> </p> <p>&nbsp;&nbsp;&nbsp; 解释一下： <br>&nbsp;&nbsp;&nbsp; ^[0-9]表示文件名以0-9之间的数字开头，^是开头的意思（$结尾） <br>&nbsp;&nbsp;&nbsp; *表示它前面的字符（这里是数字）要重复若干次（&gt;=0） <br>&nbsp;&nbsp;&nbsp; \.匹配139869.txt中的那个小数点。因为正则表达式中，‘.’被占用了，表示任意字符，所以要转义一下 <br>&nbsp;&nbsp;&nbsp; txt，这就不说了，紧接着小数点的是‘txt’三个字符。</p> <p>&nbsp;&nbsp;&nbsp; Everything只支持部分正则表达式, <font color="#800000">| () ? * + . [] [^] ^ $ {m,n} </font><font color="#000000">不过已经完全够用了。<br><a href="http://xbeta.info/everything/faq.htm#How_do_I_use_regex">http://xbeta.info/everything/faq.htm#How_do_I_use_regex</a></font></p> <p><font color="#000000">&nbsp;&nbsp;&nbsp; 考虑这样一个问题：项目组在验收的时候，被指出代码的注释量不够，需要达到至少30%才行，也就是至少需要添加6500行注释。此时老师提出，要将所有的函数加上注释，函数的名称、功能、参数、返回值。这个时候，考虑能不能用正则表达式，提取源代码中的函数信息，然后自动生成注释模板？比如:</font></p> <blockquote> <p><font color="#000000">int foo(int x, int y); <br>替换为： <br></font>/** <br>* @method foo <br>* @para x <br>* @para y <br>* @return <br>*/ <br>int foo(int x, int y);</p></blockquote> <p>&nbsp;&nbsp;&nbsp; 注意到，这个函数参数的个数和类型可以是变动的，返回值限定符的个数和类型也是变动的，比如static类型函数，有两个限定符，而构造函数，则没有限定符，还有部分virtual类型函数。</p><img src ="http://www.cppblog.com/ronliu/aggbug/76268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-03-11 20:01 <a href="http://www.cppblog.com/ronliu/archive/2009/03/11/76268.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QT编程之configue Dialog</title><link>http://www.cppblog.com/ronliu/archive/2009/03/08/75939.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Sun, 08 Mar 2009 14:20:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/03/08/75939.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/75939.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/03/08/75939.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/75939.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/75939.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本例学习QDialog。预期目的：1. 组织多个窗体。2. 学习Dialog的相关属性。3. 学习一些widget。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1. 本例中，定义了3个不同的PageWidget，都是从QWidget中派生。用户在左侧list更换后，切换到不同的配置页。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2. QStackedWidget提供一组widget，但一次只能有一个显示。将这个widget添加到layout中。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3. 在layout设置中，一般为MainWindow设置一个layout，然后向这个layout中添加不同的widget，layout。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4. 一个窗体是Window或者Dialog，向这个窗体中添加其他的Widget，这些Widget可以使系统提供的，也可以是用户自己定义的。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5. 本例中使用两次QListWidget。一次为图文，一次为文字。setViewMode()，设置ListWidget为图标模式。通过setIcon()，设置Item的图标。configButton-&gt;setIcon(QIcon(":/images/config.png"));</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6. 定义QListWidgetItem的父类为QListWidget，设置QListWidget的项。或者使用addWidget()之类的方法。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7. 左侧select切换时，if(!current)&nbsp; current = previous;防止current为0的意外情况。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8. 自定义了一个slot，用来处理contentList被选中项切换时，相应的处理方法。也就是设置stackedWidget的被选中项。通过contentlist的row()确定index，然后设置第index项为当前item。</p><img src ="http://www.cppblog.com/ronliu/aggbug/75939.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-03-08 22:20 <a href="http://www.cppblog.com/ronliu/archive/2009/03/08/75939.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用QT进行国际化语言版本的开发</title><link>http://www.cppblog.com/ronliu/archive/2009/02/26/75006.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Thu, 26 Feb 2009 12:09:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/02/26/75006.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/75006.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/02/26/75006.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/75006.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/75006.html</trackback:ping><description><![CDATA[<p>2008.2.27 by RonLiu  <p>方法一：使用tr()函数  <p>QT中，用QString存储所有可见得文本/字符串，使用tr()将各种字符编码的文本转化为QString，然后既可以将他们设置为控件的显示文本。  <p>在Widget的构造函数中加入：  <p>QTextCodec::setCodecForTr(QTextCodec::codecForName("gbk"));  <p>QFont font1("Times", 12, QFont::Normal, FALSE);  <p>this-&gt;setFont(font1);  <p>这样在该窗体的其他位置，可以使用tr()设置控件的内容，他们均可以显示为中文了。  <p>setWindowTitle(tr("消息嗅探器"));  <p>注意：这种方式设置的中文显示对于整个控件，以及它们的子控件都生效。如果在子控件中另外设置了setFont()，那么全局的字体方案将会失效。  <p>方法二：使用translate()转换  <p>先将需要显示的中文转化为gbk编码的unicode，然后将unicode转化为QByteArray，在将只转化为char指针，并传递给translate()函数。  <p>注意：这种方法显示中文时，会出现失效的情况。譬如在菜单栏中可以显示中文，但是在Label或者Button中却无法显示中文。  <p>另外，这种方法仅仅建议只有少数按钮显示中文时选用，否则，代码写得也麻烦呀。  <p>如果使用QDesigner生成的ui文件，后创建的界面类，一般都有一个retranslateUI，就是做这个用的。  <p>const char * stringToUnicode(const char *str)  <p>{  <p>static QTextCodec *codec = QTextCodec::codecForName("gbk");  <p>QByteArray qba = (codec-&gt;toUnicode(str)).toLocal8Bit();  <p>const char * c_str = qba.data();  <p>return c_str;  <p>}  <p>menuFile-&gt;setTitle(QApplication::translate("MainWindow", stringToUnicode("文件"), 0, QApplication::CodecForTr));  <p>QTextCodeC用于在不同的编码方案之间进行转换。  <p>方法三：使用Linguist  <p>这是QT自带的用于软件本地化的软件的工具。没仔细研究过。  <p>这种方式可以用于外文软件的本地化，那么相比于前两者方式，处于更高的层次。  <p>延生一：编写多语言版本的QT程序  <p>（本部分内容参考QT手册Internationalization一节）  <p>在方法一和方法二种，仍然是一个程序对应一个语言。如果希望QT程序针对不同的语言，有不同的版本，该如何操作？  <p>准备一个.pro文件，如：  <p>HEADERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = funnydialog.h \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wackywidget.h  <p>SOURCES&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = funnydialog.cpp \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; main.cpp \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wackywidget.cpp  <p>FORMS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = fancybox.ui  <p>TRANSLATIONS&nbsp;&nbsp;&nbsp; = superapp_dk.ts \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; superapp_fi.ts \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; superapp_no.ts \  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; superapp_se.ts  <p>1. 使用lupdate，从QT程序中抽取可转换的文本，生成一个ts文件。  <p>2. 使用Linguist工具，在原始文本间转换。ts文件以xml格式保存，可以手动修改。  <p>3. 运行lrelease，生成轻量级的qm格式的消息文件。这种文件可以在程序中使用。  <p>4. In your application, you must QTranslator::load()&nbsp; the translation files appropriate for the user's language, and install them using <a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/QT_11AF3/qcoreapplication.html">QCoreApplication::installTranslator</a>().</p><img src ="http://www.cppblog.com/ronliu/aggbug/75006.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-02-26 20:09 <a href="http://www.cppblog.com/ronliu/archive/2009/02/26/75006.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse中CDT的设置</title><link>http://www.cppblog.com/ronliu/archive/2009/02/20/74395.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Fri, 20 Feb 2009 06:15:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/02/20/74395.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/74395.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/02/20/74395.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/74395.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/74395.html</trackback:ping><description><![CDATA[<p>1. 为什么使用Eclipse进行C++的开发。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因为Eclipse的IDE支持多种语言，如Java、Python、C++，也支持不同的操作系统。这样不管换到什么环境，或者换一种语言，熟悉的环境不会变化。</p> <p>2. 安装和设置Eclipse/CDT的环境。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a. mingw的安装与配置。<a title="http://www.cppblog.com/romangol/archive/2008/04/19/47595.html" href="http://www.cppblog.com/romangol/archive/2008/04/19/47595.html">http://www.cppblog.com/romangol/archive/2008/04/19/47595.html</a>。（PATH，C_INCLUDEPATH，CPLUS_INCLUDE_PATH, LIBRARY_PATH）</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b. Java虚拟机的安装与设置。（PATH）</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c. Eclipse/CDT的下载与安装。<a title="http://www.ibm.com/developerworks/cn/linux/opensource/os-ecc/index.html" href="http://www.ibm.com/developerworks/cn/linux/opensource/os-ecc/index.html">http://www.ibm.com/developerworks/cn/linux/opensource/os-ecc/index.html</a></p> <p>3. toolchain设置</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 新建一个自带makefile的helloworld程序，build可以通过。但点击运行时，<strong>提示找不到可执行文件</strong>。原因在于，新建项目时，<strong>没有选择合适的toolchain</strong>。如果是下载后解压后得到的CDT，那么toolchain已经内置在其中了。但如果是update的方式获取，则需要手动下载。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; 我安装的是mingw的编译环境，但选择cygwin，却仍然可以生成可执行的程序。奇怪的事情。获取是因为，设置configuration时，通过检查环境变量来获取实际调用的编译器？</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EclipseCDT_BDAE/image_2.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EclipseCDT_BDAE/image_thumb.png" width="244" height="54"></a>&nbsp;&nbsp; <img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EclipseCDT_BDAE/image_thumb_1.png" width="226" height="52"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EclipseCDT_BDAE/image_6.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/EclipseCDT_BDAE/image_thumb_2.png" width="346" height="30"></a>&nbsp;</p> <p>4. 何为toolchain？</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A toolchain is a set of tools (such as a compiler, linker, and assembler) <u>intended to build your project</u>. Additional tools, such as a debugger, can be associated with a toolchain. There can be several toolchains available, depending on the compilers installed on your system.</p> <p>5. 有哪些toolchain可供选择？</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; Cygwin，通过支持GNU libc运行库，它完全实现gun toolchain，使用dll向上提供Windows的兼容层。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; mingw。windows平台下gnu toolchain的入口，它直接使用windows c运行库，不需要兼容层，但可移植性要差一些。</p> <p>6. Eclipse如何使用这些toolchain？ TODO</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; The CDT is designed to provide an <strong>extensible architecture</strong>, that will provide support for <strong>integration of tools</strong> provided by Independent Software Vendors。</p> <p>&nbsp;</p> <p>附：</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Eclipse 平台只是用于开发者工具的一个框架，它不直接支持 C/C++；它使用外部插件来提供支持。CDT 是完全用 Java 实现的开放源码项目（根据 Common Public License 特许的），它作为 Eclipse SDK 平台的一组插件。这些插件将 C/C++ 透视图添加到 Eclipse 工作台（Workbench）中，现在后者可以用许多视图和向导以及高级编辑和调试支持来支持 C/C++ 开发。</p> <p>下面是 CDT 插件／组件的完整列表： <ul> <li><b>主 CDT 插件（Primary CDT plug-in）</b>是“框架”CDT 插件。  <li><b>CDT 功能 Eclipse（CDT Feature Eclipse）</b>是 CDT 功能组件（Feature Component）。  <li><b>CDT 核心（CDT Core）</b>提供了核心模型（Core Model）、CDOM 和核心组件（Core Component）。  <li><b>CDT UI</b>是核心 UI、视图、编辑器和向导。  <li><b>CDT 启动（CDT Launch）</b>为诸如编译器和调试器之类的外部工具提供了启动机制。  <li><b>CDT 调试核心（CDT Debug Core）</b>提供了调试功能。  <li><b>CDT 调试 UI（CDT Debug UI）</b>为 CDT 调试编辑器、视图和向导提供了用户界面。  <li><b>CDT 调试 MI（CDT Debug MI）</b>是用于与 MI 兼容的调试器的应用程序连接器。 </li></ul><img src ="http://www.cppblog.com/ronliu/aggbug/74395.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-02-20 14:15 <a href="http://www.cppblog.com/ronliu/archive/2009/02/20/74395.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QT编程之Layout</title><link>http://www.cppblog.com/ronliu/archive/2009/02/16/73971.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Mon, 16 Feb 2009 14:28:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/02/16/73971.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/73971.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/02/16/73971.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/73971.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/73971.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 对于QT的学习，一直处于半懂不懂的状态，看文档也只处于“貌似”的境界，导致真正碰到问题时就个屁掉。这次阅读basiclayout的demo说明，甚感惭愧，之前学得太肤浅。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1. 设计一个窗体，安排好它的函数和属性。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2. 基本的layout包括四类，QHBoxLayout，QVBoxLayout，QGridLayout，QFormLayout。前两个将widget水平或竖直防止，grid将widget以格子的形式放置，formlayout将widget以row的形式放置。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3. layout的使用方法是，先定一个layout，再向这个layout中添加widget，然后使用父类中的setlayout()，设置这个widget的layout。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4. layout有一个setMenubar，可以使得Dialog也可以设置菜单栏。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5. 在定义类时，定义一个enum，之后就可以直接使用这个enum中的元素。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6. QT赋参数的方法为tr("Button %1").arg(i + 1)。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7. QGridLayout有setColumnStretch(int, int)方法，用于设置grid中格子的伸长因子，也就是能够占用多大的空间。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8. QDialogButtonBox指用于确定/退出的button组。它是这两类常用button的一个box组合。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9. 本例中涉及到的其它widget包括：</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.&nbsp; QTextEdit，文本编辑框，支持plain text和html text</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b.&nbsp; QPushButton，按钮</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c.&nbsp; QGroupBox，将widget以box的形式组织在一起</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d. QLineEdit，行编辑框</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e. QComboBox，下拉框</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f. QSpinBox，spin框，提供数值选择。</p><img src ="http://www.cppblog.com/ronliu/aggbug/73971.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-02-16 22:28 <a href="http://www.cppblog.com/ronliu/archive/2009/02/16/73971.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Python操作cppblog的metablog接口</title><link>http://www.cppblog.com/ronliu/archive/2009/02/11/73508.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Wed, 11 Feb 2009 14:36:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/02/11/73508.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/73508.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/02/11/73508.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/73508.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/73508.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cppblog提供了metablog接口，供用户使用一些桌面工具操作blog。MetaBlogAPI是一个XML-RPC Service。它可以让用户远程调用Blog程序提供的接口来完成一些功能，比如发布新的文章，查看最新文章的列表等。<a title="http://dudu.cnblogs.com/articles/411388.html" href="http://dudu.cnblogs.com/articles/411388.html">http://dudu.cnblogs.com/articles/411388.html</a></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 先看cppblog的一个接口：</p> <p>metaWeblog.getCategories()的参数</p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_2.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_thumb.png" width="435" height="70"></a> </p> <p>返回结构体</p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_4.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_thumb_1.png" width="424" height="159"></a> </p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下面介绍使用Python来操作metablog接口。既然metablog是一个xml-rpc接口，那么就使用Python的xmlrpc库吧，好消息是这个库Python已经提供了，就是xmlrpclib。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 代码如下:</p> <p>import xmlrpclib</p> <p>user = 'ronliu'</p> <p>pass = '123'</p> <p>url = '<a title="http://www.cppblog.com/ronliu/services/metaweblog.aspx" href="http://www.cppblog.com/ronliu/services/metaweblog.aspx">http://www.cppblog.com/ronliu/services/metaweblog.aspx</a>'</p> <p>server = xmlrpclib.Server(url)</p> <p>cata = server.metaWeblog.getCategories('', user, pass)&nbsp;&nbsp;&nbsp; #典型的rpc调用</p> <p>for e in cata:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; print e['categoryid'], e['title']</p> <p>操作结果：</p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_6.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_thumb_2.png" width="240" height="163"></a>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用xmlrpclib的Server()方法，可以创建一个rpc服务器的代理，然后通过这个代理访问远程的方法。可以使用Python提供的调试功能查看rpc的执行过程：</p> <p>import httplib</p> <p>httplib.HTTPConnection.debuglevel = 1</p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_8.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_thumb_3.png" width="517" height="120"></a> </p> <p><a href="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_10.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/ronliu/WindowsLiveWriter/Pythoncppblogmetablog_13A60/image_thumb_4.png" width="388" height="114"></a></p><img src ="http://www.cppblog.com/ronliu/aggbug/73508.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-02-11 22:36 <a href="http://www.cppblog.com/ronliu/archive/2009/02/11/73508.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>体验51ditu的开放API</title><link>http://www.cppblog.com/ronliu/archive/2009/02/11/73492.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Wed, 11 Feb 2009 12:25:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/02/11/73492.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/73492.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/02/11/73492.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/73492.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/73492.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用这些api，即使一个门外汉也可以为自己的网站添加地图。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下面的代码，将会创建一个简单的地图网页。如：</p> <p>&lt;html xmlns="<a href="http://www.w3.org/1999/xhtml&quot;">http://www.w3.org/1999/xhtml"</a> &gt;<br>&lt;head runat="server"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;title&gt;地图测试&lt;/title&gt;<br>&nbsp;&nbsp;&nbsp; &lt;script language="javascript" src="<a href="http://api.51ditu.com/js/maps.js">http://api.51ditu.com/js/maps.js</a> "&gt;&lt;/script&gt;<br>&lt;/head&gt; </p> <p>&lt;body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div id="myMap" style="position:relative; width:400px; height:300px;"&gt;&lt;/div&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;script language="javascript"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var maps = new LTMaps( "myMap" );&nbsp;&nbsp; //LTMaps类有一个参数，是该地图所在div的name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maps.cityNameAndZoom( "beijing" , 5 );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var c = new LTSmallMapControl();&nbsp;&nbsp; //简单的放大缩小条<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maps.addControl(c);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var point = new LTPoint( 11640969 , 3989945 );//北京<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var marker = new LTMarker( point );&nbsp; //一个标记<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maps.addOverLay( marker );&nbsp; //将标记覆盖到地图涂层上<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var text = new LTMapText( marker );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text.setLabel( "我的位置" ); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maps.addOverLay( text ); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;  <p>详细的API说明在<a title="http://api.51ditu.com/docs/index.html" href="http://api.51ditu.com/docs/index.html">http://api.51ditu.com/docs/index.html</a>可以查询。</p> <p><img alt="" src="http://api.51ditu.com/docs/img/index/index_clip_image002.jpg" width="553" height="363"></p> <p>51API架构</p><img src ="http://www.cppblog.com/ronliu/aggbug/73492.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-02-11 20:25 <a href="http://www.cppblog.com/ronliu/archive/2009/02/11/73492.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>socket编程之端口占用 及socket高级选项</title><link>http://www.cppblog.com/ronliu/archive/2009/01/06/71312.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Tue, 06 Jan 2009 03:52:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/01/06/71312.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/71312.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/01/06/71312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/71312.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/71312.html</trackback:ping><description><![CDATA[现象：服务器端意外退出后马上重启，提示端口绑定错误，端口正在使用中。稍等一会后再次重启，可以正常运行。<br>可以设置socket的选项为SO_REUSEADDR，使其允许完全重复的绑定。<br>&nbsp;&nbsp;&nbsp; int rc = 1;<br>&nbsp;&nbsp;&nbsp; setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&amp;rc, sizeof(rc));<br>&nbsp;&nbsp;&nbsp; bind(fd, (struct sockaddr *) &amp;addr, sizeof(addr));<br><br>setsockopt的函数原型为：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 其中optval为选项的开关标志符，例如我使用rc＝1开启SO_REUSEADDR。<br>
<br>fcntl 文件控制，file control，譬如控制socket为非阻塞IO，信号驱动IO等。类似的有ioctl<br> <img src ="http://www.cppblog.com/ronliu/aggbug/71312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-01-06 11:52 <a href="http://www.cppblog.com/ronliu/archive/2009/01/06/71312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>三个月总结和三个月计划（一）</title><link>http://www.cppblog.com/ronliu/archive/2009/01/04/71113.html</link><dc:creator>ronliu</dc:creator><author>ronliu</author><pubDate>Sun, 04 Jan 2009 03:13:00 GMT</pubDate><guid>http://www.cppblog.com/ronliu/archive/2009/01/04/71113.html</guid><wfw:comment>http://www.cppblog.com/ronliu/comments/71113.html</wfw:comment><comments>http://www.cppblog.com/ronliu/archive/2009/01/04/71113.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ronliu/comments/commentRss/71113.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ronliu/services/trackbacks/71113.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; （一）感冒了，浑身发抖，头疼，胸口疼，胃疼。不注意保暖，以及严重的不规律饮食带来的。现在只想早些跑回去钻被窝加衣服。网络小说是不能看了，不规律的饮食很大程度与此有关，且影响学习状态。可以多读一些历史，政治，经济方面的书，比如世界通史之类。关注养生，病殃殃的状况实在难受，学会调养自己的身体。有条件的话，可以多锻炼一些。<br>&nbsp;&nbsp;&nbsp;&nbsp; （二）找工作期间，最遗憾的是，没有拿得出手的技能，以及拿得出手的成果。在找完工作之后，就开始急于求成，一心想作一个东西出来，但经常是想了却不做，做时半途而废，然后又开始新的想法。很浮躁，急于求成。在今后的三个月，可以多作技能方面的锻炼。比如编程语言，能否作到精通？需要锻炼的技能包括：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 甲。语言是表达思想的工具，语言说不好，不精通，再好的思想也表达不出来。反过来，语言学得好了，会促进思维的成长。然后，掌握一门专精的语言，也是将来安身立命，向更深层次的架构师成长的根本。但就目前，有什么语言是真正拿的出手的？C＋＋是最熟悉的，却仍然谈不上精通。在今后的三个月，对C＋＋的深入锻炼，是重点。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 乙。在平常的编程中，算法用的似乎并不多，但对培养计算机的思维，培养设计能力，很有好处。更高层的，如设计模式之类。可以将语言的学习和算法，设计模式的学习结合起来。<br>&nbsp;&nbsp;&nbsp;&nbsp; （三）新的一年，增大一岁。不知不觉，二十好几。回头看时，什么也没有做成。感情上，学业上，以及和家人的关系，都不如意。这是浮躁的根本原因。但这些问题，却不是一蹴而就的，需要时间的积累，需要精力的积累，不是随想就有的。就像Scott信中的那位技术总监，没有5年甚至5年以上的技术沉淀，能够将技术玩到如指臂使？淡然，做好自己该做的。清风抚山岗，明月照大江。高三毕业那年，能够坐在河边，对广场上人来人往充耳不闻，和尚念经般默诵这两句话，心中淡然。年龄增大，考虑增多，却越来越浮躁了。在浮躁和淡然之间，需要有一个平衡。<br>&nbsp;&nbsp;&nbsp;&nbsp; （四）做好接下来的三个月！<br>  <img src ="http://www.cppblog.com/ronliu/aggbug/71113.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ronliu/" target="_blank">ronliu</a> 2009-01-04 11:13 <a href="http://www.cppblog.com/ronliu/archive/2009/01/04/71113.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>