Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » How to pass vector/array of structs to witz?
How to pass vector/array of structs to witz? [message #40322] Fri, 19 July 2013 10:39 Go to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
I have a data set like this:

struct DataSet{
	int data1;
	double data2;
	String data3;
};


Array<DataSet> set;


and I would like to pass it to witz script and be able to access it in the same way I can access data from sql querry (using row number and column name). Can you tell me how to do it?

Re: How to pass vector/array of structs to witz? [message #40327 is a reply to message #40322] Fri, 19 July 2013 15:58 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Zbych,

If I'm not mistaken, the closest you can get is to use ValueArray instead of Array and ValueMap instead of DataSet. ValueArray/Map are not really ergonomic to handle, so the best approach is probably to convert your data before passing them to witz.

Something like
struct DataSet{
	int data1;
	double data2;
	String data3;
};

Array<DataSet> set;

ValueArray v;
for (int i=0; i<set.GetCount(); ++i) {
    ValueMap vm;
    vm["data1"]=set[i].data1;
    vm["data2"]=set[i].data2;
    vm["data3"]=set[i].data3;
    v.Add(vm);
}

http("set", v);

Note: I'd not try to compile or run the code Wink

It is quite verbose, so some helper functions might be a good idea...

Best regards,
Honza
Re: How to pass vector/array of structs to witz? [message #40340 is a reply to message #40327] Mon, 22 July 2013 12:55 Go to previous message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Thank you. ValueArray + ValueMap did the trick.
Previous Topic: Probable bug in Skylark and sessions
Next Topic: Skylark - serving CSS style sheets
Goto Forum:
  


Current Time: Fri Mar 29 01:13:02 CET 2024

Total time taken to generate the page: 0.01686 seconds