Debian Codegraph @

style/ELObjPropVal.h

raw
1 // Copyright (c) 1999 Matthias Clasen
2 // See the file copying.txt for copying permission.
3
4 #ifndef ELObjPropVal_INCLUDED
5 #define ELObjPropVal_INCLUDED 1
6
7 #include "Node.h"
8 #include "ELObj.h"
9
10 #ifdef DSSSL_NAMESPACE
11 namespace DSSSL_NAMESPACE {
12 #endif
13
14 class ELObjPropertyValue : public PropertyValue {
15 public:
16 ELObjPropertyValue(Interpreter &interp, bool rcs) : interp_(&interp), rcs_(rcs), obj(0) { }
17 void set(const NodePtr &nd) {
18 obj = new (*interp_) NodePtrNodeListObj(nd);
19 }
20 void set(const NodeListPtr &nl) {
21 obj = new (*interp_) NodeListPtrNodeListObj(nl);
22 }
23 void set(const NamedNodeListPtr &nnl) {
24 obj = new (*interp_) NamedNodeListPtrNodeListObj(nnl);
25 }
26 void set(bool b) {
27 if (b)
28 obj = interp_->makeTrue();
29 else
30 obj = interp_->makeFalse();
31 }
32 void set(GroveChar c) {
33 obj = interp_->makeChar(c);
34 }
35 void set(GroveString s) {
36 obj = new (*interp_) StringObj(s.data(), s.size());
37 }
38 void set(ComponentName::Id id) {
39 const char *s = rcs_ ? ComponentName::rcsName(id) : ComponentName::sdqlName(id);
40 obj = interp_->makeSymbol(interp_->makeStringC(s));
41 }
42 void set(const GroveStringListPtr &gsListPtr) {
43 PairObj *head = new (*interp_) PairObj(0, 0);
44 ELObjDynamicRoot protect(*interp_, head);
45 PairObj *tail = head;
46 ConstGroveStringListIter sgListIter(*gsListPtr);
47 while (!sgListIter.done()) {
48 StringObj *gs = new (*interp_) StringObj(sgListIter.cur().data(), sgListIter.cur().size());
49 tail->setCdr(gs);
50 PairObj *tem = new (*interp_) PairObj(gs, 0);
51 tail->setCdr(tem);
52 tail = tem;
53 sgListIter.next();
54 }
55 tail->setCdr(interp_->makeNil());
56 obj = head->cdr();
57 }
58 void set(const ComponentName::Id *names) {
59 PairObj *head = new (*interp_) PairObj(0, 0);
60 ELObjDynamicRoot protect(*interp_, head);
61 PairObj *tail = head;
62 for (int i = 0; names[i] != ComponentName::noId; i++) {
63 const char *s = (rcs_
64 ? ComponentName::rcsName(names[i])
65 : ComponentName::sdqlName(names[i]));
66 SymbolObj *sym = interp_->makeSymbol(interp_->makeStringC(s));
67 tail->setCdr(sym); // in case we ever gc symbols
68 PairObj *tem = new (*interp_) PairObj(sym, 0);
69 tail->setCdr(tem);
70 tail = tem;
71 }
72 tail->setCdr(interp_->makeNil());
73 obj = head->cdr();
74 }
75 void set(long l) {
76 obj = interp_->makeInteger(l);
77 }
78 ELObj *obj;
79 private:
80 Interpreter *interp_;
81 bool rcs_;
82 };
83
84 #ifdef DSSSL_NAMESPACE
85 }
86 #endif
87
88 #endif /* not ELObjPropVal_INCLUDED */
89
90