Re: Returning a string in c++ UO as UO Parameter
Posted: 14 April 2022, 18:05
Perhaps you can add all known python versions to the list?
Discussions about use and implementation of the CAPE-OPEN standard
https://forum.colan.org/
Code: Select all
STDMETHOD(get_OptionList)(VARIANT* v)
{
// This function specifies all allowed version numbers.
// Pro-II displays only version numbers, which are allowed by this function.
// set type to string array
v->vt = VT_ARRAY | VT_BSTR;
// specify allowed versions
vector<BSTR> allowed_versions = { SysAllocString(L"x.y.z") };
for(unsigned int major = 0; major <=2; major++)
{
for (unsigned int minor = 0; minor <= 11; minor++)
{
for (unsigned int bugfix = 0; bugfix <= 11; bugfix++)
{
// build version STL string
string version_STLstring = to_string(major) + "." + to_string(minor) + "." + to_string(bugfix);
// convert STL string to BSTR and append to vector
CComBSTR temp(version_STLstring.c_str());
allowed_versions.push_back(temp.Detach());
}
}
}
// write allowed versions to output parameter
v->parray = SafeArrayCreateVector(VT_BSTR, 0, (unsigned int) allowed_versions.size()); // start indexing at 0
long i = 0;
for (vector<BSTR>::iterator it = allowed_versions.begin(); it != allowed_versions.end(); it++, i++ )
{
SafeArrayPutElement(v->parray, &i, *it);
}
return NOERROR;
}
STDMETHOD(get_RestrictedToList)(VARIANT_BOOL * vb)
{
*vb = VARIANT_TRUE;
return NOERROR;
}