Home » Community » Newbie corner » Passing an ArrayCtrl / SqlArray to a function template
Passing an ArrayCtrl / SqlArray to a function template [message #49276] |
Mon, 15 January 2018 11:51  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi folks,
I am creating a small util library for my applications (actually, is a namespace).
I use frequently a method to export the content of a SqlArray /ArrayCtrl to a csv file, so it makes sense to include it in this library.
template <class T>
void ExportCSV(T o)
{
String filename = "";
FileSel fs;
CoInitialize(NULL);
PWSTR path = 0;
SHGetKnownFolderPath(FOLDERID_Desktop, KF_FLAG_SIMPLE_IDLIST, NULL, &path);
std::wstring s = path;
std::string homedir( s.begin(), s.end() );
homedir.append("\\");
CoTaskMemFree(path);
fs.Type("CSV", "*.csv");
fs.PreSelect(homedir);
if(!fs.ExecuteSaveAs()) return;
filename = fs;
SaveFile(filename, "Prova");
FileOut out(filename);
if(!out) {
Exclamation(t_("Failed opening ") + filename);
return;
}
out.Put(o.AsCsv());
}
When I compile I get the following error:
error C2280: 'Upp::ArrayCtrl::ArrayCtrl(Upp::ArrayCtrl &)': attempting to reference a deleted function
I know this is a really generic question, but I am bit lost.
Regards,
Gio
|
|
|
Re: Passing an ArrayCtrl / SqlArray to a function template [message #49281 is a reply to message #49276] |
Mon, 15 January 2018 14:13   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
a Ctrl can't passed by value, use reference instead:
PS: think about using GetDesktopFolder ()
template <class T>
void ExportCSV(T& o)
{
String filename = "";
FileSel fs;
fs.Type("CSV", "*.csv");
fs.PreSelect(GetDesktopFolder ());
if(!fs.ExecuteSaveAs()) return;
filename = fs;
SaveFile(filename, "Prova");
FileOut out(filename);
if(!out) {
Exclamation(t_("Failed opening ") + filename);
return;
}
out.Put(o.AsCsv());
}
regards
omari.
|
|
|
|
|
|
Goto Forum:
Current Time: Sun May 11 15:28:29 CEST 2025
Total time taken to generate the page: 0.02705 seconds
|