Here are some C and C++ libraries, DLLs, VCLs, source code, components, modules, application frameworks, class libraries, source code snippets, and the like, that you can use with your programs without payment of fees and royalties. Note that some libraries (etc) listed here may have certain restrictions about its use and/or distribution. Be sure you read the licence conditions in each package before using them.
A few types of libraries have been moved to their own pages, due to the large number of items in those categories. Here are some of the other pages containing free libraries on this site:
The information provided on this page comes without any warranty whatsoever. Use it at your own risk. Just because a program, book or service is listed here or has a good review does not mean that I endorse or approve of the program or of any of its contents. All the other standard disclaimers also apply.
If you want your applications to support Adobe Type 1 fonts, this rasterizing library might be just what you need. It requires a Unix system. It is implemented independently of X11, so it might be the solution for those of you who don't want to use the Type 1 rasterizer provided with X11R5 and later. The source code for the package has a filename like t1lib-*.tar.gz (where * is replaced by the version number). Latest: There is a Windows port of t1lib available as well.
Heard of True Type? Well, now you can include True Type support in your programs on systems that do not have True Type support by default. Linux and other OSes are supported.
This version of STL (Standard Template Library for C++) is available free of charge from their website. It is apparently also shipped with the current versions of the Borland C++ compilers.
If your compiler does not have a recent Standard Template Library implementation, you might want to consider this version available free from SGI.
The LinuxThreads library implements Posix 1003.1c threads on (as the name reveals) Linux. It provides kernel-level threads where scheduling is handled by the Linux kernel. Thus, unlike user-level thread packages, it can take advantage of multiprocessors.
This C library implements POSIX threads on a variety of operating systems, including Linux, FreeBSD, SCO Unix, Solaris, SunOS and DOS.
QpThread is a C++ framework for threads and Unix signals that operates on top of POSIX threads. It supports deferred cancellation (through C++ exceptions), timers, thread pools, etc.
ICU, or the International Components for Unicode, comprises C/C++ and Java libraries for Unicode support, internationalisation and globalisation (i8n/g11n). It supports Unicode text handling, full character properties and character set conversions, with more than 500 codepages, Unicode regular expressions, language sensitive collation and searching, normalisation (normalization), upper/lowercase, script transliterations, more than 230 locale data, multi-calendar and time zones, formatting of dates, times, numbers, currencies, messages, etc. If you are writing an application that requires internationalization and globalization support, and are working with Unicode, this is something that you should check out. It is licensed under the X License (an open source licence). Platforms supported include Windows, Linux, AIX, HP-UX, Solaris, etc.
This site is a source of "free peer-reviewed portable C++ source libraries" (quoted from the site). There are numerous libraries available, including libraries for managing date and time, filesystems, iterators, random numbers, regex, tests, strings, text processing, containers, math and numerics, data structures, memory, parsing, concurrent programming, algorithms, etc.
STLSoft is a collection of templates in header form that contain numerous classes and functions for Windows and Unix systems. Included in this library are ATLSTL (for creating COM components with the Active Template Library), COMSTL (allows the manipulation of the Component Object Model interfaces and API), .netSTL (applies STL techniques to the .NET framework), InetSTL (applies the STL techniques to the Internet APIs), MFCSTL (allows the manipulation of the Microsoft Foundation Classes or MFC), UNIXSTL (library for programming Unix-type systems), and WinSTL (allows you to program using the Windows API). The library comes with documentation and works with numerous compilers including Borland C++, Comeau C/C++, Digital Mars C/C++, GNU gcc, Intel C/C++, Metrowerks Codewarrior, Microsoft Visual C++, and OpenWatcom. As of version 1.8.1, STLSoft is licensed under the BSD license.
libunicows allows you to write programs that use Unicode on Windows 9x/ME with a compiler other than Microsoft Visual C++ (the Microsoft unicows library requires Visual C++). This library supports (at the time I write this) MinGW, Visual C++ 6, Borland C++, and Watcom (and OpenWatcom) C/C++. It comes with source code released under the MIT licence.
OSLib is a C library for programmers writing system software (whether it be embedded software or even entire operating system kernels). It comprises 4 libraries (the extender library, the standard C library, the math library and the kernel library).
The MIT Exokernel Operating System attempts to provide a level of abstraction of hardware so that you can concentrate on the other aspects of implementing an operating system. It may be useful to those of you planning to write an operating system.
The OSKit Project is a C framework of 34 components providing a wide variety of facilities that is useful for people planning to write operating system kernels, servers, boot loaders, embedded applications and the like. The function libraries provide numerous facilities, including some common C library services (string, memory, printf, etc), default handlers for traps and interrupts, kernel support functions such as those that set up and manipulate page tables (etc), support for multiprocessor systems, POSIX emulation system call libraries, memory management, threads, synchronization, scheduling, debugging aids, hard disk handling, file system implementations, device driver implementations (SCSI, IDE, network drivers), video driver implementations, etc. The portions of OSKit that contain machine-dependent code currently supports Intel x86 and Digital DNARD (StrongArm SA-110 CPU).
regex is a regular expression parser that is released into the public domain (or so the site says). It is useful if you want to write a program using regular expressions but don't want to use the GPL ones that come from the Free Software Foundation. (The package is somewhere in the middle of the page linked to; just scroll down to find it.)
glob is a parser to handle wildcards (similar to the way that Unix shells parse wildcards). It is released into the public domain (or so the site says). It is useful if you want to write a program with globbing facility but don't want to use the GPL ones that come from the Free Software Foundation. (The package is somewhere in the middle of the page linked to; just scroll down to find it.)
SynEdit is a multi-line edit control that you can use in your Delphi and Borland C++ Builder programs. Features include syntax highlighting for a variety of programming languages and a macro recorder. This is a VCL control that comes with source code.
libsigc++ has C++ classes that provide you a typesafe callback system. You can define signals and assign callback functions to those signals. It is licensed under the GNU Library General Public License (LGPL). It works on platforms with a standards-compliant C++ compiler, such as those with gcc (see the Free C/C++ Compilers page for gcc). A port for Microsoft Visual C++ (which does not implement partial specializating) has also been integrated into the distribution, so the library should also work with that compiler.
The Standard Function Library, or SFL, contains routines for compression, encryption, encoding, data type conversion, data output formatting, process control, dates, times, calendars, symbol tables, linked lists, configuration files, error message files, string manipulation, searching, Internet socket access, MIME, CGI, SMTP, batch programming, debug tracing, directory access, environment access, etc. It is designed with portability in mind. The library is written in ANSI C and is supported on MSDOS, Windows, OS/2, Linux, AIX, SunOS, HP/UX, Solaris, NetBSD, FreeBSD, SCO OpenServer, Digital Unix, and OpenVMS. The source code is also available.
HTML Tidy is an HTML validation library that comes with source code. It allows you to embed HTML validation facilities into your application, which may come in handy if you are writing your own editor.
Views extends STL to include domain views, which allows you to simplify your code when you work with containers.
GNU Lightning is a library of routines that allows programs to generate assembly language code at runtime. It abstracts the target CPU, exposing your program to a standardized RISC instruction set. The library is supposed to be fast, thus making it useful if you're developing a Just-In-Time compiler.
Ever wanted to create your own syntax-highlighting editor? Scintilla is a source code edit control, similar in concept to Microsoft's RichEdit control, that supports things like syntax highlighting, code completion and call tips. It also supports things like the use of proportional fonts, bold, italics, multiple foreground and background colours, and multiple fonts. The source code is available free, and the licence allows you to use the control in any project, free or commercial.
If you need to add speech to your programs, or enable it to process speech input, TurboPower's Async Professional provides you an easy access to Microsoft's Speech API (SAPI) allowing you to integrate voice/speech recognition and speech synthesis in your programs. It also handles the sending and receiving (as well as viewing and printing) of faxes (and converts BMP, DCX, PCX and TIF files automatically), alphanumeric and text (GSM/SMS) paging, high speed file transfers (including the major file transfer protocols like Zmodem and FTP), IP telephony (audio and video, Voice Over IP or VOIP), Internet communications (Winsock access), supports ISDN modems, RS-232 and RS-485 standards, and includes an XML-based modem database. And so on. Like most of the TurboPower tools, this open source toolkit may be used with Delphi and Borland C++ Builder and ActiveX environments like Microsoft Visual C++ and Visual Basic. If you use Borland Kylix on Linux, you might want to try the TurboPower Async Professional CLX version.
TurboPower SysTools contain numerous utility functions and classes for Borland Delphi and Borland C++ Builder as well as programming environments that support COM objects (like Microsoft Visual Basic, Microsoft Visual C++. Among the routines included in this library are string manipulation routines, date and time math routines, high-speed sorting, high-precision maths, runtime math expression analyzer, Microsoft Excel-like finance and statistical routines, email attachment MIME encoding and decoding, reusable containers (stacks, queues, trees, deques, hash tables), CRC data integrity checking, 1 dimensional and 2 dimensional (1-D and 2-D) bar codes, money routines, logging classes, patterns, random number distributions, text data manipulation and more. SysTools is open source, released by TurboPower under the Mozilla Public License. It works on Windows systems. There is also a version of TurboPower SysTools for Kylix.
TurboPower Orpheus contains over 120 VCL components such as data entry components, data entry validators, grid for presenting and editing 2 column information, status bars, progress bars, button and tab styles, reports, countdown and elapsed timer components, etc. Orpheus is open source, and may be used with development tools that support VCL such as Borland Delphi and C++Builder.
ShellShock contains native VCL components that allow your application to integrate with the Windows shell and Windows explorer. Included in this package are tree views, list views, combo boxes, enumeration of folder contents, monitoring of shell events, file operations (copy, delete, move, rename, together with Windows shell animations), drag and drop support, Windows shortcut creation and inspection, customization of common dialog boxes, minimization to the system tray, etc. You need to use a development tool that supports VCL such as Borland C++Builder and Delphi to use this toolkit. ShellShock comes with source code.
If you need to create demo versions of your programs, you might want to check out TurboPower's OnGuard library. The library provides you the ability to create applications that are time-limited, feature-limited, limited to a certain number of uses, limited to a certain number of concurrent network users, etc. Written in Object Pascal, it may be used in Windows development using tools like Borland C++Builder or Delphi.
TurboPower Essentials has 13 open source native VCL components that provides drop-down calendars and calculators, roll-up dialog boxes, 3-D labels, tiled backgrounds, scrolling messages, menu buttons, etc. You need to use a development tool that supports VCL such as Borland C++Builder and Delphi to use this toolkit.
Add time, task and contact management to your applications with Visual PlanIt's synchronized data-aware VCL components. You can create mult-column Outlook style contact grids; day, week, month event views, Outlook style task lists, connect-and-go database connectivity, printing, etc. The components are compatible with Delphi and C++Builder (and presumably any other development system that supports VCL components).
GetPot, an anagram of the ubiquitous getopt, allows programs to parse command lines and simple input files by simply including the header file for the library (the entire library is apparently in the header file). C++, Java, Ruby and Python versions are currently available. The library is distributed under the GNU LGPL.
MyLibC is a clone of glibc for Windows. The author wrote this to reduce the size of executables that resulted when glib was used on Windows. Sources are provided.
uClibc is a C library for developing embedded Linux systems. It supports shared libraries, multithreading and runs on standard Linux systems with support for ARM, i386, h8300, m68k, mips, mipsel, PowerPC, SH, SPARC, and v850 processors.
GradC++ ToolBox contains several C++ components dealing with threading, program options, logging, and initialisation of COBRA services. It comes with an administrative guide, programmers' guide and sources. The C++ library may be used free of charge for non-commercial purposes.
This library has functions which you can call from your MSDOS programs to access the long filenames (LFN) API found in Windows 95 and above. It thus makes it easy for you to write long file name (LFN) support. The library contains the POSIX.1 compatible opendir() functions, DOS findfirst() functions, open() functions, fopen() functions, mk/rm/chdir(), remove(), unlink(), rename(), getcwd(), getdcwd(), getcurdir(), fullpath(), lfn2sfn(). As you can see, all the hard work of accessing the API has been done for you - just use the usual familiar functions (whether Unix or DOS). It requires a Borland compiler to compile (which you can get it for free, legally - check out our Free C/C++ Compilers page).
This is a library that eases the work needed to port Unix programs to NT. There aren't many details on the website about the libraries' capabilities, but you can simply download it from their site and check it out yourself.
ClibPDF is a C library that allows you to create PDF files from your application or even CGI scripts. With PDF files becoming more popular on the Internet, it is beginning to look like it may be a good idea for more applications to be able to create and access PDF files. The library is free if you are using it for non-profit purposes.
This C++ graph library, based on the Standard Template Library (STL), contains classes useful when you work with graphs, nodes, and edges, as well as basic algorithms which can be used to build more complex graph algorithms. The library has been used on Solaris, Linux, Windows NT, 95, 98, HP-UX and FreeBSD, although it is possible that it works elsewhere as well.
Matrix TCL Lite is a C++ matrix template class that may be used for common matrix operations like any other built-in data types. It has been tested with Borland C++ 5.0 (both 16 and 32 bit); Borland C++ 5.5, C++ Builder version 1.0, 3.0, 4.0 and 5.0; MS Visual C++ version 4.0, 4.2, 5.0 and 6.0; SUN g++ under Sun Solaris; GNU C++ and SGI C++ version 7.2.1; Metrowerks CodeWarrior Pro 5; and Sybase Power++ v 2.1.
Ensemble is a toolkit for building reliable distributed applications. Included in this toolkit is a library of protocols which you can use to build your distributed applications. The library primarily uses UDP/IP sockets. You can write your applications in C, C++, Java (on Solaris and NT), and ML. Ensemble itself is written in ML and will apparently run on any platform that supports Objective Caml and sockets, including Windows, SunOS4, Solaris, Linux and RS6000-AIX. You can get the binaries for SunOS, Solaris, Linux and Windows NT. Source code is also available for download.
This is a plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Versions are available for C, Fortran 77 and Fortran 90 compilers on Linux, FreeBSD, OpenVMS, MS-DOS, Windows 95/98/NT, and other flavours of Unix. On some operating systems, Java, Perl, and Python are also supported. (Not all versions of the library are free, though.)
This C library "allows network management applications to access SMI MIB module information through a well defined API that hides the nasty details of locating and parsing SMIv1/v2 MIB modules."
This is a simple network library built on top of glib. It works on Linux, BSD, Mac OS X, Solaris, HP and Windows.
This is a "Unix-based Garmin CPS communication and analysis function library and development system. To quote/paraphrase from their documentation, it includes high level host communication routines that treat waypoints, almanacs, etc as objects; datum conversions; cartographic functions; etc. The source code is distributed under the GNU LGPL, and is written in ANSI C.
Whisper is a general purpose C++ application framework, which takes advantage of templates, multiple inheritance, STL and exceptions. It is portable to both Macintosh and Win32. It contains numerous debugging tools.
This is a CORBA 2 ORB (with associated libraries) that was originally developed by AT&T Laboratories, Cambridge, and is certified CORBA 2.1 compliant. OmniORB is distributed under the GNU GPL and the libraries in the package is distributed under the Library GPL. The package is designed in such a way so that you can actually distribute your applications that use the libraries without being forced to release your source code as well. Platforms supported include Solaris, Windows NT, Windows 95, Linux (x86, PowerPC), Digital Unix, AIX, HPUX, Open VMS (Alpha and Vax), NextStep, Reliant Unix, Phar Lap's Real Time ETS Kernel, SGI Irix, SCO Unixware, MacOS, OS RTEMS, SCO OpenServer, etc. In case you are wondering what CORBA is, it basically defines the interface and API that allows programs to communicate with each other even if they are running on separate machines on different hardware and operating systems. If you need more information, you can check up the Object Management Group's website for their beginner's guide.
GNU Common C++ is a C++ framework for developing portable threaded applications. It has abstractions for threads, sockets, XML parsing, serialization, config files, and so on, hiding the differences between platforms in its classes so that you can write code that is (hopefully) portable. It is released under the GNU GPL license.
Hoard is a malloc/free replacement that is supposed to be fast, scalable and memory efficient. It supports Linux and other Unix platforms.
This is a free implementation of the curses package of Unix. It has all the BSD curses facilities plus the System V enhancements. Platforms supported include Linux and most (if not all) Unix systems. It has been ported even to OS/2. For those not familiar with curses, this is library that allows programs to write to the screen in a terminal-independent manner.
A C++ class library that has a number of features, including classes for retrieving files via HTTP, sending and receiving email, database classes, thread support, string class, html parser, etc. It supports Unix platforms.
A garbage collector for C/C++ that can also function as a memory leak detector. You can simply replace your calls to malloc() with GC_malloc(). Win32, Win32s, OS/2, MacOS, AmigaDOS and Unix systems are supported.
Added : 04/12/1997 Amended : 04/12/1997 Licensing : N/A
This list is not exhaustive. If you are looking for a particular library, and you don't find it here, try an ordinary Web search engine (e.g. Google). If you do find a suitable library, why not use the submission form to add it to this list for the next person?
Due to the increasing size of this list, and problems with updating the automatic poster at rtfm.mit.edu, the full list is now only available on the Web (at "http://www.trumphurst.com/cpplibs/" and "http://purl.oclc.org/NET/C++Libraries").
Marshall Cline's C++ FAQ is available on his Web page.
I have not included a credits list, because it would be nearly as large as the rest of the file! Many thanks to all those who contributed, and I hope you won't be offended that I haven't mentioned you.
Please mail comments, criticisms, additions and amendments to me at cpplibs@trumphurst.com. However, please DO NOT mail me with requests for assistance in finding files mentioned in the list. I am unable to provide such a service. Definite information such as "file xyz is no longer at site xxx" IS welcome - even better if you can tell me an alternative site where it can be found. If you are new to the Internet, try to find out about tools such as archie, whois, www, gopher etc. I recommend the newsgroups "news.announce.newusers" and "news.answers" for starters. See also the Web "roadmap" to such services listed below.
Added : 01/01/1995 Amended : 16/05/2006 Licensing : N/A
Please add references at the end of your text in the form <tag>:<item> [;<link text>]
Where
Added : 01/01/1995 Amended : 09/04/2001 Licensing : N/A
Added : 01/01/1995 Amended : 26/04/2000 Licensing : N/A
Mail amendments or additions to this list
A Web form for submissions to this list
Mail the author for permission to distribute
Copyright (c) 2006 Nikki Locke, Trumphurst Ltd.
Permission is granted to distribute over the Internet without charge.
The author's permission is required (and usually given) to distribute
in any other way, including on CD.
原文Qhttp://www.vckbase.com/document/viewdoc/?id=1540 |
|
C++ 扩展和嵌?Python
作者:胡金?/a>
常用的Python/C API介绍
下面是例子中用到的几个Python/C
API的简要介l及CZ代码。注意,qƈ不是q些函数的详l介l,而仅仅是我们所用到的功能简介,更详l内容请参考文[1]、[2]、[3]、[4]?br />
打开Microsoft Visual Studio .NET 2003Q新Z个控制台E序Q?include <Python.h>Qƈ在main函数里加入示例代码?br />
//先定义一些变?
char *cstr;1. void Py_Initialize( )
PyObject *pstr, *pmod, *pdict;
PyObject *pfunc, *pargs;
执行一DPython代码Q就好象是在__main__ 函数里面执行一栗例Q?/p>
PyRun_SimpleString("from time import time,ctime\n"3. PyObject* PyImport_ImportModule( char *name)
"print ''Today is'',ctime(time())\n");
导入一个Python模块Q参数name可以?.py文g的文件名。相当于Python内徏函数__import__()。例Q?/p>
pmod = PyImport_ImportModule("mymod"); //mymod.py4. PyObject* PyModule_GetDict( PyObject *module)
相当于Python模块对象的__dict__ 属性,得到模块名称I间下的字典对象。例Q?/p>
pdict = PyModule_GetDict(pmod);5. PyObject* PyRun_String( const char *str, int start, PyObject *globals, PyObject *locals)
执行一DPython代码?/p>
pstr = PyRun_String("message", Py_eval_input, pdict, pdict);6. int PyArg_Parse( PyObject *args, char *format, ...)
解构Python数据为C的类型,q样CE序中才可以使用Python里的数据。例Q?/p>
/* convert to C and print it*/7. PyObject* PyObject_GetAttrString( PyObject *o, char *attr_name)
PyArg_Parse(pstr, "s", &cstr);
printf("%s\n", cstr);
q回模块对象o中的attr_name 属性或函数Q相当于Python中表辑ּ语句Qo.attr_name。例Q?/p>
/* to call mymod.transform(mymod.message) */8. PyObject* Py_BuildValue( char *format, ...)
pfunc = PyObject_GetAttrString(pmod, "transform");
构徏一个参数列表,把Ccd转换为Python对象QPython可以使用Ccd数据Q例Q?/p>
cstr="this is hjs''s test, to uppercase";9. PyEval_CallObject(PyObject* pfunc, PyObject* pargs)
pargs = Py_BuildValue("(s)", cstr);
此函数有两个参数Q都指向Python对象指针Qpfunc是要调用的Python 函数Q通常可用PyObject_GetAttrString()获得Qpargs是函数的参数列表Q通常可用Py_BuildValue()构徏。例Q?/p>
pstr = PyEval_CallObject(pfunc, pargs);10. void Py_Finalize( )
PyArg_Parse(pstr, "s", &cstr);
printf("%s\n", cstr);
关闭Python解释器,释放解释器所占用的资源。例Q?/p>
Py_Finalize();
Python2.4环境没有提供调试版本的Python24d.libQ所以上q示例在release模式下编译。编译完成后Q把可行文g和附2l出的mymod.py文g攑֜一P再点d可运行。ؓ了简化编E,? l出了simplepy.h。这P调用mymod.transform变成如下形式Q?/p>
//#include”simplepy.h?br />CSimplepy py;
py.ImportModule("mymod");
std::string str=py.CallObject("transform",
"this is hjs''s test, to uppercase");
printf("%s\n", str.c_str());
接下来,我们来用C++为Python~写扩展模块(动态链接库)Qƈ在PythonE序中调用C++开发的扩展功能函数。生成一个取名ؓpyUtil的Win32 DLL工程Q除了pyUtil.cpp文g以外Q从工程中移除所有其它文Ӟq填入如下的代码Q?
// pyUtil.cpp在Python代码中调用这个动态链接库Q?
#ifdef PYUTIL_EXPORTS
#define PYUTIL_API __declspec(dllexport)
#else
#define PYUTIL_API __declspec(dllimport)
#endif
#include<windows.h>
#include<string>
#include<Python.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
?)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
std::string Recognise_Img(const std::string url)
{
//q回l果
return "从dll中返回的数据... : " +url;
}
static PyObject* Recognise(PyObject *self, PyObject *args)
{
const char *url;
std::string sts;
if (!PyArg_ParseTuple(args, "s", &url))
return NULL;
sts = Recognise_Img(url);
return Py_BuildValue("s", sts.c_str() );
}
static PyMethodDef AllMyMethods[] = {
{"Recognise", Recognise, METH_VARARGS},//暴露lPython的函?br /> {NULL, NULL} /* Sentinel */
};
extern "C" PYUTIL_API void initpyUtil()
{
PyObject *m, *d;
m = Py_InitModule("pyUtil", AllMyMethods); //初始化本模块Qƈ暴露函数
d = PyModule_GetDict(m);
}
import pyUtil用C++为Python写扩展时Q如果您愿意使用Boost.Python库的话,开发过E会变得更开心JQ要~写一个与上述pyUtil同样功能的动? 链接库,只需把文件内Ҏ换ؓ下面的代码。当Ӟ~译需要boost_python.lib支持Q运行需要boost_python.dll支持?
result = pyUtil.Recognise("input url of specific data")
print "the result is: "+ result
#include<string>所有示例都在Microsoft Windows XP Professional + Microsoft Visual Studio .NET 2003 + Python2.4环境下测试通过Q本文所用的Boost库ؓ1.33版本?
#include <boost/python.hpp>
using namespace boost::python;
#pragma comment(lib, "boost_python.lib")
std::string strtmp;
char const* Recognise(const char* url)
{
strtmp ="从dll中返回的数据... : ";
strtmp+=url;
return strtmp.c_str();
}
BOOST_PYTHON_MODULE(pyUtil)
{
def("Recognise", Recognise);
}
? text.txt
this is test text in text.txt.
? mymod.py
import string
message = ''original string''
message =message+message
msg_error=""
try:
text_file = open("text.txt", "r")
whole_thing = text_file.read()
print whole_thing
text_file.close()
except IOError, (errno, strerror):
print "I/O error(%s): %s" % (errno, strerror)
def transform(input):
#input = string.replace(input, ''life'', ''Python'')
return string.upper(input)
def change_msg(nul):
global message #如果没有此行Qmessage是函数里头的局部变?br /> message=''string changed''
return message
def r_file(nul):
return whole_thing
def get_msg(nul):
return message
? simplepy.h
#ifndef _SIMPLEPY_H_
#define _SIMPLEPY_H_
// simplepy.h v1.0
// Purpose: facilities for Embedded Python.
// by hujinshan @2005q???:13:02
#include
using std::string;
#include
//--------------------------------------------------------------------
// Purpose: ease the job to embed Python into C++ applications
// by hujinshan @2005q???:13:18
//--------------------------------------------------------------------
class CSimplepy // : private noncopyable
{
public:
///constructor
CSimplepy()
{
Py_Initialize();
pstr=NULL, pmod=NULL, pdict=NULL;
pfunc=NULL, pargs=NULL;
}
///destructor
virtual ~CSimplepy()
{
Py_Finalize();
}
///import the user module
bool ImportModule(const char* mod_name)
{
try{
pmod = PyImport_ImportModule(const_cast(mod_name));
if(pmod==NULL)
return false;
pdict = PyModule_GetDict(pmod);
}
catch(...)
{
return false;
}
if(pmod!=NULL && pdict!=NULL)
return true;
else
return false;
}
///Executes the Python source code from command in the __main__ module.
///If __main__ does not already exist, it is created.
///Returns 0 on success or -1 if an exception was raised.
///If there was an error, there is no way to get the exception information.
int Run_SimpleString(const char* str)
{
return PyRun_SimpleString(const_cast(str) );
}
///PyRun_String("message", Py_eval_input, pdict, pdict);
///Execute Python source code from str in the context specified by the dictionaries globals.
///The parameter start specifies the start token that should be used to parse the source code.
///Returns the result of executing the code as a Python object, or NULL if an exception was raised.
string Run_String(const char* str)
{
char *cstr;
pstr = PyRun_String(str, Py_eval_input, pdict, pdict);
if(pstr==NULL)
throw ("when Run_String, there is an exception was raised by Python environment.");
PyArg_Parse(pstr, "s", &cstr);
return string(cstr);
}
///support olny one parameter for python function, I think it''s just enough.
string CallObject(const char* func_name, const char* parameter)
{
pfunc=NULL;
pfunc = PyObject_GetAttrString(pmod, const_cast(func_name));
if(pfunc==NULL)
throw (string("do not found in Python module for: ")
+func_name).c_str();
char* cstr;
pargs = Py_BuildValue("(s)", const_cast(parameter));
pstr = PyEval_CallObject(pfunc, pargs);
if(pstr==NULL)
throw ("when PyEval_CallObject, there is an exception was raised by Python environment");
PyArg_Parse(pstr, "s", &cstr);
return string(cstr);
}
//PyObject *args;
//args = Py_BuildValue("(si)", label, count); /* make arg-list */
//pres = PyEval_CallObject(Handler, args);
protected:
PyObject *pstr, *pmod, *pdict;
PyObject *pfunc, *pargs;
};
#endif // _SIMPLEPY_H_
// end of file
原文地址Q?a >http://teddyma.cnblogs.com/archive/2005/08/31/226688.html
Version:
Link: http://aspectsharp.sourceforge.net/
Status: beta
Dependency: antlr, Castle.DynamicProxy
Description:
Aspect# is an AOP (Aspect Oriented Programming) framework for the CLI (.Net and Mono). It relies on DynamicProxy and offers a built-in language to declare and configure aspects, and is compliant to AopAlliance. It became part of the Castle Project in June 2005.
- Custom mini configuration language, not xml.
- Mix/Intercept classes and methods through dicnamic proxy approach.
Restrictions:
- Classes to be created dynamic proxy for shouldn’t be sealed and only virtual methods can be intercepted.
- Using intercepted classes is not completely transaparent to users that users should explicit create the dynamically proxied class through the AspectEngine.
- No static weaving support.
Version: 0.7
Status: beta
Link: http://sourceforge.net/projects/aspectdng
Dependency: mono.petoolkit, rail
Description:
AspectDNG is a .NET aspect weaver, that's to say a tool that can "transplant" code into an existing assembly. This transplant is made after the standard .NET compilation, which means that both aspect and the so called "base" code (the one the transplant will be operated on) can be developped in any programming language that is compatible with .NET CLS. Another way to say that: AspectDNG works on assemblies (EXE or DLL) that may have been created out of C#, VB.NET, Eiffel.NET, Mananged C++...
- Xml, Xpath based configuration file format.
- IL level static Weaving.
- Custom xml based disassembled language ILML which can be used to convert assemblies to and be modified/combined and then converted to assemblies.
Restrictions:
- Static weaving only.
- Not very stable.
Version:
Link: http://www.cs.virginia.edu/~eos
Status: beta
Dependency: none
Description:
Eos is an aspect-oriented extension for C# on Microsoft] .NET Framework? Eos aims to improve upon the current aspect-oriented language model in three dimensions. First, it generalizes aspect instantiation & advice weaving model to eliminate the need for the work-arounds that are unavoidable today when aspects are used to express certain crosscutting concerns. Second it generalizes the join point model. Third it aims to eliminate the distinction between class and aspect constructs in favor of a single conceptual building block that combines the expressive capabilities of current classes and aspects, significantly improving conceptual integrity and uniformity in language design. The language is very similar to AspectJ except for constructs which are not implemented in Eos and constructs which AspectJ does not provides.
- AspectJ like extended C# langauage and custom compiler.
Restrictions:
- Static weaving only.
- Not very stable.
Version: 0.7
Link: http://theagiledeveloper.com/category/15.aspx
Status: beta
Dependency: none
Description:
Encase is an aspect oriented programming framework for the .NET Platform written in C#. Encase is unique in that it provides aspects to be applied during runtime in managed code rather then being configuration file based that other AOP frameworks rely upon. The advantage of applying aspects in this way is that it promotes productivity to developers new and/or unfamiliar with AOP.
Restrictions:
- Encase cannot mixin multiple classes that implement a shared interface? For instance, if class A implements Ialphabet, and class B implements Ialphabet, classes A and B can not both be mixed in as an aspect.
- Encase can only provide interception and aspect weaving to virtual (overriable) methods and properties.
- Encase is unable to apply aspects to sealed (NotInheritable) classes.
- Like Aspect#, but more unstable.
Version:
Link: http://gael.fraiteur.net/postsharp.aspx
Status: alpha
Dependency: none
Description:
PostSharp is a free and open-source post-compiler for the .NET Framework. PostSharp is an extensible platform that makes it easy to develop and execute static program analysis and program transformation plug-ins.
- Developped under .Net Framework 2.0 beta
- There is a very good third pary collection library ?“Xipho.Collections?for .Net 2.0 in the source code
Restrictions:
- Not say to be a really aop framework yet.
Version:
Link: http://www.dcl.hpi.uni-potsdam
Status: beta
Dependency: none
Description:
The LOOM .NET project aims to investigate and promote the usage of AOP in the context of the Microsoft .NET framework. We have been developing two AOP tools (so called weavers) that all implement different approaches to weaving: A runtime weaver crating weaved objects on the fly and a static weaver.
Main
- Support under .Net Framework 2.0 beta
- Include both dynamic proxy based dynamic interception and il level rail like static weaving support.
Restrictions:
-
Not very stable.
7. Others
LibcurlZ个免费开源的Q客Lurl传输库,支持FTPQ?/span>FTPSQ?/span>TFTPQ?/span>HTTPQ?/span>HTTPSQ?/span>GOPHERQ?/span>TELNETQ?/span>DICTQ?/span>FILE?/span>LDAPQ跨q_Q支?/span>WindowsQ?/span>UnixQ?/span>Linux{,U程安全Q支?/span>Ipv6。ƈ且易于用?/span>
?/span>http://curl.haxx.se/libcurl/ 下蝲一个稳定的版本Q注意选择OS?/span>
下蝲下来的是源码包,需要编译?/span>
解压zip文gQ进?/span>curl-7.14.0\lib目录Q我下蝲的是7.14.0Q?/span>
~译Debug版本。新Z个批处理bat文gQ如buildDebug.batQ内容如下:
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
set CFG=debug-dll-ssl-dll-zlib-dll
set OPENSSL_PATH=E:\SSL\openssl-0.9.7e
set ZLIB_PATH=E:\zip\zlib123
nmake -f Makefile.vc6
其输出:libcurld_imp.lib, libcurld.dll
~译Release版本。新Z个批处理文gBuildRelease.batQ内容如下:
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
set CFG=release-dll-ssl-dll-zlib-dll
set OPENSSL_PATH=E:\SSL\openssl-0.9.7e
set ZLIB_PATH=E:\zip\zlib123
nmake -f Makefile.vc6
其输出:libcurl_imp.lib, libcurl.dll
上面~译的是libcurl?/span> dllQ?/span>OpenSSL Dll版本?/span>Zlib Dll版本。如果没有,可以?/span>www.openssl.org或?/span>http://www.zlib.net/下蝲?/span>
如果需要编译其他版本,可查?/span>Makefile.vc6Q设定相应的CFG 参数卛_?/span>
商业软g使用libcurlӞ只需要包含其copywrite声明卛_?/span>
不支?/span>SOCKS4?/span>
SOCKS5实现有缺PD必须讄用户和密码?/span>
q接 proxy q程不能讄时?/span>posted on 2005-11-29 17:03 Michael 阅读(1072) 评论(2) ~辑 收藏
1、GTK+ (Gtkmm)
GTK+最初是GIMP的专用开发库Q后来发展ؓLinux下开发图形界面的应用E序的主开发工具之一。GTK+2.0是自pYӞq且是GNU工程的一部分。GTK+2.0的许可协议是LGPL?/p>
GTK+使用C语言开发,但是其设计者用面向对象技术?在GNOMEq_上提供了C++(gtkmm)、Perl、Ruby、Java和Python(PyGTK)l定Q其他的l定有Ada?D?Haskell、PHP和所有的.NET~程语言?/p>
与其他很多部件工L不同QGTK+q不ZXt。这一决策优劣互见Q优ҎGTK+可以应用于其他系l,其灵zL也很强Q而缺点就是它无法利用以传l方法ؓX11定制的X资源数据库?/p>
Glade是一个界面设计工P但是它也包含了一U描qGUI界面的XML语言Q它和libglade一起工作就可以直接使用GTK和GNOME控g?/p>
2、Qt
Qt是Trolltech公司的一个品?
Qt是一个多q_的C++囑Ş用户界面应用E序框架。它提供l应用程序开发者徏立艺术的图形用L面所需的所用功能。Qt是完全面向对象的很容易扩展,q且 允许真正地组件编E?自从1996q早些时候,Qtq入商业领域Q它已经成ؓ全世界范围内数千U成功的应用 E序的基。Qt也是行的Linux桌面环境KDE 的基QKDE是所有主要的Linux发行版的一个标准组件?
Qt支持下述q_Q?MS/Windows - 95?8、NT 4.0、ME、和2000
Unix/X11 - Linux、Sun Solaris、HP-UX、Compaq Tru64 UNIX、IBM AIX、SGI IRIX和其它很多X11q_
Macintosh - Mac OS X
Embedded - 有~冲(framebuffer)支持的Linuxq_?3、wxWidgets
开源YӞLGPLQ,针对C++、Python以及Perl的跨q_工具集?/p>
详细介绍Q参?a >l述 wxWindows
wxWidget作ؓ一个C++ GUI Library?992发展到现在,已经在全球范围内产生了极大的影响力,利用q个cdq行GUI开发的软g更是不计其数?/p>wxWidgets原名wxWindowsQ是由Julian Smart?992q还在英国爱丁堡大学人工应用研究所开始的一个项目。Julian Smart现在是Anthemion软g公司的技术ȝ?/p>
单地_wxWidgets提供了用于可在多q_上开发GUI应用E序的一整套单易学易用的API。wxWidgets支持的多q_包括
Windows 3.1/95/98/NT/2000/XP、带有Motif
1.2版本以上的Unix、带有GTK+的Unix/Linux/*BSD、Mac{等。开发者只需要用自己使用的系l^台的~译器编译源E序Qƈ链接?br /> 相应的库文gQ生成的E序代码卛_有该q_的外观和界面。在q些GUI之上QwxWidgetsq提供了在线帮助、网l编E、流处理、多U常用图形格式支
持、数据库支持、HTML察看和打华ͼ{等各种强大的功能?/p>wxWidgets支持的Windows上的多种行~译器包括:
Visual C++ 1.5, 4.0, 5.0, 6.0
Borland C++ 4.5, 5.0
Borland C++ Builder 1.0, 3.0
Watcom C++ 10.6 (Win32)
Cygwin
MinGW32
Metrowerks CodeWarrior 44、Fox
What is FOX?
![]()
FOX is a C++ based Toolkit for developing Graphical User Interfaces easily and effectively. It offers a wide, and growing, collection of Controls, and provides state of the art facilities such as drag and drop, selection, as well as OpenGL widgets for 3D graphical manipulation. FOX also implements icons, images, and user-convenience features such as status line help, and tooltips. Tooltips may even be used for 3D objects!
Considerable importance has been placed on making FOX one of the fastest toolkits around, and to minimize memory use:- FOX uses a number of techniques to speed up drawing and spatial layout of the GUI. Memory is conserved by allowing programmers to create and destroy GUI elements on the fly.
Even though FOX offers a large collection of Controls already, FOX leverages C++ to allow programmers to easily build additional Controls and GUI elements, simply by taking existing controls, and creating a derived class which simply adds or redefines the desired behavior.
One of the prime design goals of FOX is the ease of programming; thus, most controls can be created using a single line of C++ code; most parameters have sensible default values, so that they may be omitted, and layout managers ensure that designers of GUI's do not have to worry about precise alignments.
Another nice feature of FOX which significantly reduces the number of lines of code which have to be written is FOX's ability to have widgets connect to each other, and passing certain commands between them; for example, a menu entry Hide Toolbar can be directly connected to the Toolbar, and cause it to hide.
Finally, FOX makes it easy to maintain the state of the GUI in an application by having the GUI elements automatically updating themselves by interrogating the application's state. This feature eliminates the large amount of effort that may go into sensitizing, graying out, checking/unchecking etc. depending on the application state.
FOX is Platform Independence! ![]()
The list of platforms is growing! Currently, we have FOX running on a large number of operating systems, ranging from Linux, FreeBSD, SGI IRIX, HP-UX, IBM AIX, SUN Solaris, DEC/Compaq Tru64 UNIX, to MS-Window operating systems like Windows 9x, Windows NT, Windows ME and Windows 2000. Since most of the FOX implementation is completely oblivious to the underlying platform (in many cases it is not even including header files), applications work virtually identically on all these platforms.
For example, here is the FOX textedit sample application running under Windows NT. And here is the same application running on a Silicon GraphicsOctane system.
个h比较喜欢GtkmmQ代码比较干净Q只有GUIQ但在Windows下的效果g没有原生的Window控g?/p>
Features
- Use inheritance to derive custom widgets.
- Type-safe signal handlers, in standard C++.
- Polymorphism.
- Use of Standard C++ Library, including strings, containers, and iterators.
- Full internationalisation with UTF8.
- Complete C++ memory management
- Object composition
- Automatic deallocation of dynamically allocated widgets.
- Full use of C++ namespaces.
- No macros.
- Cross-platform: Linux (gcc), FreeBSD (gcc), NetBSD (gcc), Solaris (gcc, Forte), Win32 (gcc, MSVC++ .Net 2003), MacOS X (gcc), others
- Free software and free of cost for both Open Source and proprietary development.
- Discussed, designed and implemented in public.