1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/xpwidgets/nsPrimitiveHelpers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsPrimitiveHelpers_h___ 1.11 +#define nsPrimitiveHelpers_h___ 1.12 + 1.13 +#include "nsError.h" 1.14 +#include "nscore.h" 1.15 + 1.16 +class nsISupports; 1.17 + 1.18 + 1.19 +class nsPrimitiveHelpers 1.20 +{ 1.21 +public: 1.22 + 1.23 + // Given some data and the flavor it corresponds to, creates the appropriate 1.24 + // nsISupports* wrapper for passing across IDL boundaries. The length parameter 1.25 + // should not include the null if the data is null terminated. 1.26 + static void CreatePrimitiveForData ( const char* aFlavor, const void* aDataBuff, 1.27 + uint32_t aDataLen, nsISupports** aPrimitive ) ; 1.28 + 1.29 + // Given a nsISupports* primitive and the flavor it represents, creates a new data 1.30 + // buffer with the data in it. This data will be null terminated, but the length 1.31 + // parameter does not reflect that. 1.32 + static void CreateDataFromPrimitive ( const char* aFlavor, nsISupports* aPrimitive, 1.33 + void** aDataBuff, uint32_t aDataLen ) ; 1.34 + 1.35 + // Given a unicode buffer (flavor text/unicode), this converts it to plain text using 1.36 + // the appropriate platform charset encoding. |inUnicodeLen| is the length of the input 1.37 + // string, not the # of bytes in the buffer. |outPlainTextData| is null terminated, 1.38 + // but its length parameter, |outPlainTextLen|, does not reflect that. 1.39 + static nsresult ConvertUnicodeToPlatformPlainText ( char16_t* inUnicode, int32_t inUnicodeLen, 1.40 + char** outPlainTextData, int32_t* outPlainTextLen ) ; 1.41 + 1.42 + // Given a char buffer (flavor text/plaikn), this converts it to unicode using 1.43 + // the appropriate platform charset encoding. |outUnicode| is null terminated, 1.44 + // but its length parameter, |outUnicodeLen|, does not reflect that. |outUnicodeLen| is 1.45 + // the length of the string in characters, not bytes. 1.46 + static nsresult ConvertPlatformPlainTextToUnicode ( const char* inText, int32_t inTextLen, 1.47 + char16_t** outUnicode, int32_t* outUnicodeLen ) ; 1.48 + 1.49 +}; // class nsPrimitiveHelpers 1.50 + 1.51 + 1.52 + 1.53 +class nsLinebreakHelpers 1.54 +{ 1.55 +public: 1.56 + 1.57 + // Given some data, convert from the platform linebreaks into the LF expected by the 1.58 + // DOM. This will attempt to convert the data in place, but the buffer may still need to 1.59 + // be reallocated regardless (disposing the old buffer is taken care of internally, see 1.60 + // the note below). 1.61 + // 1.62 + // NOTE: this assumes that it can use nsMemory to dispose of the old buffer. 1.63 + static nsresult ConvertPlatformToDOMLinebreaks ( const char* inFlavor, void** ioData, int32_t* ioLengthInBytes ) ; 1.64 + 1.65 +}; // class nsLinebreakHelpers 1.66 + 1.67 + 1.68 +#endif // nsPrimitiveHelpers_h___