T
TBass
Hi.
I wrote a "tag" class to store values. The user gets to store most any
type he would need. Instead of getting too complicatated, I decided I
would store the value as a stringstream, then overload the SetValue
method.
....
protected:
std::stringstream m_szValue;
....
void
CFusionTag::SetValue( char *szValue )
{
m_szValue << szValue;
MessageBox::Show( m_szValue.str().c_str() );
} /* ::SetValue */
void
CFusionTag::SetValue( unsigned int uiValue )
{
m_szValue << uiValue;
}
void
CFusionTag::SetValue( int iValue )
{
m_szValue << iValue;
}
void
CFusionTag::SetValue( float fValue )
{
m_szValue << fValue;
}
void
CFusionTag::SetValue( double dValue )
{
m_szValue << dValue;
}
void
CFusionTag::SetValue( long lValue )
{
m_szValue << lValue;
}
That works fine (I'm aware of the obvious flaw in this code, but I use
taking advantage of that for debugging purposes). The value gets
stored.
My problem (which is probably obvious to everyone but me) is returning
the value when someone calls the GetValue method.
void
CFusionTag::GetValue( char *szValue )
{
MessageBox::Show( "Sending back a char value!" );
szValue = (char *)m_szValue.str().c_str();
}
The char string returned is always blank. I thought this would be
pretty simple, but STL keeps getting the better of me. Can anyone
point me in the right direction?
Thanks in advance,
T
I wrote a "tag" class to store values. The user gets to store most any
type he would need. Instead of getting too complicatated, I decided I
would store the value as a stringstream, then overload the SetValue
method.
....
protected:
std::stringstream m_szValue;
....
void
CFusionTag::SetValue( char *szValue )
{
m_szValue << szValue;
MessageBox::Show( m_szValue.str().c_str() );
} /* ::SetValue */
void
CFusionTag::SetValue( unsigned int uiValue )
{
m_szValue << uiValue;
}
void
CFusionTag::SetValue( int iValue )
{
m_szValue << iValue;
}
void
CFusionTag::SetValue( float fValue )
{
m_szValue << fValue;
}
void
CFusionTag::SetValue( double dValue )
{
m_szValue << dValue;
}
void
CFusionTag::SetValue( long lValue )
{
m_szValue << lValue;
}
That works fine (I'm aware of the obvious flaw in this code, but I use
taking advantage of that for debugging purposes). The value gets
stored.
My problem (which is probably obvious to everyone but me) is returning
the value when someone calls the GetValue method.
void
CFusionTag::GetValue( char *szValue )
{
MessageBox::Show( "Sending back a char value!" );
szValue = (char *)m_szValue.str().c_str();
}
The char string returned is always blank. I thought this would be
pretty simple, but STL keeps getting the better of me. Can anyone
point me in the right direction?
Thanks in advance,
T