Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /*
7 :
8 : A package of routines shared by the XUL content code.
9 :
10 : */
11 :
12 : #ifndef nsXULContentUtils_h__
13 : #define nsXULContentUtils_h__
14 :
15 : #include "nsISupports.h"
16 :
17 : class nsIAtom;
18 : class nsIContent;
19 : class nsIDocument;
20 : class nsIRDFNode;
21 : class nsIRDFResource;
22 : class nsIRDFLiteral;
23 : class nsIRDFService;
24 : class nsICollation;
25 :
26 : // errors to pass to LogTemplateError
27 : #define ERROR_TEMPLATE_INVALID_QUERYPROCESSOR \
28 : "querytype attribute doesn't specify a valid query processor"
29 : #define ERROR_TEMPLATE_INVALID_QUERYSET \
30 : "unexpected <queryset> element"
31 : #define ERROR_TEMPLATE_NO_MEMBERVAR \
32 : "no member variable found. Action body should have an element with uri attribute"
33 : #define ERROR_TEMPLATE_WHERE_NO_SUBJECT \
34 : "<where> element is missing a subject attribute"
35 : #define ERROR_TEMPLATE_WHERE_NO_RELATION \
36 : "<where> element is missing a rel attribute"
37 : #define ERROR_TEMPLATE_WHERE_NO_VALUE \
38 : "<where> element is missing a value attribute"
39 : #define ERROR_TEMPLATE_WHERE_NO_VAR \
40 : "<where> element must have at least one variable as a subject or value"
41 : #define ERROR_TEMPLATE_BINDING_BAD_SUBJECT \
42 : "<binding> requires a variable for its subject attribute"
43 : #define ERROR_TEMPLATE_BINDING_BAD_PREDICATE \
44 : "<binding> element is missing a predicate attribute"
45 : #define ERROR_TEMPLATE_BINDING_BAD_OBJECT \
46 : "<binding> requires a variable for its object attribute"
47 : #define ERROR_TEMPLATE_CONTENT_NOT_FIRST \
48 : "expected <content> to be first"
49 : #define ERROR_TEMPLATE_MEMBER_NOCONTAINERVAR \
50 : "<member> requires a variable for its container attribute"
51 : #define ERROR_TEMPLATE_MEMBER_NOCHILDVAR \
52 : "<member> requires a variable for its child attribute"
53 : #define ERROR_TEMPLATE_TRIPLE_NO_VAR \
54 : "<triple> should have at least one variable as a subject or object"
55 : #define ERROR_TEMPLATE_TRIPLE_BAD_SUBJECT \
56 : "<triple> requires a variable for its subject attribute"
57 : #define ERROR_TEMPLATE_TRIPLE_BAD_PREDICATE \
58 : "<triple> should have a non-variable value as a predicate"
59 : #define ERROR_TEMPLATE_TRIPLE_BAD_OBJECT \
60 : "<triple> requires a variable for its object attribute"
61 : #define ERROR_TEMPLATE_MEMBER_UNBOUND \
62 : "neither container or child variables of <member> has a value"
63 : #define ERROR_TEMPLATE_TRIPLE_UNBOUND \
64 : "neither subject or object variables of <triple> has a value"
65 : #define ERROR_TEMPLATE_BAD_XPATH \
66 : "XPath expression in query could not be parsed"
67 : #define ERROR_TEMPLATE_BAD_ASSIGN_XPATH \
68 : "XPath expression in <assign> could not be parsed"
69 : #define ERROR_TEMPLATE_BAD_BINDING_XPATH \
70 : "XPath expression in <binding> could not be parsed"
71 : #define ERROR_TEMPLATE_STORAGE_BAD_URI \
72 : "only profile: or file URI are allowed"
73 : #define ERROR_TEMPLATE_STORAGE_CANNOT_OPEN_DATABASE \
74 : "cannot open given database"
75 : #define ERROR_TEMPLATE_STORAGE_BAD_QUERY \
76 : "syntax error in the SQL query"
77 : #define ERROR_TEMPLATE_STORAGE_UNKNOWN_QUERY_PARAMETER \
78 : "the given named parameter is unknown in the SQL query"
79 : #define ERROR_TEMPLATE_STORAGE_WRONG_TYPE_QUERY_PARAMETER \
80 : "the type of a query parameter is wrong"
81 : #define ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND \
82 : "a query parameter cannot be bound to the SQL query"
83 :
84 : class nsXULContentUtils
85 : {
86 : protected:
87 : static nsIRDFService* gRDF;
88 : static nsICollation *gCollation;
89 :
90 : static bool gDisableXULCache;
91 :
92 : static int
93 : DisableXULCacheChangedCallback(const char* aPrefName, void* aClosure);
94 :
95 : public:
96 : static nsresult
97 : Init();
98 :
99 : static nsresult
100 : Finish();
101 :
102 : static nsresult
103 : FindChildByTag(nsIContent *aElement,
104 : int32_t aNameSpaceID,
105 : nsIAtom* aTag,
106 : nsIContent **aResult);
107 :
108 : static nsresult
109 : FindChildByResource(nsIContent* aElement,
110 : nsIRDFResource* aResource,
111 : nsIContent** aResult);
112 :
113 : static nsresult
114 : GetTextForNode(nsIRDFNode* aNode, nsAString& aResult);
115 :
116 : static nsresult
117 : GetResource(int32_t aNameSpaceID, nsIAtom* aAttribute, nsIRDFResource** aResult);
118 :
119 : static nsresult
120 : GetResource(int32_t aNameSpaceID, const nsAString& aAttribute, nsIRDFResource** aResult);
121 :
122 : static nsresult
123 : SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement);
124 :
125 : /**
126 : * Log a message to the error console
127 : */
128 : static void
129 : LogTemplateError(const char* aMsg);
130 :
131 : static nsIRDFService*
132 0 : RDFService()
133 : {
134 0 : return gRDF;
135 : }
136 :
137 : static nsICollation*
138 : GetCollation();
139 :
140 : #define XUL_RESOURCE(ident, uri) static nsIRDFResource* ident
141 : #define XUL_LITERAL(ident, val) static nsIRDFLiteral* ident
142 : #include "nsXULResourceList.h"
143 : #undef XUL_RESOURCE
144 : #undef XUL_LITERAL
145 : };
146 :
147 : #endif // nsXULContentUtils_h__
|