分类存档: 技术文章

Beyond Compare应用技巧之Comparison Rules

Beyond Compare的比较功能比较强大,相信很多程序员来讲,应该相当熟悉了。

它的Comparison Rules功能很强,用以满足各种不同条件下的比较操作。

遇到的问题:当待比较的2个文本文件开头不同,而且这些开头的部分往往不是我们想要关心的不同之处时,我们可以利用BC的Unimportant Text(非重要文本)功能来识别这些字段,并且在实际比较中忽略这些非重要文本。

举例:

Beyond Compare unimportant text

Beyond Compare unimportant text (点击图片查看大图)

如上图所示,两个文件每一行的开头分别是 10和11,比较的时候,会导致BC认为所有的行都有不同,而我们关心的是除了开头部分两个文件是否还有其他的不同。

这种情况下,我们可以编辑当前比较选项(Edit Current Rules…),选择“Importance”标签页,点击“New”添加一个新的Unimportant Text项,类型选择“Regular Expression”正则表达式:

^1\d\t1\d

上面的正则表达式的解释:以 ^表示行的开头, \d表示(0-9)任意一个数字,\t是制表符

(如下图)

Beyond Compare Comparison

Beyond Compare Comparison Unimportant Rules(点击图片查看大图)

这样上面的正则表达式可以匹配如 10(Tab)10****         或者 11(Tab)11****

点击确定后,BC的比较界面会把匹配识别的 Unimportant Text以蓝色显示。

Visual C++调试时查看数组内容

微软文档原文地址:

http://support.microsoft.com/?scid=kb%3Ben-us%3B198953&x=9&y=9

Starting with Visual C++ version 6.0, it is now possible to expand an array pointer to view all array elements in the Visual C++ Debugger Watch window. This feature is not documented.
从 Visual c + + 6.0 版开始,现在可以展开 Visual c + + 调试器监视窗口中查看所有数组元素的数组指针。 此功能未记录。

In the Watch window, type an expression that evaluates to a pointer followed by a comma and the number of elements in the array.
在监视窗口中键入一个表达式,该表达式计算为后跟一个逗号和数组中的元素数的指针。

  1. 作为控制台应用程序生成下面的代码的调试版本。
       // Filename main.cpp
       // No compile option needed
    
       #include <iostream.h>
    
       void main(void)
       {
         int * p;
         char* ptr = "Hello World";
         p = new int [10];
    
         for(int i=0; i<=9; i++){*(p+i) = i+1;}
         cout << i <<endl;
       }
  2. 使用调试器单步执行该代码,并在最后一行代码处停止。
  3. 在监视或 Quickwatch 窗口中添加变量 pptr。 您将看到变量旁边的 + 符号。
  4. 单击 + 符号以展开该变量。 您将看到它指向的数组中,只有第一个元素。
  5. 在监视窗口中现在,键入 p,10ptr,11
  6. 单击 + 符号以展开该变量。 现在,您看到它指向的数组的所有元素。

如果您要查看特定范围的元素,然后输入第一个元素来指定在上述步骤中所述跟格式说明符将起始索引的地址。 例如,(p+3),8 显示元素 p [3..10] 和 (ptr+3),10 显示元素 ptr [3..12]。 在监视窗口中的起始索引是 [0] 的不幸的是,这实际上对应于在此示例中的索引 3。 您必须记住偏移量 3 具有要添加到每个显示的索引,以获取数组元素的实际索引。

Windows XP系统关闭CD ROM的Auto-Play(自动播放)

微软文档:
How to disable the Autorun functionality in Windows
方法一,通过组策略设置(注意:Windows XP HOME不支持):

How to use Group Policy settings to disable all Autorun features in Windows Server 2003, Windows XP Professional, and Windows 2000

  1. Click Start, click Run, type Gpedit.msc in the Open box, and then click OK.
  2. Under Computer Configuration, expand Administrative Templates, and then click System.
  3. In the Settings pane, right-click Turn off Autoplay, and then click Properties.

    Note In Windows 2000, the policy setting is named Disable Autoplay.

  4. Click Enabled, and then select All drives in the Turn off Autoplay box to disable Autorun on all drives.
  5. Click OK to close the Turn off Autoplay Properties dialog box.
  6. Restart the computer.

方法二,通过注册表(所有XP系统有效,但是要修改注册表,这个操作有一定风险,请操作前备份好注册表。):

How to disable all Autorun features in Windows XP Home Edition and other operating systems.

