I'm currently trying to build a Perl interface to a homegrown C++
library. My header file contains several C style typedefs for structs
used in the methods of the library's main class. Best as I can
tell, there is no instant way to get Inline to handle them.
Do I need to map each of these structs to it's own Perl class and try
to fiddle with the main object's interface code to handle them, or is
there anyway that I can get Inline to handle them by fiddling with the
typemaps?
My C++ header is attached. I'm new to both Inline and perl's guts so I
apologize if I've missed something obvious.
thanks in advance for any help,
dean.
/*
* Program: dservclient.h
* Language: GNU C++
* Editor settings: Tab spaces at 2
* Max-width at 140 Characters
*
* Header file for dservclient.cc
*
* See dservclient.cc for more specific function documentation.
*
* This is a Thread Safe Library.
*
* =========================================================================
* Date Programmer Changes
* -------------------------------------------------------------------------
*
* 09/07/2001 Daniel Lydiard o Created
*
* 99/99/9999 ... Changed to ...
*
* =========================================================================
*/
#ifndef _H_DSERVCLIENT_
#define _H_DSERVCLIENT_
/* URL encoding */
typedef enum _HTURIEncoding {
URL_XALPHAS = 0x1,
URL_XPALPHAS = 0x2,
URL_PATH = 0x4
} HTURIEncoding;
/* field definition */
typedef struct dserv_fields {
char fieldname[16]; // 15 chars max + null term
char type; // type of value (S or N)
unsigned int max_length; // max length of value (used for
header info)
char *value; // pointer to value of the field
} DSERV_FIELDS;
/* row definition */
typedef struct dserv_row {
unsigned int field_count; // field count
DSERV_FIELDS fields[756*2]; // field entries (Qicware can only
have 756 fields max) * 2 because of joins.
} DSERV_ROW;
/* connection info struct */
typedef struct dserv_connect {
char last_error[1024]; // last query error
char next_key[65]; // next key
#ifdef __GNUC__
int my_socket_fd; // socket fd (-1 when not connected)
#else
SOCKET my_socket_fd; // windows socket
#endif
} DSERV_CONNECT;
/* client class */
class dservclient {
public:
dservclient(); // constructor
~dservclient(); // destructor
/* connection */
int dserv_connect(DSERV_CONNECT &info, char *host, unsigned int port);
int dserv_close (DSERV_CONNECT &info);
/* reading */
int read (DSERV_CONNECT &info, list<DSERV_ROW> &row, char *tablename, char
*start_key, char *end_key,
char *fields, unsigned int limit, char *where_clause = NULL);
/* reading with 2 joined tables */
int join (DSERV_CONNECT &info, list<DSERV_ROW> &row1, char *table1, char
*start_key, char *end_key, char *fields1,
char *table2, char *join_key, char *fields2, unsigned int limit,
char *where_clause = NULL);
/* normal update */
int update(DSERV_CONNECT &info, char *tablename, char *key, list<DSERV_ROW> &row);
/* updating the WBACTU */
int update_WBACTU(DSERV_CONNECT &info, list<DSERV_ROW> &row);
int update_WBACTU(DSERV_CONNECT &info, list<DSERV_ROW> &row, unsigned int timeout);
/* insert */
int insert(DSERV_CONNECT &info, char *tablename, char *key, list<DSERV_ROW> &row);
/* overriding a table */
int table_override(DSERV_CONNECT &info, char *tablename, char *dsk, char *dir,
char *filename);
/* misc functions */
void clear_list (list<DSERV_ROW> &row);
int get_field_index(list<DSERV_ROW> &row, char *fieldname);
void list_init(list<DSERV_ROW> &row);
int list_add(list<DSERV_ROW> &row, char *fieldname, char *value);
private:
/* functions */
#ifdef _MSC_VER
int init_winsock(DSERV_CONNECT &info);
#endif
int sock_writeln(DSERV_CONNECT &info, char *data, unsigned int len);
int sock_readln (DSERV_CONNECT &info, char *data, unsigned int size);
int get_reply (DSERV_CONNECT &info, list<DSERV_ROW> &row);
char *HTEscape (const char *str, HTURIEncoding mask, char *result);
char *strip (char *string);
};
#endif // _H_DSERVCLIENT_