Proc param - variable structure - possible?

Just starting out? Need help? Post your questions and find answers here.
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Proc param - variable structure - possible?

Post by SparrowhawkMMU »

Hi,

I have a situation where I want to pass a structure into a procedure as a parameter (the structure is converted into a JSON member and added to a JSON object). The procedure is in another module, but I suspect that this is irrelevant?

However, at runtime, the structure to be passed may vary from call to call (e.g. some have sub structures, some don't, etc)

For example, one call might pass a FeedParams structure, another may pass a LicenseeParams structure, yet another would pass an AuthParams structure, and so on.

Does SpiderBasic support passing a parameter of an indeterminate type? If so, could somebody kindly post an example of how this might be done.

I know I can pass a known structure by pointer, but not how to make it more generic.

A workaround I am considering is having in-between procs in a resolution module, one proc for each procedure type.
So instead of calling JSONRPC::SetParams(*params) I would have something like AppJSON::SetCreateFeedParams(*params,FeedParams) which would convert the structure into JSON and pass that to JSONRPC::SetParams(param.s)

i.e. an app-specific structure to JSON resolution layer. This would keep my JSONRPC module generic whilst also keeping the JSON handling out of my business logic modules.

But if the initial enquiry does have a solution, that would be a cleaner approach.

Thanks for any help.

Thanks

PS - I hope that the above makes sense!

Edit: fixed a typo