C++ Portable Types Library (PTypes) Version 1.7

Top: Introduction

Basic features

PTypes features:

  • Threads and synchronization objects along with message queues solve the vital problem of diversity of the threading API's on different platforms.

  • IP socket classes and utilities provide complete IP-based framework for both client-side and server-side programming. Combined with PTypes multithreading, these classes can be used for designing complex non-visual applications, such like network daemons or web robots.

  • Dynamic strings, variants, character sets, date/time type and various kinds of dynamic and associative arrays: Delphi programmers will find them very similar to the ones in their favorite language. The collection of these basic data types may be useful, among other things, for building compilers and interpreters for higher-level languages.

  • Streaming interfaces provide buffered I/O with simple and powerful text parsing methods. A strictly defined syntax for the given text format or a formal language can be represented by calls to PTypes token extraction methods. The unified streaming interface is applicable to files, named pipes and network sockets.

  • Special thread class with enhanced functionality called unit. Units have their own main() and input/output 'plugs'; they can be connected to each other within one application to form pipes, like processes in the Unix shell.

  • Finally, everything above is portable: all platform-dependent details are hidden inside.

Naming and writing style

PTypes is yet another 'custom' class library among tens and hundreds of others. Using custom nonstandard libraries is not encouraged in general. However, all libraries, including the standard ones, do not descend from Heavens, they all are made by human programmers. Therefore, every library has its own advantages and disadvantages (and bugs), application domain, as well as a naming style. We designed this library in the hope that PTypes with its conciseness and intuitiveness could find its own 'target audience'.

First, some of the fundamental classes in the library (string, variant, character set and lists) declare their manipulation functions outside the class, i.e. as friend functions, to create an illusion of working with built-in data types.

Second, PTypes uses old-fashioned all-lowercase naming style. This style can peacefully coexist with any other writing style: you can combine PTypes' style with your favorite one in your application. Other naming styles do not appear to be so 'friendly'.

These features, along with a naming style (a string type is called string, thread is thread, etc) significantly improve readability (hence reliability) of sources that use the library. Take a look at these 4 examples and compare them:

// traditional all-lowercase style, PTypes uses this
int add(objlist& list, unknown* obj);

// modern C++ style
int ObjList::addObject(Unknown* object);

// Borland style
int TObjectList::AddObject(TObject* Object);

// Microsoft/Hungarian
BOOL CPTypesObjectList::AddObject(
    CObject* Object, DWORD dwFlags,
    LPDWORD lpdwResult, LPVOID lpReserved,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes);

Versions and availability

Version 1.7 of PTypes is the seventh public release. The third number in the version indicates insignificant improvements or bug fixes. You might want to take a look at the Changes page if you are familiar with one of the previous versions.

The latest source code and both on-line and out-of-line documentation can be found at one of the following locations:

You can receive announcements about new releases through one of the following services:

Subscribe to the project at Freshmeat.Net
Monitor the project at SourceForge.Net

The development version of PTypes is available at SourceForge.Net's CVS server. If you are willing to join the development of PTypes, please become a user and then contact me to get full access to the CVS repository.

Bugs and known problems

The list of problems encountered in the latest version along with their solutions, if available, can be found at PTypes project management page (at

PTypes project management page


We would like to thank:

Pierre-Frederic Caillaud <> - for valuable suggestions on optimizing the dynamic string routines.
Ralph Siemsen <> - for helping with the memory corruption problem on Linux.
An anonymous contributor (through - for the datetime bug report.


PTypes is open and free, which also means it is open to your comments and suggestions. Please, submit bug reports and feature requests through PTypes project management page at There is a public discussion forum for general questions.

The author would be grateful if you let him know that you use the library in your project. The author's email address is:

Hovik Melikyan <>

See also: Compiling and Porting, Changes

PTypes home