• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNI with C++ structures

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to call a function in C++ that returns a pointer to a structure array, like this

BOOL __stdcall GetPositionBlotter(int* iCount, void* RecArray);

Where RecArray is elements like this

typedef struct _POSITIONREC {
char SymIdent[20];
char SymExchange[15];
char SymSecType[20];
char SymExpiry[30];
char SymRight[30];
char SymCurrency[20];
DWORD Quantity;
double MarketPrice;
double MarketValue;
double AverageCost;
double UnrealizedPNL;
double RealizedPNL;
} POSITIONREC, *LPPOSITIONREC;
;

How do I get that C++ structure back to Java? I suppose I need an array of a class? I guess somehow I need to instantiate those classes in C++ and load the fields in a loop and pass them back as the result.

Can anyone provide simple example code of how I do that please?

John
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very simple but complete working example. Study it thoroughly:

Regards
reply
    Bookmark Topic Watch Topic
  • New Topic