>Hi,
>
>On Tue, 2006-04-04 at 11:54 +0200, Antonio B. wrote:
>> Hi,
>>=20
>> I wants to change an element in a MField by string.
>> There is getValueByStr (std::string &str, UInt32 index), instead
>> I need of something as pushValueByStr (std::string &str, UInt32 index).
>>=20
>> Really I have:
>>=20
>> UInt32 pos =3D 4;
>> std::string str =3D ".......";
>> MFFieldContainerPtr mfptr =3D (MFFieldContainerPtr *) field;
>>=20
>> How can I change the value of 4=C2=B0 element of mfptr with str value??=
>?
>> The simplest solution is ...
>Question what is inside the string an id to retrieve an existing
>field container or the complete container description ?
>If it is the complete description technically you would have to pass the
>string to the corresponding loader. We don't have a different way to
>recreate containers from strings right now. You can try to create an
>OSGLoader, wrap your string into a string stream, pass it to scanStream
>and get the result. A small warning as the loader is implemented right
>now your string has to start with the correct header #OSG V1.0 and
>adhere to the osg ascii syntax. And I never actually tried this.
>If it is an id it depends on what the id looks like. If it is the
>field container id convert it to int (e.g
>val =3D TypeTraits<UInt32>::getFromString("...")), retrieve the container
>from the FieldContainerFactory and put it into the mfield (e.g
>(*mfpr)[val] =3D ptr). But be careful not to confuse the refcounting
>and the parent linking (if it applies).
>regards,
> gerrit
Thanks Gerrit but this not is that I wants.
I have a method in my MFEditor class named changeValByStr()
void changeValByStr(Field *mf, std::string strVal, UInt32 pos)
{
//In this method I want to change the value of mf[pos] with the
value //represented by strVal string. mf is MField<DataTypeT>
}
Of course, 'strVal' is a string representation of a DataTypeT of 'mf',
For example:
if 'mf' is MField<Color3f> then strVal="0 0.4567 0";
if 'mf' is MField<Matrix> then strVal="1 0 0 0 4 5 6.657 7 8 9
....";
... and so on;
My MFEditor class is only for MField<BaseType> (MFUInt8, ...., MFVect3i,...,
MFPnt4f, ..., MFMatrix, MFColor3f...) and not for MFFieldContainerPtr.
The only method to modify a MField by string is:
((MFFieldContainerPtr *)mf)->pushValueByStr(strVal.c_str());
But this append a new element. Instead I want to change the 'pos' element of
mf with strVal value.
How can I do?
Thanks
Antonio.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users