added Info.plist
[TestXSLT.git] / libsablot / src / engine / key.h
1 /* 
2  * The contents of this file are subject to the Mozilla Public
3  * License Version 1.1 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of
5  * the License at http://www.mozilla.org/MPL/
6  * 
7  * Software distributed under the License is distributed on an "AS
8  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9  * implied. See the License for the specific language governing
10  * rights and limitations under the License.
11  * 
12  * The Original Code is the Sablotron XSLT Processor.
13  * 
14  * The Initial Developer of the Original Code is Ginger Alliance Ltd.
15  * Portions created by Ginger Alliance are Copyright (C) 2000-2002
16  * Ginger Alliance Ltd. All Rights Reserved.
17  * 
18  * Contributor(s):
19  * 
20  * Alternatively, the contents of this file may be used under the
21  * terms of the GNU General Public License Version 2 or later (the
22  * "GPL"), in which case the provisions of the GPL are applicable 
23  * instead of those above.  If you wish to allow use of your 
24  * version of this file only under the terms of the GPL and not to
25  * allow others to use your version of this file under the MPL,
26  * indicate your decision by deleting the provisions above and
27  * replace them with the notice and other provisions required by
28  * the GPL.  If you do not delete the provisions above, a recipient
29  * may use your version of this file under either the MPL or the
30  * GPL.
31  */
32
33 #ifndef KeyHIncl
34 #define KeyHIncl
35
36 #include "base.h"
37 #include "context.h"
38 #include "sxpath.h"
39
40 class KList : public CList
41 {
42 public:
43     KList();
44     ~KList();
45     eFlag makeValues(Sit S, Expression& use);
46     eFlag getNodes(Sit S, const Str& keyValue, Context& result) const;
47     virtual int compare(int i, int j, void *data);
48     virtual void swap(int i, int j);    
49     void sort(Sit S);
50     void setSourceDoc(SXP_Document doc_) 
51         {doc = doc_;}
52     SXP_Document getSourceDoc() 
53         {return doc;}
54 private:
55     int findNdx(const Str& keyValue) const;
56     SXP_Document doc;
57 };
58
59 class Key
60 {
61 public:
62     Key(const EQName& ename_, Expression& match_, Expression& use_);
63     eFlag create(Sit S, SXP_Document doc);
64     eFlag getNodes(Sit S, const Str& keyValue, Context& result, SXP_Document doc) const;
65     const EQName& getName();
66     ~Key();
67     void report(Sit S, MsgType type, MsgCode code, 
68         const Str &arg1, const Str &arg2) const;
69     KList* find(SXP_Document doc) const;
70 private:
71     const EQName ename;
72     PList<KList*> subkeys;
73     Expression &match,
74         &use;    
75     void list();        
76 };
77
78 class KeySet: public PList<Key*>
79 {
80 public:
81     KeySet();
82     eFlag addKey(Sit S, const EQName& ename, SXP_Document doc,
83                  Expression& match, Expression& use);
84     eFlag makeKeysForDoc(Sit S, SXP_Document doc);
85     eFlag getNodes(Sit S, const EQName& ename, SXP_Document doc,
86         const Str& value, Context& result);
87     ~KeySet();
88     void report(Sit S, MsgType type, MsgCode code, 
89                 const Str &arg1, const Str &arg2) const;                
90 private:
91     Key* findKey(const EQName& ename);
92 };
93
94 #endif // KeyHIncl