Boost logo

Boost :

From: Alexander Belyakov (al_at_[hidden])
Date: 2006-04-27 03:47:41


May be it will be interesting to compare another approach to the proposed
Property Tree Library. I was highly pleased to see this library but here I
focused at differences which could offer more flexible and scalable solution
at some aspects of registry behavior. Of course, this flexibility has some
cost and functionality of libraries not overlapped fully. But the registry
functionality is the most interesting part for me.

class path;

class basic_registry_proxy
{
public:
    ...
    template<class T> virtual bool get(const path, T&) const = 0;
    template<class T> virtual bool set(const path, T&) = 0;
    ...
}

//basic_registry_proxy - represents the whole regestry tree.
//Not any key but whole tree.
//path - identify actual key at basic_registry_proxy.

class simple_registry : public basic_registry_proxy; // uses win API
class win_registry : public basic_registry_proxy; // uses win API
class thread_safe_registry : public basic_registry_proxy; // uses
Boost.Thread
class dispersed_registry : public basic_registry_proxy; // stores data at
multiple files

class basic_parser
{
public:
    virtual load(basic_registry_proxy*, const char* PathatAtProxy = 0) const
= 0;
    virtual save(basic_registry_proxy*, const char* PathatAtProxy = 0) const
= 0;
}

class win_registry_parser : public basic_parser;
class XML_registry_parser : public basic_parser;

usage example:
// copy windows registry to simple_registry (1)
win_registry_parser wregparser("HKEY_LOCAL_MACHINE/SOFTWARE/");
simple_registry sregistry;
wregparser.load(&sregistry);

// convert windows registry to simple_registry (2)
 win_registry wregistry;
simple_registry sregistry;
copy(&wregistry, path("/"), &sregistry, path(/));

Assume that at windows registry we have such structure:
somekey1 defaulttext1 REG_SZ
    somekey2
        somekey3 defaulttext2 REG_SZ
        somevalue1 somedata REG_SZ
        somevalue2 1234 REG_DWORD

Lets choose prefix "#" for subsidiary attribute information. So we could get
new representation of registry.

somekey1 defaulttext1
{
    #role key {}
    #type REG_SZ {}
    somekey2
    {
         somekey3 defaulttext2
        {
            #role key{}
            #type REG_SZ {}
        }
        somevalue1 somedata
        {
            #role value {}
            #type REG_SZ {}
        }
        somevalue2 1234
        {
            #role value{}
            #type REG_DWORD {}
        }
    }
}
At this case the new registry syntaxes is richer than windows registry one.

Regards,
Alexander Belyakov


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