Boost logo

Boost :

From: Daniel Spangenberg (dsp_at_[hidden])
Date: 2003-09-02 03:01:53


Hello Boosters,

maybe I am blind as a bat, but I was looking for a possibility to check
a given
regular expression for its general validity.

To get rid of my problem to define "validity" I delegate its definition
to "everything
which would lead to the throw of boost::bad_expression" of all
reg_expression<charT,..> c'tors and assignments which take a textual
regular expression
as argument. (Maybe this defintion is incomplete, but we can work on
that).

Also I see the existence of boost::regbase::use_except and
boost::regbase::failbit
I don't see how to use them in a way to enable/disable exceptions in
regular
expressions, dispite probably the activation of the general
BOOST_NO_EXCEPTIONS
(Shame on me!).

Question: It seems, that boost::regbase::use_except is always active,
because it
is or'ed to the flags arguments in every(?) c'tor or assignment of
reg_expression.
Is that true?

If that is true: Why does the flag regbase::use_except (officially)
exist?

Lets assume, that throwing boost::bad_expression is a general policy (I
can live with that),
it would be **very** nice to have at least one (probably static) member
function,
which takes a textual regular expression and an optional bunch of
regbase flags as arguments and
returns a bool, which simply returns true in case of a valid expression,
otherwise false. What
do you think of that?

Of course I could write my own wrapper, which internally uses a
try/catch(boost::bad_expression)
block, but that is not a very nice programming style I think, according
to the general
guideline: "If you **can** handle a problem locally, do should do that".

Thank you for your help,

Daniel Spangenberg

P.S.: Please forgive me, if I obviously overlooked some already present
feature of regex!


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk