★ wanayoo — archive 1999 http://ibm.com/java/education/international-unicode/unicodeb.htmlNouvelle recherche | Portail wanayoo

Introduction to IBM Classes for Unicode


Appendix B : Relationship between C++ and C API

The following provides a general description of how the C wrapper API relates to the C++ API. In the following examples C++ code will be italicized, and the corresponding C wrapper code will be bold.

Classes in C++ are wrapped by C structures with the same name.

C++ API: class T_FORMAT_API Calendar {

C API: typedef struct _Calendar Calendar;>

Constants in C++ are wrapped by C constants whose names are made up of:

T_<class containing name_<constant name

C++ API: class T_UTILITY_API Unicode { static const UniChar MIN_VALUE; ....}

C API: CAPI UniChar T_Unicode_MIN_VALUE;>

Enumerations in C++ are wrapped by C enumerations whose names are made up of

_T_<class containing name_<enumeration name

C++ API: enum EDateFields {

C API: enum _T_Calendar_EDateFields {

The default constructor in C++ is wrapped by a C function whose name is made up of

T_<class containing name_new

C++ API: UnicodeString();

C API: CAPI UnicodeString* T_UnicodeString_new();

The copy constructor in C++ is wrapped by a C function whose name is made up of

T_<class containing name_newCopy

C++ API: UnicodeString(const UnicodeString& that);

C API: CAPI UnicodeString* T_UnicodeString_newCopy(const UnicodeString* stringToCopy);

Additional constructors for C++ classes are wrapped by C functions whose names are made up of

T_<class containing name_new<object created from

C++ API: UnicodeString(const char* that); // Must be null-terminated

C API: CAPI UnicodeString* T_UnicodeString_newFromChar(const char* charsToCopy);

The destructor for a C++ class is wrapped by a C function whose name is made up of

T_<class containing name_delete

C++ API: virtual ~Calendar();

C API: CAPI void T_Calendar_delete(Calendar* calendarToDelete);

The operators that are overloaded in a C++ class are wrapped by C functions whose names are made up of

T_<class containing name_<operation name

C++ API: UnicodeString& operator=(const UnicodeString& that);

C API: CAPI void T_UnicodeString_assign(UnicodeString* destinationLocale, const UnicodeString* sourceLocale);

 

C++ API: virtual t_bool operator==(const Calendar& that) const;

C API: CAPI t_bool T_Calendar_equals(const Calendar* calendar, const Calendar* calendarToCompareTo);

Methods in C++ are wrapped by C functions whose names are made up of

T_<class containing name_<method name

C++ API: virtual Calendar* clone() const = 0;

C API: CAPI Calendar* T_Calendar_clone(const Calendar* calendarToClone);

C++ API: Date getTime(ErrorCode& status) const;

C API: CAPI Date T_Calendar_getTime(const Calendar* calendar, ErrorCode* status);

Note that static methods do not depend on any information from the class, so the C wrapper does not need to take the corresponding structure as an argument.

C++ API: static Date getNow();

C API: CAPI Date T_Calendar_getNow();

Additional text is added to the name of the C wrapper when there may be a naming conflict. For instance, T_Calendar_equals is the C wrapper for operator==, so the method equals is wrapped by T_Calendar_timeEquals to indicate that the function compares the time of the objects, as opposed to all of the data stored in the object.

C++ API: t_bool equals(const Calendar& when, ErrorCode& status) const;

C API: CAPI t_bool T_Calendar_timeEquals(const Calendar* calendar, Calendar* calendarToCompareTo, ErrorCode* status);

 





JavaTM is a trademark of Sun Microsystems, Inc.

Microsoft is a registered trademark of Microsoft Corporation.

Other companies, products, and service names may be trademarks or service marks of others.

Copyright    Trademark



IBM HomeOrderEmployment