Hi Thorsten,

[...]

---%<-----------------------------------------------------------------

#define VALIDATE_AND_THROW(c, m, ifc, arg_num)  if( !(c) ) { \
           OSL_ENSURE(false, m); \
           throw ::com::sun::star::lang::IllegalArgumentException( \
           ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \
           ::rtl::OUString::createFromAscii(",\n"m), \
           ifc, \
           arg_num ); }

#define ENSURE_AND_THROW(c, m, ifc) if( !(c) ) { \
          OSL_ENSURE(false, m); \
          throw ::com::sun::star::uno::RuntimeException( \
          ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \
          ::rtl::OUString::createFromAscii(",\n"m), \
          ifc ); }

#define ENSURE_AND_RETURN(c, m)  if( !(c) ) { \
          OSL_ENSURE(false, m); \
          return false; }

---%<-----------------------------------------------------------------

I am just wondering if the naming is clear enough.

VALIDATE_AND_THROW and ENSURE_AND_THROW are the same, except that the former throws an IllegalArgumentException whereas the latter throws a RuntimException. And both validate and ensure. I think when reading the place where such a macro is used, I wouldn't exactly know what happens. Or, when wanting to use it I wouldn't probably remember which was which.

    // I admit: foo should be an argument here, so you should see that
    VALIDATE_AND_THROW( foo==1, "foo should be 1", this, 2 );
    ENSURE_AND_THROW( foo==1, "foo should be 1", this );

What about (after changing also AND to OR):

    ENSURE_ARG_OR_THROW
    ENSURE_OR_THROW

Just my 2 ct's (1ct for each macro)

-Bjoern

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to