[Insight-developers] ExceptionObject Borland Compile errors

Niels Dekker niels-xtk at xs4all.nl
Thu May 29 12:32:51 EDT 2008


Karthik Krishnan wrote:
> Also line 255 should read
>  ExceptionObject::SetDescription( description );
> instead of
>  ExceptionObject::SetLocation( description );

Oops!  Luis, are you gonna fix it, or do you want me to?

Two small PERF/STYLE thingies:

The SetLocation and SetDescription overloads for std::string could avoid 
having multiple GetExceptionData() calls, as follows:

  void
  ExceptionObject::SetLocation(const std::string& s)
  {
    const ExceptionData * const thisData = this->GetExceptionData();

    m_ExceptionData = ReferenceCountedExceptionData::ConstNew(
      thisData ? thisData->m_File : std::string(),
      thisData ? thisData->m_Line : 0,
      thisData ? thisData->m_Description : std::string(),
      s);
  }

  void
  ExceptionObject::SetDescription(const std::string& s)
  {
    const ExceptionData * const thisData = this->GetExceptionData();

    m_ExceptionData = ReferenceCountedExceptionData::ConstNew(
      thisData ? thisData->m_File : std::string(),
      thisData ? thisData->m_Line : 0,
      s,
      thisData ? thisData->m_Location : std::string());
  }


GetExceptionData() could return an ExceptionData pointer, instead of a 
ReferenceCountedExceptionData pointer (and it could do static_cast for 
PERF reasons, as I wrote before):

  const ExceptionObject::ExceptionData *
  ExceptionObject::GetExceptionData() const
  {
    const ExceptionData * thisData =
      static_cast< const ExceptionData *>(
        this->m_ExceptionData.GetPointer() );
    return thisData;
  }

This looks more elegant to me, because this cast is more limited (from 
ReferenceCounterInterface to its directly derived class).  And because a 
ExceptionData pointer is sufficient anyway, whenever GetExceptionData() 
is called.


What do you think?


Kind regards,

  Niels 



More information about the Insight-developers mailing list