I need help in translating this C++ header into Delphi.
It's a callback function prototype, and some inline functions (I have no clear idea why they are there, since it seems they are not used).
Source .h code:
// This file defines 'myStreamWriter_t' a function pointer type.
// The user of the C API need to specify a callback of above type which
// will be called on xxx_print(...) with the formatted data.
// For C++ API, a default callback is specified which writes data to
// the stream specified in xxx::print
typedef int(*myStreamWriter_t)(const char* p1,
int p2,
void *p3);
The above It's quite easy: it should translate, in Delphi, as follows:
type
myStreamWriter_t = function(const p1:Pchar;
p2:integer;
p3:pointer):integer;
Now, there are other things that I don't know how to translate:
Souce .h code:
#include <ostream>
namespace ns1 {
namespace ns2 {
inline int OstreamWriter(const char *p1, int p2, void *p3);
struct StreamProxyOstream {
static int writeToStream(const char* p1, int p2, void *p3);
// Format, to the specified 'p3' stream, which must be a pointer to a
// 'std::ostream', the specified 'p2' bytes length of the specified 'p1' data.
};
inline
int StreamProxyOstream::writeToStream(const char *p1,
int p2,
void *p3)
{
reinterpret_cast<std::ostream*>(p3)->write(p1, p2);
return 0;
}
inline
int OstreamWriter(const char *p1, int p2, void *p3)
{
return StreamProxyOstream::writeToStream(p1, p2, p3);
}
} // close namespace ns2
} // close namespace ns1
...how to translate in Delphi the above??
Thank you very much!