WvStreams
unidefgen.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * UniDefGen is a UniConfGen for retrieving data with defaults
6 *
7 * Usable with the moniker default:
8 */
9
10#ifndef __UNIDEFGEN_H
11#define __UNIDEFGEN_H
12
13#include "unifiltergen.h"
14
15/*
16 * The defaults are stored and accessed by using a * in the keyname. The *
17 * can represent either a segment of the path, or can can be left as a key
18 * in a path so that any search to that path returns a result.
19 *
20 * (note: odd spacing is only to avoid putting * and / directly together)
21 *
22 * For example, you could set /twister/expression/ * /reality =
23 * "/tmp/twister" and then a search for /twister/expression/bob/reality
24 * would return the result.
25 *
26 * There is no limitation on where the * can be placed or the number of *s.
27 * For example: /twister/ * / * / reality / *
28 * would be an acceptable (though somewhat insane) use. This would make it
29 * so a search to /twister/(whatever)/(whatever)/reality/(whatever) would
30 * always return a key.
31 *
32 * If a more absolute path exists, then it will be returned instead of the
33 * defaults. Precedence is given to matches existing closer to the end of
34 * the key.
35 *
36 * If the key is set to '*n', it will return the n'th element from the end of
37 * the absolute path that was passed in. For instance, if
38 * /twister/ * / * / reality is set to *1, then a search for
39 * /twister/expression/bob/reality will return 'bob'. If it is set to *2, the
40 * search will return 'expression'. If it were set to *3 (or *0), the result is
41 * undefined.
42 */
43class UniDefGen : public UniFilterGen
44{
45 UniConfKey finddefault(const UniConfKey &key, char *p, char *q);
46 WvString replacewildcard(const UniConfKey &key,
47 const UniConfKey &defkey, WvStringParm in);
48
49public:
50 UniDefGen(IUniConfGen *gen) : UniFilterGen(gen) { }
51
52 /***** Overridden members *****/
53
54 virtual bool keymap(const UniConfKey &unmapped_key, UniConfKey &mapped_key);
55 virtual void flush_buffers() { }
56 virtual WvString get(const UniConfKey &key);
57 virtual void set(const UniConfKey &key, WvStringParm value);
58};
59
60#endif // __UNIDEFGEN_H
An abstract data container that backs a UniConf tree.
Definition uniconfgen.h:40
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition uniconfkey.h:39
virtual void flush_buffers()
Flushes any commitment/notification buffers .
Definition unidefgen.h:55
virtual bool keymap(const UniConfKey &unmapped_key, UniConfKey &mapped_key)
A mapping function for filters that remap one keyspace onto another.
Definition unidefgen.cc:113
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
Definition unidefgen.cc:131
A UniConfGen that delegates all requests to an inner generator.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330