|
||||
File indexing completed on 2025-01-18 10:03:30
0001 // Copyright (c) 2016-2019 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _FSD_Base64_HeaderFile 0015 #define _FSD_Base64_HeaderFile 0016 0017 #include <NCollection_Buffer.hxx> 0018 #include <TCollection_AsciiString.hxx> 0019 0020 //! Tool for encoding/decoding base64 stream. 0021 class FSD_Base64 0022 { 0023 public: 0024 0025 //! Function encoding a buffer to base64 string. 0026 //! @param[out] theEncodedStr the place for encoded string. Terminating null is not put. 0027 //! If it is NULL just return the needed size. 0028 //! @param[in] theStrLen the length of the buffer theEncodedStr in bytes. 0029 //! This value must not be less than value returned when theEncodedStr is NULL. 0030 //! @param[in] theData the input binary data. 0031 //! @param[in] theDataLen the length of input data in bytes. 0032 //! @return the length of the encoded string not including terminating null. 0033 //! If theStrLen is not enough for storing all data nothing is written and 0 is returned. 0034 Standard_EXPORT static Standard_Size Encode (char* theEncodedStr, 0035 const Standard_Size theStrLen, 0036 const Standard_Byte* theData, 0037 const Standard_Size theDataLen); 0038 0039 //! Function encoding a buffer to base64 string. 0040 //! @param[in] theData the input binary data 0041 //! @param[in] theDataLen the length of input data in bytes 0042 //! @return Base64 encoded string. 0043 Standard_EXPORT static TCollection_AsciiString Encode(const Standard_Byte* theData, 0044 const Standard_Size theDataLen); 0045 0046 //! Function decoding base64 string. 0047 //! @param[out] theDecodedData the place for decoded data. 0048 //! If it is NULL just return the needed size. 0049 //! @param[in] theDataLen the length of the buffer theDecodedData in bytes. 0050 //! This value must not be less than value returned when theDecodedData is NULL. 0051 //! @param[in] theEncodedStr the input encoded string. 0052 //! @param[in] theStrLen the length of input encoded string. 0053 //! @return the length of the decoded data in bytes. If theDataLen is not enough 0054 //! for storing all data nothing is written and 0 is returned. 0055 Standard_EXPORT static Standard_Size Decode (Standard_Byte* theDecodedData, 0056 const Standard_Size theDataLen, 0057 Standard_CString theEncodedStr, 0058 const Standard_Size theStrLen); 0059 0060 //! Function decoding base64 string. 0061 //! @param[in] theStr the input encoded string 0062 //! @param[in] theLen the length of input encoded string 0063 //! @return null handle in case of out of memory condition 0064 Standard_EXPORT static Handle(NCollection_Buffer) Decode (Standard_CString theStr, 0065 const Standard_Size theLen); 0066 }; 0067 0068 #endif // _FSD_Base64_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |