Boost logo

Boost :

From: Marcin Kalicinski (kalita_at_[hidden])
Date: 2006-04-24 17:01:21


> get an object pointer from the ptree by using
> "namespace.(namespace...).object" as a path, then invoke verb on that
> object. For all its simplicity, this is amazingly useful, too. You can
> build
> a key binding module on top of that:
>
> ctrl+o factory.document.open
> ctrl+n factory.document.new
>
> and so on. You can also add events to your buttons or menus in this way.
> It's not Python, but it may be enough.

This reminds me of another way I used ptree, but because that was several
years ago, the details escaped my memory. Basically, it was used as a simple
"scripting language". The language was mostly used for evaluating conditions
specified in text files. They were read into a property tree, and then a
very simple function evaluated them. Hierarchical structure of the data
turned out to be very well suited for specifying arbitrarily complex
conditions. For example this condition:

if (v1 == v2 && (v3 < v4 || v5 > v6))

was encoded like that in the file:

Condition And
{
    Equals
    {
        Value1 v1
        Value2 v2
    }
    Condition Or
    {
        Less
        {
            Value1 v3
            Value2 v4
        }
        Greater
        {
            Value1 v5
            Value2 v6
        }
    }
}

This is quite an obscure example, but hopefully shows that ptree has
potential uses thay go beyond "configuration reading/writing". This of
course could be done using a full blown scripting language like Python. But
why summon the monster snake when ptree + a function that was slightly more
than 1 screen were enough?

Best regards,
Marcin


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