extra: import at 3.0.1 beta 1
[mozilla-extra.git] / extensions / webservices / soap / src / nsSOAPUtils.h
blobb95071fde2e5340b7d3b018d4577620ba1fe6550
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
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * 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 nsSOAPUtils_h__
39 #define nsSOAPUtils_h__
41 #include "nsString.h"
42 #include "nsIDOMElement.h"
43 #include "nsISOAPEncoding.h"
45 class nsSOAPUtils {
46 private:
47 nsSOAPUtils() {} // Never create a member of this class
48 ~nsSOAPUtils() {}
49 public:
50 static void GetSpecificChildElement(nsISOAPEncoding * aEncoding,
51 nsIDOMElement * aParent,
52 const nsAString & aNamespace,
53 const nsAString & aType,
54 nsIDOMElement * *aElement);
55 static void GetSpecificSiblingElement(nsISOAPEncoding * aEncoding,
56 nsIDOMElement * aSibling,
57 const nsAString & aNamespace,
58 const nsAString & aType,
59 nsIDOMElement * *aElement);
60 static void GetFirstChildElement(nsIDOMElement * aParent,
61 nsIDOMElement ** aElement);
62 static void GetNextSiblingElement(nsIDOMElement * aStart,
63 nsIDOMElement ** aElement);
64 static nsresult GetElementTextContent(nsIDOMElement * aElement,
65 nsAString & aText);
66 static PRBool HasChildElements(nsIDOMElement * aElement);
68 static void GetNextSibling(nsIDOMNode * aSibling, nsIDOMNode ** aNext);
69 static nsresult MakeNamespacePrefix(nsISOAPEncoding *aEncoding,
70 nsIDOMElement * aElement,
71 const nsAString & aURI,
72 nsAString & aPrefix);
73 static nsresult GetNamespaceURI(nsISOAPEncoding *aEncoding,
74 nsIDOMElement * aElement,
75 const nsAString & aQName,
76 nsAString & aURI);
77 static nsresult GetLocalName(const nsAString & aQName,
78 nsAString & aLocalName);
80 static PRBool GetAttribute(nsISOAPEncoding *aEncoding,
81 nsIDOMElement * aElement,
82 const nsAString & aNamespaceURI,
83 const nsAString & aLocalName,
84 nsAString & aValue);
87 struct nsSOAPStrings
89 const nsLiteralString kSOAPEnvURI1;
90 const nsLiteralString kSOAPEnvURI2;
91 const nsLiteralString *kSOAPEnvURI[2];
93 const nsLiteralString kSOAPEncURI;
94 const nsLiteralString kSOAPEncURI11;
95 const nsLiteralString kXSIURI;
96 const nsLiteralString kXSURI;
97 const nsLiteralString kXSIURI1999;
98 const nsLiteralString kXSURI1999;
99 const nsLiteralString kSOAPEnvPrefix;
100 const nsLiteralString kSOAPEncPrefix;
101 const nsLiteralString kXSIPrefix;
102 const nsLiteralString kXSITypeAttribute;
103 const nsLiteralString kXSPrefix;
104 const nsLiteralString kEncodingStyleAttribute;
105 const nsLiteralString kActorAttribute;
106 const nsLiteralString kMustUnderstandAttribute;
107 const nsLiteralString kEnvelopeTagName;
108 const nsLiteralString kHeaderTagName;
109 const nsLiteralString kBodyTagName;
110 const nsLiteralString kFaultTagName;
111 const nsLiteralString kFaultCodeTagName;
112 const nsLiteralString kFaultStringTagName;
113 const nsLiteralString kFaultActorTagName;
114 const nsLiteralString kFaultDetailTagName;
115 const nsLiteralString kEncodingSeparator;
116 const nsLiteralString kQualifiedSeparator;
117 const nsLiteralString kXMLNamespaceNamespaceURI;
118 const nsLiteralString kXMLNamespaceURI;
119 const nsLiteralString kXMLNamespacePrefix;
120 const nsLiteralString kXMLPrefix;
121 const nsLiteralString kTrue;
122 const nsLiteralString kTrueA;
123 const nsLiteralString kFalse;
124 const nsLiteralString kFalseA;
125 const nsLiteralString kVerifySourceHeader;
126 const nsLiteralString kVerifySourceURI;
127 const nsLiteralString kVerifySourceNamespaceURI;
129 // used by nsDefaultSOAPEncoder.cpp
130 const nsLiteralString kEmpty;
131 const nsLiteralString kNull;
132 const nsLiteralString kNil;
133 const nsLiteralString kSOAPArrayTypeAttribute;
134 const nsLiteralString kSOAPArrayOffsetAttribute;
135 const nsLiteralString kSOAPArrayPositionAttribute;
136 const nsLiteralString kAnyTypeSchemaType;
137 const nsLiteralString kAnySimpleTypeSchemaType;
138 const nsLiteralString kArraySOAPType;
139 const nsLiteralString kStructSOAPType;
140 const nsLiteralString kStringSchemaType;
141 const nsLiteralString kBooleanSchemaType;
142 const nsLiteralString kFloatSchemaType;
143 const nsLiteralString kDoubleSchemaType;
144 const nsLiteralString kLongSchemaType;
145 const nsLiteralString kIntSchemaType;
146 const nsLiteralString kShortSchemaType;
147 const nsLiteralString kByteSchemaType;
148 const nsLiteralString kUnsignedLongSchemaType;
149 const nsLiteralString kUnsignedIntSchemaType;
150 const nsLiteralString kUnsignedShortSchemaType;
151 const nsLiteralString kUnsignedByteSchemaType;
152 const nsLiteralString kNormalizedStringSchemaType;
153 const nsLiteralString kTokenSchemaType;
154 const nsLiteralString kNameSchemaType;
155 const nsLiteralString kNCNameSchemaType;
156 const nsLiteralString kDecimalSchemaType;
157 const nsLiteralString kIntegerSchemaType;
158 const nsLiteralString kNonPositiveIntegerSchemaType;
159 const nsLiteralString kNonNegativeIntegerSchemaType;
160 const nsLiteralString kBase64BinarySchemaType;
162 nsSOAPStrings();
165 extern nsSOAPStrings *gSOAPStrings;
167 // Used to support null strings.
169 inline PRBool AStringIsNull(const nsAString & aString)
171 return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
174 inline void SetAStringToNull(nsAString & aString)
176 aString.SetIsVoid(PR_TRUE);
179 #define NS_SOAP_ENSURE_ARG_STRING(arg) \
180 NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
182 inline void
183 SOAPEncodingKey(const nsAString & aURI, const nsAString & aType,
184 nsAString & result)
186 result = aURI + gSOAPStrings->kEncodingSeparator + aType;
189 #endif