WvStreams
uniautogen.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * A UniConf moniker that uses an .ini file to look up which moniker it
6 * should use to find the config file/subtree for a particular application.
7 */
8#include "uniconfroot.h"
9#include "unisubtreegen.h"
10#include "wvlinkerhack.h"
11
12WV_LINK(UniAutoGen);
13
14
21WvString uniautogen_moniker("default:ini:/etc/uniconf.conf");
22
23/*
24 * A moniker for finding the "right" config generator for a particular
25 * application, given the application name.
26 *
27 * For example, for moniker "auto:org/gnome/Nautilus", we would:
28 *
29 * - open /etc/uniconf.conf.
30 * - look for org/gnome/Nautilus in there.
31 * - if it exists, use that value as the config moniker, and return.
32 * - else, look for org/gnome
33 * - if it exists, go get that config moniker, take the subtree
34 * "Nautilus" from there, and return.
35 * - else, look for org
36 * - if it exists, go get that config moniker, take the subtree
37 * "gnome/Nautilus" from there, and return.
38 * - else, look for /
39 * - if it exists, go get that config moniker, take the subtree
40 * "org/gnome/Nautilus" from there, and return.
41 * - else, return a null: generator.
42 */
43static IUniConfGen *creator(WvStringParm s, IObject *_obj)
44{
46 wvcreate<IUniConfGen>(uniautogen_moniker, _obj), true);
47 const UniConfKey appname(s);
48
49 for (int i = appname.numsegments(); i >= 0; i--)
50 {
51 UniConfKey prefix(appname.first(i)), suffix(appname.removefirst(i));
52
53 if (!!cfg.xget(prefix))
54 {
55 return new UniSubtreeGen(wvcreate<IUniConfGen>(cfg.xget(prefix)),
56 suffix);
57 }
58 }
59
60 return wvcreate<IUniConfGen>("null:");
61}
62
63
64static WvMoniker<IUniConfGen> autoreg("auto", creator);
The basic interface which is included by all other XPLC interfaces and objects.
Definition: IObject.h:65
An abstract data container that backs a UniConf tree.
Definition: uniconfgen.h:40
A default implementation of IUniConfGen, providing various handy features that save trouble when impl...
Definition: uniconfgen.h:200
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition: uniconfkey.h:39
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
Definition: uniconfroot.h:74
A UniConfGen that returns only a particular subtree of a given generator.
Definition: unisubtreegen.h:19
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition: wvstring.h:94
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
Definition: wvmoniker.h:62
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:330