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
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/
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
15 * The Original Code is Mozilla Communicator client code.
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.
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsINameSpaceManager_h___
39 #define nsINameSpaceManager_h___
41 #include "nsISupports.h"
42 #include "nsStringGlue.h"
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 static const PRInt32 kNameSpaceID_None
= 0;
51 #define kNameSpaceID_XMLNS 1 // not really a namespace, but it needs to play the game
52 #define kNameSpaceID_XML 2
53 #define kNameSpaceID_XHTML 3
54 #define kNameSpaceID_XLink 4
55 #define kNameSpaceID_XSLT 5
56 #define kNameSpaceID_XBL 6
57 #define kNameSpaceID_MathML 7
58 #define kNameSpaceID_RDF 8
59 #define kNameSpaceID_XUL 9
60 #define kNameSpaceID_SVG 10
61 #define kNameSpaceID_XMLEvents 11
62 #define kNameSpaceID_LastBuiltin 11 // last 'built-in' namespace
64 #define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1"
66 #define NS_INAMESPACEMANAGER_IID \
67 { 0xd74e83e6, 0xf932, 0x4289, \
68 { 0xac, 0x95, 0x9e, 0x10, 0x24, 0x30, 0x88, 0xd6 } }
71 * The Name Space Manager tracks the associtation between a NameSpace
72 * URI and the PRInt32 runtime id. Mappings between NameSpaces and
73 * NameSpace prefixes are managed by nsINameSpaces.
75 * All NameSpace URIs are stored in a global table so that IDs are
76 * consistent accross the app. NameSpace IDs are only consistent at runtime
77 * ie: they are not guaranteed to be consistent accross app sessions.
79 * The nsINameSpaceManager needs to have a live reference for as long as
80 * the NameSpace IDs are needed.
84 class nsINameSpaceManager
: public nsISupports
87 NS_DECLARE_STATIC_IID_ACCESSOR(NS_INAMESPACEMANAGER_IID
)
89 virtual nsresult
RegisterNameSpace(const nsAString
& aURI
,
90 PRInt32
& aNameSpaceID
) = 0;
92 virtual nsresult
GetNameSpaceURI(PRInt32 aNameSpaceID
, nsAString
& aURI
) = 0;
93 virtual PRInt32
GetNameSpaceID(const nsAString
& aURI
) = 0;
95 virtual PRBool
HasElementCreator(PRInt32 aNameSpaceID
) = 0;
98 NS_DEFINE_STATIC_IID_ACCESSOR(nsINameSpaceManager
, NS_INAMESPACEMANAGER_IID
)
100 nsresult
NS_GetNameSpaceManager(nsINameSpaceManager
** aInstancePtrResult
);
102 void NS_NameSpaceManagerShutdown();
104 #endif // nsINameSpaceManager_h___