PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/mozilla/mozilla/dist/include/necko/nsIStreamConverter.h

http://kmbrasil.codeplex.com
C++ Header | 183 lines | 62 code | 29 blank | 92 comment | 0 complexity | 311174d90f2422da171ddd7dbb72e43d MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM h:/projects/mozilla/mozilla/netwerk/streamconv/public/nsIStreamConverter.idl
  3. */
  4. #ifndef __gen_nsIStreamConverter_h__
  5. #define __gen_nsIStreamConverter_h__
  6. #ifndef __gen_nsIStreamListener_h__
  7. #include "nsIStreamListener.h"
  8. #endif
  9. #ifndef __gen_nsIInputStream_h__
  10. #include "nsIInputStream.h"
  11. #endif
  12. #ifndef __gen_nsIURI_h__
  13. #include "nsIURI.h"
  14. #endif
  15. /* For IDL files that don't want to include root IDL files. */
  16. #ifndef NS_NO_VTABLE
  17. #define NS_NO_VTABLE
  18. #endif
  19. /* starting interface: nsIStreamConverter */
  20. #define NS_ISTREAMCONVERTER_IID_STR "0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b"
  21. #define NS_ISTREAMCONVERTER_IID \
  22. {0x0b6e2c69, 0x5cf5, 0x48b0, \
  23. { 0x9d, 0xfd, 0xc9, 0x59, 0x50, 0xe2, 0xcc, 0x7b }}
  24. /**
  25. * nsIStreamConverter provides an interface to implement when you have code
  26. * that converts data from one type to another.
  27. *
  28. * Suppose you had code that converted plain text into HTML. You could implement
  29. * this interface to allow everyone else to use your conversion logic using a
  30. * standard api.
  31. * <p>
  32. * <b>STREAM CONVERTER USERS</b>
  33. *
  34. * There are currently two ways to use a stream converter:
  35. * <ol>
  36. * <li> <b>SYNCHRONOUS</b> Stream to Stream
  37. * You can supply the service with a stream of type X
  38. * and it will convert it to your desired output type and return
  39. * a converted (blocking) stream to you.</li>
  40. *
  41. * <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
  42. * You can supply data directly to the converter by calling it's
  43. * nsIStreamListener::OnDataAvailable() method. It will then
  44. * convert that data from type X to your desired output type and
  45. * return converted data to you via the nsIStreamListener you passed
  46. * in by calling its OnDataAvailable() method.</li>
  47. * </ol>
  48. * <p>
  49. *
  50. * <b>STREAM CONVERTER SUPPLIERS</b>
  51. *
  52. * Registering a stream converter:
  53. * Stream converter registration is a two step process. First of all the stream
  54. * converter implementation must register itself with the component manager using
  55. * a contractid in the format below. Second, the stream converter must add the contractid
  56. * to the registry.
  57. *
  58. * Stream converter contractid format (the stream converter root key is defined in this
  59. * file):
  60. *
  61. * <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
  62. *
  63. * @author Jud Valeski
  64. * @see nsIStreamConverterService
  65. */
  66. class NS_NO_VTABLE nsIStreamConverter : public nsIStreamListener {
  67. public:
  68. NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTREAMCONVERTER_IID)
  69. /**
  70. * <b>SYNCRONOUS VERSION</b>
  71. * Converts a stream of one type, to a stream of another type.
  72. *
  73. * Use this method when you have a stream you want to convert.
  74. *
  75. * @param aFromStream The stream representing the original/raw data.
  76. * @param aFromType The MIME type of aFromStream.
  77. * @param aToType The MIME type of the returned stream.
  78. * @param aCtxt Either an opaque context, or a converter specific context
  79. * (implementation specific).
  80. * @return The converted stream. NOTE: The returned stream may not
  81. * already be converted. An efficient stream converter
  82. * implementation will converter data on demand rather than
  83. * buffering the converted data until it is used.
  84. */
  85. /* nsIInputStream convert (in nsIInputStream aFromStream, in string aFromType, in string aToType, in nsISupports aCtxt); */
  86. NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) = 0;
  87. /**
  88. * <b>ASYNCRONOUS VERSION</b>
  89. * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable()
  90. * method from one type to another, pushing the converted data out to the caller
  91. * via aListener::OnDataAvailable().
  92. *
  93. * Use this method when you want to proxy (and convert) nsIStreamListener callbacks
  94. * asynchronously.
  95. *
  96. * @param aFromType The MIME type of the original/raw data.
  97. * @param aToType The MIME type of the converted data.
  98. * @param aListener The listener who receives the converted data.
  99. * @param aCtxt Either an opaque context, or a converter specific context
  100. * (implementation specific).
  101. */
  102. /* void asyncConvertData (in string aFromType, in string aToType, in nsIStreamListener aListener, in nsISupports aCtxt); */
  103. NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) = 0;
  104. };
  105. /* Use this macro when declaring classes that implement this interface. */
  106. #define NS_DECL_NSISTREAMCONVERTER \
  107. NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval); \
  108. NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt);
  109. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  110. #define NS_FORWARD_NSISTREAMCONVERTER(_to) \
  111. NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) { return _to Convert(aFromStream, aFromType, aToType, aCtxt, _retval); } \
  112. NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) { return _to AsyncConvertData(aFromType, aToType, aListener, aCtxt); }
  113. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  114. #define NS_FORWARD_SAFE_NSISTREAMCONVERTER(_to) \
  115. NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Convert(aFromStream, aFromType, aToType, aCtxt, _retval); } \
  116. NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) { return !_to ? NS_ERROR_NULL_POINTER : _to->AsyncConvertData(aFromType, aToType, aListener, aCtxt); }
  117. #if 0
  118. /* Use the code below as a template for the implementation class for this interface. */
  119. /* Header file */
  120. class nsStreamConverter : public nsIStreamConverter
  121. {
  122. public:
  123. NS_DECL_ISUPPORTS
  124. NS_DECL_NSISTREAMCONVERTER
  125. nsStreamConverter();
  126. private:
  127. ~nsStreamConverter();
  128. protected:
  129. /* additional members */
  130. };
  131. /* Implementation file */
  132. NS_IMPL_ISUPPORTS1(nsStreamConverter, nsIStreamConverter)
  133. nsStreamConverter::nsStreamConverter()
  134. {
  135. /* member initializers and constructor code */
  136. }
  137. nsStreamConverter::~nsStreamConverter()
  138. {
  139. /* destructor code */
  140. }
  141. /* nsIInputStream convert (in nsIInputStream aFromStream, in string aFromType, in string aToType, in nsISupports aCtxt); */
  142. NS_IMETHODIMP nsStreamConverter::Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval)
  143. {
  144. return NS_ERROR_NOT_IMPLEMENTED;
  145. }
  146. /* void asyncConvertData (in string aFromType, in string aToType, in nsIStreamListener aListener, in nsISupports aCtxt); */
  147. NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt)
  148. {
  149. return NS_ERROR_NOT_IMPLEMENTED;
  150. }
  151. /* End of implementation class template. */
  152. #endif
  153. #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1"
  154. #endif /* __gen_nsIStreamConverter_h__ */