Jason Jesso wrote:
>Hi:
>
>Can XERCES-C be used in C programs, even though it is C++? Are there C
>bindings?
>
>Thanks
>Jason
>
>
>
>---------------------------------------------------------------------
>In case of troubles, e-mail: [EMAIL PROTECTED]
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
Jason,
A common way to use C++ libraries is to supply your own C API
functions in a C++ file, declare them extern "C" in the .cpp file,
and provide a .h file which lists only the function prototypes in C
form (no C++ includes).
example:
==============
myapi.cpp:
#include <some_cpp_files>
#include "myapi.h"
static SomeClass *myobj;
extern "C" int myapi_init(void)
{
myobj= new SomeClass();
}
extern "C" int another_wrapper_function(void)
{
myobj->someMethod();
}
==============
in myapi.h:
#ifndef MYAPI_H_
#define MYAPI_H_
#ifdef __cplusplus
extern "C" {
#endif
int myapi_init(void);
int another_wrapper_function(void);
#ifdef __cplusplus
}
#endif
#endif /* MYAPI_H_*/
==============
...and in the .c files that use this:
#include <myapi.h>
int somefunction(void)
{
myapi_init(); //get an object
another_wrapper_function();
...etc...
}
Basically, what you would do in the API file, is declare a
static global object pointer, and all of the other wrapper
functions call methods on that object.
Hope this helps.
Bob
---------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]