For operating systems that do not include Gpedit.msc, follow these steps:

  1. Click Start, click Run, type regedit in the Open box, and then click OK.
    点击”开始“按钮,点击”运行“,在运行对话框中输入”regedit “, 然后点击”确定“。
  2. Locate and then click the following entry in the registry:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDriveTypeAutorun
    定位到如下注册表键值:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDriveTypeAutorun
  3. Right-click NoDriveTypeAutoRun, and then click Modify.
    右键选择”NoDriveTypeAutoRun“这个键,然后点击”修改“。
  4. In the Value data box, type 0xFF to disable all types of drives. Or, to selectively disable specific drives, use a different value as described in the “How to selectively disable specific Autorun features” section.
    在弹出的键值修改对话框中,把原来的值修改为0xFF。或者用不同的值来有选择性地禁用指定驱动器,详见”How to selectively disable specific Autorun features”章节。
  5. Click OK, and then exit Registry Editor.
    点击确定,然后退出注册表编辑器。
  6. Restart the computer.
    重启计算机,使设置生效。

C++中类和结构体的区别(Differences between C++ Classes and Structs)

引用地址:

http://blog.stevedoria.net/20050913/differences-between-cpp-classes-and-structs

请注意,本文讨论的前提是在C++标准下的类和结构体,而不是讨论C中的结构体.

The only difference is the default visibility of members (both support data and functions and constructors and destructors).
- classes have private members by default
- structs have public members by default
可见,在C++中,类和结构体的唯一区别是成员的可见性(两者都支持数据和成员函数以及构造函数和析构函数).
对于类来说,成员默认为私有.
对于结构体来说,成员默认为公有.
对于继承来说,类之间的继承,成员默认为私有,而结构体之间的继承则默认为公有.

不过,还有爱钻牛角尖的同学会问,如果是类和结构体之间的继承,情况会怎样呢?

class A
{
public:
int a;
};

struct B : A { };

struct C
{
int c;
};

class D : C
{
};

int main()
{
B b;
D d;
b.a = 1;
d.c = 2;
}

用 C++编译器编译上面的代码,会在 d.c = 2;处报错,VC 6.0给出的错误提示:error C2248: ‘c’ : cannot access public member declared in class ‘C’,看起来有点匪夷所思啊,不能访问公有成员(既然都公有了,还不能访问?).
相应的C++标准 11.2.2 of ISO/IEC 14882-2003文档:
the kind of inheritance is determined by the derived class being declared as a class or struct when an access specificer for the base class is absent.
当被继承的基类缺少存取说明符的修饰时, 继承的类型由被声明为类或者结构体的派生类所决定.
示例中class D : C, 基类C并没有存取说明符的修饰,那么集成的类型就由派生类D来决定,D被声明为类(而非结构体),对于类来说,类之间的继承,成员默认为私有,所以实际上此时的int c;应该为私有,那么上面的编译错误也就可以解释通了.
我们可以试着把class D : C 改为 class D : public C,就可以编译通过了.

Drupal安装手记(解决Fantastico安装无法切换中文问题)

Fantastico安装drupal6.X,首先它装的不是最新版本,但是由于Fantastico可以很方便的进行升级维护,而且安装步骤非常简单,像我这样的懒人肯定是要先尝试一下这么容易的操作了。

问题出在汉化这里,上传了语言包后,到后台选择Add Language,可是无论怎么填都是会出错。

错误提示如下:

Drupal Fantastico Error

Drupal Fantastico Error

Google了半天,Drupal官方上对于类似问题也都没有很好的办法,我的解决办法是(土法):

1.  备份网站数据库,其他必要的程序。

2.  删除Drupal数据库,然后重建同名的数据库。

3. 运行http://yoursite.com/Drupal/install.php

重新安装后,中文就可以用了。

该解决方法的问题:

1. 需要删除重建数据库

2. 重新安装后,Fantastico管理面板中原来的Drupal安装信息丢失 :-(

Co-installer for Device and Driver Installation

相关链接: MSDN http://msdn.microsoft.com/en-us/library/ms790156.aspx

顾名思义,Co-installer是个微软的Win32 DLL(动态链接库)用来协助设备安装。

A co-installer is a Microsoft Win32 DLL that assists in device
installation. Co-installers are called by SetupAPI as “helpers” for
Class Installers. For example, a vendor can provide a co-installer to
write device-specific information to the registry that cannot be
handled by the INF file.

The shaded boxes represent the components that you can provide for the system-supplied device setup classes.
The operating system supplies the other components. If you create a
custom device setup class, you can also supply a class installer.
However, you rarely need to create a new device setup class, because
almost every device can be associated with one of the system-supplied
device setup classes. For more information about Setup components, see Device Installation Overview.

Co-installers can be device-specific or class-specific.

Canonical URL by SEO No Duplicate WordPress Plugin