1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsINameSpaceManager_h___
39 : #define nsINameSpaceManager_h___
40 :
41 : #include "nsISupports.h"
42 : #include "nsStringGlue.h"
43 :
44 : class nsIAtom;
45 : class nsString;
46 :
47 : #define kNameSpaceID_Unknown -1
48 : // 0 is special at C++, so use a static const PRInt32 for
49 : // kNameSpaceID_None to keep if from being cast to pointers
50 : // Note that the XBL cache assumes (and asserts) that it can treat a
51 : // single-byte value higher than kNameSpaceID_LastBuiltin specially.
52 : static const PRInt32 kNameSpaceID_None = 0;
53 : #define kNameSpaceID_XMLNS 1 // not really a namespace, but it needs to play the game
54 : #define kNameSpaceID_XML 2
55 : #define kNameSpaceID_XHTML 3
56 : #define kNameSpaceID_XLink 4
57 : #define kNameSpaceID_XSLT 5
58 : #define kNameSpaceID_XBL 6
59 : #define kNameSpaceID_MathML 7
60 : #define kNameSpaceID_RDF 8
61 : #define kNameSpaceID_XUL 9
62 : #define kNameSpaceID_SVG 10
63 : #define kNameSpaceID_XMLEvents 11
64 : #define kNameSpaceID_LastBuiltin 11 // last 'built-in' namespace
65 :
66 : #define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1"
67 :
68 : #define NS_INAMESPACEMANAGER_IID \
69 : { 0xd74e83e6, 0xf932, 0x4289, \
70 : { 0xac, 0x95, 0x9e, 0x10, 0x24, 0x30, 0x88, 0xd6 } }
71 :
72 : /**
73 : * The Name Space Manager tracks the association between a NameSpace
74 : * URI and the PRInt32 runtime id. Mappings between NameSpaces and
75 : * NameSpace prefixes are managed by nsINameSpaces.
76 : *
77 : * All NameSpace URIs are stored in a global table so that IDs are
78 : * consistent accross the app. NameSpace IDs are only consistent at runtime
79 : * ie: they are not guaranteed to be consistent accross app sessions.
80 : *
81 : * The nsINameSpaceManager needs to have a live reference for as long as
82 : * the NameSpace IDs are needed.
83 : *
84 : */
85 :
86 : class nsINameSpaceManager : public nsISupports
87 1404 : {
88 : public:
89 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_INAMESPACEMANAGER_IID)
90 :
91 : virtual nsresult RegisterNameSpace(const nsAString& aURI,
92 : PRInt32& aNameSpaceID) = 0;
93 :
94 : virtual nsresult GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI) = 0;
95 : virtual PRInt32 GetNameSpaceID(const nsAString& aURI) = 0;
96 :
97 : virtual bool HasElementCreator(PRInt32 aNameSpaceID) = 0;
98 : };
99 :
100 : NS_DEFINE_STATIC_IID_ACCESSOR(nsINameSpaceManager, NS_INAMESPACEMANAGER_IID)
101 :
102 : nsresult NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult);
103 :
104 : void NS_NameSpaceManagerShutdown();
105 :
106 : #endif // nsINameSpaceManager_h___
|