1 : /*
2 : * DO NOT EDIT. THIS FILE IS GENERATED FROM /builds/slave/m-beta-lnx-codecoverage/build/xpcom/ds/nsIAtom.idl
3 : */
4 :
5 : #ifndef __gen_nsIAtom_h__
6 : #define __gen_nsIAtom_h__
7 :
8 :
9 : #ifndef __gen_nsISupports_h__
10 : #include "nsISupports.h"
11 : #endif
12 :
13 : /* For IDL files that don't want to include root IDL files. */
14 : #ifndef NS_NO_VTABLE
15 : #define NS_NO_VTABLE
16 : #endif
17 : #include "nsStringGlue.h"
18 : #include "nsCOMPtr.h"
19 : #include "nsStringBuffer.h"
20 :
21 : /* starting interface: nsIAtom */
22 : #define NS_IATOM_IID_STR "1f341018-521a-49de-b806-1bef5c9a00b0"
23 :
24 : #define NS_IATOM_IID \
25 : {0x1f341018, 0x521a, 0x49de, \
26 : { 0xb8, 0x06, 0x1b, 0xef, 0x5c, 0x9a, 0x00, 0xb0 }}
27 :
28 3244520 : class NS_SCRIPTABLE nsIAtom : public nsISupports {
29 : public:
30 :
31 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IATOM_IID)
32 :
33 : /* [binaryname(ScriptableToString)] AString toString (); */
34 : NS_SCRIPTABLE NS_IMETHOD ScriptableToString(nsAString & _retval NS_OUTPARAM) = 0;
35 :
36 : /* [noscript] AUTF8String toUTF8String (); */
37 : NS_IMETHOD ToUTF8String(nsACString & _retval NS_OUTPARAM) = 0;
38 :
39 : /* [binaryname(ScriptableEquals)] boolean equals (in AString aString); */
40 : NS_SCRIPTABLE NS_IMETHOD ScriptableEquals(const nsAString & aString, bool *_retval NS_OUTPARAM) = 0;
41 :
42 : /* [noscript,notxpcom] boolean equalsUTF8 (in AUTF8String aString); */
43 : NS_IMETHOD_(bool) EqualsUTF8(const nsACString & aString) = 0;
44 :
45 : /* [noscript,notxpcom] boolean isStaticAtom (); */
46 : NS_IMETHOD_(bool) IsStaticAtom(void) = 0;
47 :
48 : // note this is NOT virtual so this won't muck with the vtable!
49 42139 : inline bool Equals(const nsAString& aString) {
50 42139 : return aString.Equals(nsDependentString(mString, mLength));
51 : }
52 1961077 : inline const PRUnichar* GetUTF16String() {
53 1961077 : return mString;
54 : }
55 1961005 : inline const PRUint32 GetLength() {
56 1961005 : return mLength;
57 : }
58 3248075 : inline void ToString(nsAString& aBuf) {
59 3248075 : nsStringBuffer::FromData(mString)->ToString(mLength, aBuf);
60 3248075 : }
61 : /**
62 : * A hashcode that is better distributed than the actual atom
63 : * pointer, for use in situations that need a well-distributed
64 : * hashcode.
65 : */
66 0 : inline uint32_t hash() const {
67 0 : return mHash;
68 : }
69 : protected:
70 : PRUint32 mLength;
71 : uint32_t mHash;
72 : PRUnichar* mString;
73 : };
74 :
75 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIAtom, NS_IATOM_IID)
76 :
77 : /* Use this macro when declaring classes that implement this interface. */
78 : #define NS_DECL_NSIATOM \
79 : NS_SCRIPTABLE NS_IMETHOD ScriptableToString(nsAString & _retval NS_OUTPARAM); \
80 : NS_IMETHOD ToUTF8String(nsACString & _retval NS_OUTPARAM); \
81 : NS_SCRIPTABLE NS_IMETHOD ScriptableEquals(const nsAString & aString, bool *_retval NS_OUTPARAM); \
82 : NS_IMETHOD_(bool) EqualsUTF8(const nsACString & aString); \
83 : NS_IMETHOD_(bool) IsStaticAtom(void); \
84 :
85 : /* Use this macro to declare functions that forward the behavior of this interface to another object. */
86 : #define NS_FORWARD_NSIATOM(_to) \
87 : NS_SCRIPTABLE NS_IMETHOD ScriptableToString(nsAString & _retval NS_OUTPARAM) { return _to ScriptableToString(_retval); } \
88 : NS_IMETHOD ToUTF8String(nsACString & _retval NS_OUTPARAM) { return _to ToUTF8String(_retval); } \
89 : NS_SCRIPTABLE NS_IMETHOD ScriptableEquals(const nsAString & aString, bool *_retval NS_OUTPARAM) { return _to ScriptableEquals(aString, _retval); } \
90 : NS_IMETHOD_(bool) EqualsUTF8(const nsACString & aString) { return _to EqualsUTF8(aString); } \
91 : NS_IMETHOD_(bool) IsStaticAtom(void) { return _to IsStaticAtom(); } \
92 :
93 : /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
94 : #define NS_FORWARD_SAFE_NSIATOM(_to) \
95 : NS_SCRIPTABLE NS_IMETHOD ScriptableToString(nsAString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->ScriptableToString(_retval); } \
96 : NS_IMETHOD ToUTF8String(nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->ToUTF8String(_retval); } \
97 : NS_SCRIPTABLE NS_IMETHOD ScriptableEquals(const nsAString & aString, bool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->ScriptableEquals(aString, _retval); } \
98 : NS_IMETHOD_(bool) EqualsUTF8(const nsACString & aString) { return !_to ? NS_ERROR_NULL_POINTER : _to->EqualsUTF8(aString); } \
99 : NS_IMETHOD_(bool) IsStaticAtom(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsStaticAtom(); } \
100 :
101 : #if 0
102 : /* Use the code below as a template for the implementation class for this interface. */
103 :
104 : /* Header file */
105 : class nsAtom : public nsIAtom
106 : {
107 : public:
108 : NS_DECL_ISUPPORTS
109 : NS_DECL_NSIATOM
110 :
111 : nsAtom();
112 :
113 : private:
114 : ~nsAtom();
115 :
116 : protected:
117 : /* additional members */
118 : };
119 :
120 : /* Implementation file */
121 : NS_IMPL_ISUPPORTS1(nsAtom, nsIAtom)
122 :
123 : nsAtom::nsAtom()
124 : {
125 : /* member initializers and constructor code */
126 : }
127 :
128 : nsAtom::~nsAtom()
129 : {
130 : /* destructor code */
131 : }
132 :
133 : /* [binaryname(ScriptableToString)] AString toString (); */
134 : NS_IMETHODIMP nsAtom::ScriptableToString(nsAString & _retval NS_OUTPARAM)
135 : {
136 : return NS_ERROR_NOT_IMPLEMENTED;
137 : }
138 :
139 : /* [noscript] AUTF8String toUTF8String (); */
140 : NS_IMETHODIMP nsAtom::ToUTF8String(nsACString & _retval NS_OUTPARAM)
141 : {
142 : return NS_ERROR_NOT_IMPLEMENTED;
143 : }
144 :
145 : /* [binaryname(ScriptableEquals)] boolean equals (in AString aString); */
146 : NS_IMETHODIMP nsAtom::ScriptableEquals(const nsAString & aString, bool *_retval NS_OUTPARAM)
147 : {
148 : return NS_ERROR_NOT_IMPLEMENTED;
149 : }
150 :
151 : /* [noscript,notxpcom] boolean equalsUTF8 (in AUTF8String aString); */
152 : NS_IMETHODIMP_(bool) nsAtom::EqualsUTF8(const nsACString & aString)
153 : {
154 : return NS_ERROR_NOT_IMPLEMENTED;
155 : }
156 :
157 : /* [noscript,notxpcom] boolean isStaticAtom (); */
158 : NS_IMETHODIMP_(bool) nsAtom::IsStaticAtom()
159 : {
160 : return NS_ERROR_NOT_IMPLEMENTED;
161 : }
162 :
163 : /* End of implementation class template. */
164 : #endif
165 :
166 : /*
167 : * The three forms of NS_NewAtom and do_GetAtom (for use with
168 : * |nsCOMPtr<nsIAtom>|) return the atom for the string given. At any
169 : * given time there will always be one atom representing a given string.
170 : * Atoms are intended to make string comparison cheaper by simplifying
171 : * it to pointer equality. A pointer to the atom that does not own a
172 : * reference is not guaranteed to be valid.
173 : *
174 : * The three forms of NS_NewPermanentAtom and do_GetPermanentAtom return
175 : * the atom for the given string and ensure that the atom is permanent.
176 : * An atom that is permanent will exist (occupy space at a specific
177 : * location in memory) until XPCOM is shut down. The advantage of
178 : * permanent atoms is that they do not need to maintain a reference
179 : * count, which requires locking and hurts performance.
180 : */
181 : /**
182 : * Find an atom that matches the given UTF-8 string.
183 : * The string is assumed to be zero terminated.
184 : */
185 : extern nsIAtom* NS_NewAtom(const char* aUTF8String);
186 69366 : inline already_AddRefed<nsIAtom> do_GetAtom(const char* aUTF8String)
187 69366 : { return NS_NewAtom(aUTF8String); }
188 :
189 : /**
190 : * Find an atom that matches the given UTF-8 string.
191 : */
192 : extern nsIAtom* NS_NewAtom(const nsACString& aUTF8String);
193 76 : inline already_AddRefed<nsIAtom> do_GetAtom(const nsACString& aUTF8String)
194 76 : { return NS_NewAtom(aUTF8String); }
195 : /**
196 : * Find an atom that matches the given UTF-16 string.
197 : * The string is assumed to be zero terminated.
198 : */
199 : extern nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String);
200 31935 : inline already_AddRefed<nsIAtom> do_GetAtom(const PRUnichar* aUTF16String)
201 31935 : { return NS_NewAtom(aUTF16String); }
202 : /**
203 : * Find an atom that matches the given UTF-16 string.
204 : */
205 : extern nsIAtom* NS_NewAtom(const nsAString& aUTF16String);
206 : extern nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String);
207 16930 : inline already_AddRefed<nsIAtom> do_GetAtom(const nsAString& aUTF16String)
208 16930 : { return NS_NewAtom(aUTF16String); }
209 : /**
210 : * Return a count of the total number of atoms currently
211 : * alive in the system.
212 : */
213 : extern nsrefcnt NS_GetNumberOfAtoms(void);
214 : /**
215 : * Return a pointer for a static atom for the string or null if there's
216 : * no static atom for this string.
217 : */
218 : extern nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String);
219 : /**
220 : * Seal the static atom table
221 : */
222 : extern void NS_SealStaticAtomTable();
223 : class nsAtomString : public nsString
224 3225288 : {
225 : public:
226 3225288 : nsAtomString(nsIAtom* aAtom)
227 3225288 : {
228 3225288 : aAtom->ToString(*this);
229 3225288 : }
230 : };
231 : class nsAtomCString : public nsCString
232 29345 : {
233 : public:
234 29345 : nsAtomCString(nsIAtom* aAtom)
235 29345 : {
236 29345 : aAtom->ToUTF8String(*this);
237 29345 : }
238 : };
239 : class nsDependentAtomString : public nsDependentString
240 336956 : {
241 : public:
242 336956 : nsDependentAtomString(nsIAtom* aAtom)
243 336956 : : nsDependentString(aAtom->GetUTF16String(), aAtom->GetLength())
244 : {
245 336956 : }
246 : };
247 :
248 : #endif /* __gen_nsIAtom_h__ */
|