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::stringstre am m_szValue;
....
void
CFusionTag::Set Value( char *szValue )
{
m_szValue << szValue;
MessageBox::Sho w( m_szValue.str() .c_str() );
} /* ::SetValue */
void
CFusionTag::Set Value( unsigned int uiValue )
{
m_szValue << uiValue;
}
void
CFusionTag::Set Value( int iValue )
{
m_szValue << iValue;
}
void
CFusionTag::Set Value( float fValue )
{
m_szValue << fValue;
}
void
CFusionTag::Set Value( double dValue )
{
m_szValue << dValue;
}
void
CFusionTag::Set Value( 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::Get Value( char *szValue )
{
MessageBox::Sho w( "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::stringstre am m_szValue;
....
void
CFusionTag::Set Value( char *szValue )
{
m_szValue << szValue;
MessageBox::Sho w( m_szValue.str() .c_str() );
} /* ::SetValue */
void
CFusionTag::Set Value( unsigned int uiValue )
{
m_szValue << uiValue;
}
void
CFusionTag::Set Value( int iValue )
{
m_szValue << iValue;
}
void
CFusionTag::Set Value( float fValue )
{
m_szValue << fValue;
}
void
CFusionTag::Set Value( double dValue )
{
m_szValue << dValue;
}
void
CFusionTag::Set Value( 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::Get Value( char *szValue )
{
MessageBox::Sho w( "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
Comment