/* * DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/xpcom/io/nsIBinaryOutputStream.idl */ #ifndef __gen_nsIBinaryOutputStream_h__ #define __gen_nsIBinaryOutputStream_h__ #include "nsIOutputStream.h" #include "nsTArray.h" /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif // %{C++:8-12 #include "mozilla/Try.h" namespace mozilla { template class Span; } // %} /* starting interface: nsIBinaryOutputStream */ #define NS_IBINARYOUTPUTSTREAM_IID_STR "204ee610-8765-11d3-90cf-0040056a906e" #define NS_IBINARYOUTPUTSTREAM_IID \ {0x204ee610, 0x8765, 0x11d3, \ { 0x90, 0xcf, 0x00, 0x40, 0x05, 0x6a, 0x90, 0x6e }} class MOZ_BINDING(binding_to, idl, class, XPIDL_nsIBinaryOutputStream) nsIBinaryOutputStream : public nsIOutputStream { public: NS_INLINE_DECL_STATIC_IID(NS_IBINARYOUTPUTSTREAM_IID) /* Used by ToJSValue to check which scriptable interface is implemented. */ using ScriptableInterfaceType = nsIBinaryOutputStream; /* void setOutputStream (in nsIOutputStream aOutputStream); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_setOutputStream) NS_IMETHOD SetOutputStream(nsIOutputStream *aOutputStream) = 0; /* [must_use] void writeBoolean (in boolean aBoolean); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBoolean) [[nodiscard]] NS_IMETHOD WriteBoolean(bool aBoolean) = 0; /* [must_use] void write8 (in uint8_t aByte); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write8) [[nodiscard]] NS_IMETHOD Write8(uint8_t aByte) = 0; /* [must_use] void write16 (in uint16_t a16); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write16) [[nodiscard]] NS_IMETHOD Write16(uint16_t a16) = 0; /* [must_use] void write32 (in uint32_t a32); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write32) [[nodiscard]] NS_IMETHOD Write32(uint32_t a32) = 0; /* [must_use] void write64 (in uint64_t a64); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write64) [[nodiscard]] NS_IMETHOD Write64(uint64_t a64) = 0; /* [must_use] void writeFloat (in float aFloat); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeFloat) [[nodiscard]] NS_IMETHOD WriteFloat(float aFloat) = 0; /* [must_use] void writeDouble (in double aDouble); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeDouble) [[nodiscard]] NS_IMETHOD WriteDouble(double aDouble) = 0; /* [must_use] void writeStringZ (in string aString); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeStringZ) [[nodiscard]] NS_IMETHOD WriteStringZ(const char * aString) = 0; /* [must_use] void writeWStringZ (in wstring aString); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeWStringZ) [[nodiscard]] NS_IMETHOD WriteWStringZ(const char16_t * aString) = 0; /* [must_use] void writeUtf8Z (in wstring aString); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeUtf8Z) [[nodiscard]] NS_IMETHOD WriteUtf8Z(const char16_t * aString) = 0; /* [binaryname(WriteBytesFromJS),must_use] void writeBytes ([size_is (aLength)] in string aString, [optional] in uint32_t aLength); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBytes) [[nodiscard]] NS_IMETHOD WriteBytesFromJS(const char * aString, uint32_t aLength) = 0; /* [binaryname(WriteBytes),must_use,noscript,nostdcall] void writeBytesNative (in Bytes aBytes); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBytesNative) [[nodiscard]] virtual nsresult WriteBytes(mozilla::Span aBytes) = 0; /* [must_use] void writeByteArray (in Array aBytes); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeByteArray) [[nodiscard]] NS_IMETHOD WriteByteArray(const nsTArray& aBytes) = 0; // %{C++:93-101 /** * C++ helper to write a `const nsACString&` as an 8-bit pascal style string * to the stream. * 32-bit length field, followed by length 8-bit chars. */ [[nodiscard]] nsresult WriteCString(const nsACString& aString) { MOZ_TRY(Write32(aString.Length())); return WriteBytes(aString); } // %} }; /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSIBINARYOUTPUTSTREAM \ NS_IMETHOD SetOutputStream(nsIOutputStream *aOutputStream) override; \ [[nodiscard]] NS_IMETHOD WriteBoolean(bool aBoolean) override; \ [[nodiscard]] NS_IMETHOD Write8(uint8_t aByte) override; \ [[nodiscard]] NS_IMETHOD Write16(uint16_t a16) override; \ [[nodiscard]] NS_IMETHOD Write32(uint32_t a32) override; \ [[nodiscard]] NS_IMETHOD Write64(uint64_t a64) override; \ [[nodiscard]] NS_IMETHOD WriteFloat(float aFloat) override; \ [[nodiscard]] NS_IMETHOD WriteDouble(double aDouble) override; \ [[nodiscard]] NS_IMETHOD WriteStringZ(const char * aString) override; \ [[nodiscard]] NS_IMETHOD WriteWStringZ(const char16_t * aString) override; \ [[nodiscard]] NS_IMETHOD WriteUtf8Z(const char16_t * aString) override; \ [[nodiscard]] NS_IMETHOD WriteBytesFromJS(const char * aString, uint32_t aLength) override; \ [[nodiscard]] virtual nsresult WriteBytes(mozilla::Span aBytes) override; \ [[nodiscard]] NS_IMETHOD WriteByteArray(const nsTArray& aBytes) override; \ /* Use this macro when declaring the members of this interface when the class doesn't implement the interface. This is useful for forwarding. */ #define NS_DECL_NON_VIRTUAL_NSIBINARYOUTPUTSTREAM \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_setOutputStream)\ nsresult SetOutputStream(nsIOutputStream *aOutputStream); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBoolean)\ [[nodiscard]] nsresult WriteBoolean(bool aBoolean); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write8)\ [[nodiscard]] nsresult Write8(uint8_t aByte); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write16)\ [[nodiscard]] nsresult Write16(uint16_t a16); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write32)\ [[nodiscard]] nsresult Write32(uint32_t a32); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_write64)\ [[nodiscard]] nsresult Write64(uint64_t a64); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeFloat)\ [[nodiscard]] nsresult WriteFloat(float aFloat); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeDouble)\ [[nodiscard]] nsresult WriteDouble(double aDouble); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeStringZ)\ [[nodiscard]] nsresult WriteStringZ(const char * aString); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeWStringZ)\ [[nodiscard]] nsresult WriteWStringZ(const char16_t * aString); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeUtf8Z)\ [[nodiscard]] nsresult WriteUtf8Z(const char16_t * aString); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBytes)\ [[nodiscard]] nsresult WriteBytesFromJS(const char * aString, uint32_t aLength); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeBytesNative)\ [[nodiscard]] nsresult WriteBytes(mozilla::Span aBytes); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIBinaryOutputStream_writeByteArray)\ [[nodiscard]] nsresult WriteByteArray(const nsTArray& aBytes); \ /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSIBINARYOUTPUTSTREAM(_to) \ NS_IMETHOD SetOutputStream(nsIOutputStream *aOutputStream) override { return _to SetOutputStream(aOutputStream); } \ [[nodiscard]] NS_IMETHOD WriteBoolean(bool aBoolean) override { return _to WriteBoolean(aBoolean); } \ [[nodiscard]] NS_IMETHOD Write8(uint8_t aByte) override { return _to Write8(aByte); } \ [[nodiscard]] NS_IMETHOD Write16(uint16_t a16) override { return _to Write16(a16); } \ [[nodiscard]] NS_IMETHOD Write32(uint32_t a32) override { return _to Write32(a32); } \ [[nodiscard]] NS_IMETHOD Write64(uint64_t a64) override { return _to Write64(a64); } \ [[nodiscard]] NS_IMETHOD WriteFloat(float aFloat) override { return _to WriteFloat(aFloat); } \ [[nodiscard]] NS_IMETHOD WriteDouble(double aDouble) override { return _to WriteDouble(aDouble); } \ [[nodiscard]] NS_IMETHOD WriteStringZ(const char * aString) override { return _to WriteStringZ(aString); } \ [[nodiscard]] NS_IMETHOD WriteWStringZ(const char16_t * aString) override { return _to WriteWStringZ(aString); } \ [[nodiscard]] NS_IMETHOD WriteUtf8Z(const char16_t * aString) override { return _to WriteUtf8Z(aString); } \ [[nodiscard]] NS_IMETHOD WriteBytesFromJS(const char * aString, uint32_t aLength) override { return _to WriteBytesFromJS(aString, aLength); } \ [[nodiscard]] virtual nsresult WriteBytes(mozilla::Span aBytes) override { return _to WriteBytes(aBytes); } \ [[nodiscard]] NS_IMETHOD WriteByteArray(const nsTArray& aBytes) override { return _to WriteByteArray(aBytes); } \ /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSIBINARYOUTPUTSTREAM(_to) \ NS_IMETHOD SetOutputStream(nsIOutputStream *aOutputStream) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOutputStream(aOutputStream); } \ [[nodiscard]] NS_IMETHOD WriteBoolean(bool aBoolean) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteBoolean(aBoolean); } \ [[nodiscard]] NS_IMETHOD Write8(uint8_t aByte) override { return !_to ? NS_ERROR_NULL_POINTER : _to->Write8(aByte); } \ [[nodiscard]] NS_IMETHOD Write16(uint16_t a16) override { return !_to ? NS_ERROR_NULL_POINTER : _to->Write16(a16); } \ [[nodiscard]] NS_IMETHOD Write32(uint32_t a32) override { return !_to ? NS_ERROR_NULL_POINTER : _to->Write32(a32); } \ [[nodiscard]] NS_IMETHOD Write64(uint64_t a64) override { return !_to ? NS_ERROR_NULL_POINTER : _to->Write64(a64); } \ [[nodiscard]] NS_IMETHOD WriteFloat(float aFloat) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteFloat(aFloat); } \ [[nodiscard]] NS_IMETHOD WriteDouble(double aDouble) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteDouble(aDouble); } \ [[nodiscard]] NS_IMETHOD WriteStringZ(const char * aString) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteStringZ(aString); } \ [[nodiscard]] NS_IMETHOD WriteWStringZ(const char16_t * aString) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteWStringZ(aString); } \ [[nodiscard]] NS_IMETHOD WriteUtf8Z(const char16_t * aString) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteUtf8Z(aString); } \ [[nodiscard]] NS_IMETHOD WriteBytesFromJS(const char * aString, uint32_t aLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteBytesFromJS(aString, aLength); } \ [[nodiscard]] virtual nsresult WriteBytes(mozilla::Span aBytes) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteBytes(aBytes); } \ [[nodiscard]] NS_IMETHOD WriteByteArray(const nsTArray& aBytes) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteByteArray(aBytes); } \ // %{C++:106-127 [[nodiscard]] inline nsresult NS_WriteOptionalStringZ(nsIBinaryOutputStream* aStream, const char* aString) { bool nonnull = (aString != nullptr); MOZ_TRY(aStream->WriteBoolean(nonnull)); if (nonnull) { MOZ_TRY(aStream->WriteStringZ(aString)); } return NS_OK; } [[nodiscard]] inline nsresult NS_WriteOptionalWStringZ(nsIBinaryOutputStream* aStream, const char16_t* aString) { bool nonnull = (aString != nullptr); MOZ_TRY(aStream->WriteBoolean(nonnull)); if (nonnull) { MOZ_TRY(aStream->WriteWStringZ(aString)); } return NS_OK; } // %} #endif /* __gen_nsIBinaryOutputStream_h__ */