Boost logo

Boost :

Subject: Re: [boost] Phoenix V3 and Logging library help.
From: Fernando Pelliccioni (fpelliccioni_at_[hidden])
Date: 2011-07-05 17:11:37


On Tue, Jul 5, 2011 at 5:40 AM, Thomas Heller <thom.heller_at_[hidden]>wrote:

> On Mon, Jul 4, 2011 at 9:36 PM, Fernando Pelliccioni
> <fpelliccioni_at_[hidden]> wrote:
> > Thanks Thomas !!
> >
> > On Mon, Jul 4, 2011 at 3:23 PM, Thomas Heller <
> thom.heller_at_[hidden]>wrote:
> >
> >> Hi Fernando,
> >>
> >> On Mon, Jul 4, 2011 at 5:04 PM, Fernando Pelliccioni
> >> <fpelliccioni_at_[hidden]> wrote:
> >> > Hi Thomas, all,
> >> >
> >> > I am researching about logging libraries.
> >> > I had to discard Boost.Log ( from Andrey) because this library does
> not
> >> > support GCC 3.4.
> >> > I've seen other libraries, but none convinced me.
> >>
> >> Yes, Phoenix seems to work with 3.4.6. For a complete overview see:
> >> http://www.boost.org/development/tests/trunk/developer/phoenix.html
> >>
> >> If you run into any problems, let me know.
> >>
> >
> > Sure, thanks!
> >
> >
> >>
> >> > I'm thinking of writing a simple logging library, and to avoid the use
> of
> >> > macros, I decided to do something like this:
> >>
> >> Will comment inline.
> >>
> >> > namespace prototype1
> >> > {
> >> > namespace levels
> >> > {
> >>
> >> This won't work. If you want to get the stuff working you sketched
> further
> >> down,
> >> All these placeholders would need to be of a different type.
> >> I would suggest to define different expression nodes for every level,
> >> please have a look at the docs:
> >>
> >>
> http://beta.boost.org/doc/libs/1_47_0_beta1/libs/phoenix/doc/html/phoenix/examples/adding_an_expression.html
> <snip>
> >> Yes, please work through the docs, the link i posted you above should
> >> get you started.
> >>
> >>
> > I have read quickly the link you sent me, I have some doubts.
> > I will read all the documentation from Phoenix to see if I will clarify
> > concepts.
>
> Please do. If you encounter any problems I will be glad to help. Also
> patches to the documentation
> are welcome at any time ;)
>
> Thank you Thomas.

I was thinking, and came to the conclusion that it is easier to play with
Proto in this case...

See...

//-------------------------------------------------------------------------------------------------------------------------------------------
#include <string>
#include <iostream>
#include <boost/proto/proto.hpp>

namespace proto = boost::proto;

struct trace_ {};
proto::terminal<trace_>::type trace = {};

template <typename Expr>
void run_predicate_internal( Expr const & expr)
{
    using proto::value;
    using proto::child_c;

    run_predicate_internal( child_c<0>(expr) );

    std::cout << value( child_c<1>(expr) );
}

void run_predicate_internal(proto::terminal<trace_>::type const &)
{
    std::cout << "[TRACE] - ";
}

template <typename Expr>
void run_predicate( Expr const & expr)
{
    run_predicate_internal(expr);
    std::cout << std::endl;
}

int main()
{
    //proto::display_expr( trace << "hello " << "world " << 99.85 );
    run_predicate( trace << "hello " << "world " << 99.85 );

    return 0;
}

//-------------------------------------------------------------------------------------------------------------------------------------------

Do you think that I can get some benefit using PhoenixV3 instead of Proto?


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