Array of StringArrays (sqlite)

int xDb::getData (Array <StringArray> &row)
	int rc=0;
	int x;

	while ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
		StringArray c;

		for (x=0; x<sqlite3_column_count (stmt); x++)
			String k((const char *)sqlite3_column_text (stmt, x));
			c.add (k);

		row.add (c); // the problem

	return (rc);

if i comment out the row.add © part, it works, but when i try to access the row array of stringarrays i get a dbgheap.c error. i create an instance of xDb object in another Preview component, and call it like so (more or less)

db = new xDb(dbFile);
db->query (T("SELECT DISTINCT team_id FROM cfdb_machine"));
Array <StringArray> k;
int res;

res = db->getData (k);

why the error, i tried to mimic passing the arguments of getData from the juce source and examples, but what am i getting wrong ?


afaik, you should only use Array for basic types. If you want to hold lots of more complex objects, you should use OwnedArray.

OwnedArray <StringArray> k;
	int res;
	res = db->getData (k);

	for (int x=0; x<k.size(); x++)
		StringArray *p = k[x];

		log (p[0]);

this works, i can’t access the StringArray *p data, it’s a ponter and the p[0] conversion does not work:

C:\atm\devel\hwinv\dbPreview.cpp(34) : error C2664: 'writeToLog' : cannot convert parameter 1 from 'class juce::StringArray' to 'const class juce::String &'
        Reason: cannot convert from 'class juce::StringArray' to 'const class juce::String'
        No constructor could take the source type, or constructor overload resolution was ambiguous

should i carete a copy from the “p” pointer, if so how ?


you can just use (*p)[0]