Chinaunix首页 | 论坛 | 博客
  • 博客访问: 772552
  • 博文数量: 217
  • 博客积分: 2401
  • 博客等级: 大尉
  • 技术积分: 2030
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-16 06:58
个人简介

怎么介绍?

文章分类

全部博文(217)

文章存档

2023年(2)

2022年(3)

2021年(29)

2020年(12)

2019年(5)

2018年(5)

2017年(5)

2016年(3)

2015年(6)

2014年(12)

2013年(16)

2012年(9)

2011年(6)

2010年(15)

2009年(30)

2008年(59)

我的朋友

分类:

2008-09-21 17:23:00

Introduction

GRETA gives you all the power of PERL 5 regular expressions in your C++ applications. This is the of GRETA. Today, we will discuss neither nor template classes in the GRETA library, because you can get familiar with them at the GRETA homepage. Here, I will explain how to add and build the GRETA library in Visual C++, step by step.

Download

Download GRETA's source code from GRETA homepage. For example: GRETA 2.6.4 for VC6, you will get 'greta-2.6.4-vc6.zip'. Or, you can . Please do not download the *.lib file for GRETA (such as greta.lib etc.). You may find GRETA in the *.lib file from Microsoft. But greta.lib may not satisfy your needs. It may generate link errors.

Usage

GRETA library has six program files:

  • regexpr2.h
  • regexpr2.cpp
  • syntax2.h
  • syntax2.cpp
  • restack.h
  • reimpl2.h

Create a new 'Win32 Static Library' project for GRETA in your workspace:

  • Step 1: Create a blank workspace. For example, 'Test':

  • Step 2: Create the main project that will use GRETA. For example, 'Console' type 'Main':

  • Step 3: Create the GRETA project. Select 'Win32 Static Library' and make it a dependent of the Main project. After this, press the OK button, let the 'Pre-Compiled header' and 'MFC Support' remain unchecked:

  • Step 4: Copy those six program files from the GRETA zip package into the GRETA project's directory and add them to the project:

  • Step 5: Copy one of the example codes into the main() function. Change #include "regexpr2.h" to #include "..\greta\regexpr2.h". These examples are in the HTML file of the GRETA zip package. Select 'Main' project as the active project, then compile and run the project:

This is the final result that you get:

Now, we have successfully finished the project with GRETA. [].

If your project uses Unicode or your main project is DLL type, please go on with the following.

Unicode version

If your project (which uses GRETA) is of Unicode version, you must make the GRETA project to be of Unicode version. For example:

  • Step 1: Add a 'Unicode Debug' configuration for your GRETA project:

  • Step 2: In the project settings, add '_UNICODE' and 'UNICODE' macros into the C++ general preprocessor definitions of the corresponding 'Unicode Debug' configuration:

  • Step 3: Repeat step 1 and step 2 for the 'Main' project as well as for 'Release' configuration.

You will get 'Unicode Debug' and 'Unicode Release' configurations for both GRETA and your main project.

Runtime library

In many cases, when your main project is DLL type, you must make sure that GRETA uses the same runtime library as your main project, or you will get a link error.

  • Step 1: To find out which runtime library your main project uses:

  • Step 2: Select the same runtime library for GRETA project. Now, you can link successfully.

Q: Why do we need to download greta.lib and why the downloaded greta.lib generates link error?

A: This is because of "Unicode version" and "Runtime library". Because it is not known whether the downloaded greta.lib is of Unicode version, and it is also not known which runtime library the downloaded greta.lib uses, so it may generate link errors.

Regular expression tools

  • (Chinese readers can .)
  • (Chinese readers can .)

License

This article, along with any associated source code and files, is licensed under

About the Author

阅读(2157) | 评论(0) | 转发(0) |
0

上一篇:vim regular expressions

下一篇:隔夜黄莺

给主人留下些什么吧!~~