WvStreams
Main Page
Modules
Classes
Files
File List
File Members
uniconf
unisubtreegen.cc
1
/*
2
* Worldvisions Weaver Software:
3
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4
*
5
* A UniConfGen for returning only a particular subtree of a given generator.
6
*/
7
#include "unisubtreegen.h"
8
#include "wvbuf.h"
9
#include "
wvtclstring.h
"
10
#include "wvmoniker.h"
11
#include "wvlinkerhack.h"
12
13
WV_LINK(
UniSubtreeGen
);
14
15
16
static
IUniConfGen
*creator(
WvStringParm
s,
IObject
*_obj)
17
{
18
WvConstInPlaceBuf
buf(s, s.len());
19
WvString
one(
wvtcl_getword
(buf)), two(
wvtcl_getword
(buf));
20
21
if
(!one) one =
""
;
22
if
(!two) two =
""
;
23
24
return
new
UniSubtreeGen
(wvcreate<IUniConfGen>(one), two);
25
}
26
27
static
WvMoniker<IUniConfGen>
subtreereg(
"subtree"
, creator);
28
29
30
UniSubtreeGen::UniSubtreeGen(
IUniConfGen
*gen,
const
UniConfKey
&_subkey)
31
:
UniFilterGen
(gen), subkey(_subkey)
32
{
33
// nothing special
34
}
35
36
37
bool
UniSubtreeGen::keymap
(
const
UniConfKey
&unmapped_key,
UniConfKey
&mapped_key)
38
{
39
if
(unmapped_key.
isempty
())
40
mapped_key = subkey;
41
else
42
mapped_key =
UniConfKey
(subkey, unmapped_key);
43
return
true
;
44
}
45
46
bool
UniSubtreeGen::reversekeymap
(
const
UniConfKey
&mapped_key,
UniConfKey
&unmapped_key)
47
{
48
UniConfKey
_unmapped_key;
49
bool
result = subkey.
suborsame
(mapped_key, _unmapped_key);
50
if
(result)
51
unmapped_key = _unmapped_key;
52
return
result;
53
}
Generated on Thu Oct 31 2013 23:17:04 for WvStreams by
1.8.4