Bumping manifests a=b2g-bump
[gecko.git] / widget / nsPrimitiveHelpers.h
blob33c08f2581d22b924cc6ecf77d0223f19481bea7
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsPrimitiveHelpers_h___
8 #define nsPrimitiveHelpers_h___
10 #include "nsError.h"
11 #include "nscore.h"
13 class nsISupports;
16 class nsPrimitiveHelpers
18 public:
20 // Given some data and the flavor it corresponds to, creates the appropriate
21 // nsISupports* wrapper for passing across IDL boundaries. The length parameter
22 // should not include the null if the data is null terminated.
23 static void CreatePrimitiveForData ( const char* aFlavor, const void* aDataBuff,
24 uint32_t aDataLen, nsISupports** aPrimitive ) ;
26 // Given a nsISupports* primitive and the flavor it represents, creates a new data
27 // buffer with the data in it. This data will be null terminated, but the length
28 // parameter does not reflect that.
29 static void CreateDataFromPrimitive ( const char* aFlavor, nsISupports* aPrimitive,
30 void** aDataBuff, uint32_t aDataLen ) ;
32 // Given a unicode buffer (flavor text/unicode), this converts it to plain text using
33 // the appropriate platform charset encoding. |inUnicodeLen| is the length of the input
34 // string, not the # of bytes in the buffer. |outPlainTextData| is null terminated,
35 // but its length parameter, |outPlainTextLen|, does not reflect that.
36 static nsresult ConvertUnicodeToPlatformPlainText ( char16_t* inUnicode, int32_t inUnicodeLen,
37 char** outPlainTextData, int32_t* outPlainTextLen ) ;
39 // Given a char buffer (flavor text/plaikn), this converts it to unicode using
40 // the appropriate platform charset encoding. |outUnicode| is null terminated,
41 // but its length parameter, |outUnicodeLen|, does not reflect that. |outUnicodeLen| is
42 // the length of the string in characters, not bytes.
43 static nsresult ConvertPlatformPlainTextToUnicode ( const char* inText, int32_t inTextLen,
44 char16_t** outUnicode, int32_t* outUnicodeLen ) ;
46 }; // class nsPrimitiveHelpers
50 class nsLinebreakHelpers
52 public:
54 // Given some data, convert from the platform linebreaks into the LF expected by the
55 // DOM. This will attempt to convert the data in place, but the buffer may still need to
56 // be reallocated regardless (disposing the old buffer is taken care of internally, see
57 // the note below).
59 // NOTE: this assumes that it can use nsMemory to dispose of the old buffer.
60 static nsresult ConvertPlatformToDOMLinebreaks ( const char* inFlavor, void** ioData, int32_t* ioLengthInBytes ) ;
62 }; // class nsLinebreakHelpers
65 #endif // nsPrimitiveHelpers_h___