1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: util_Base64.h 4 5 Copyright (C) Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 27772 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_UTIL_UTIL_BASE64_H_ 17 #define NN_UTIL_UTIL_BASE64_H_ 18 19 #include <nn/types.h> 20 #include <nn/util/util_Result.h> 21 22 #ifdef __cplusplus 23 24 namespace nn { namespace util { 25 26 /*! 27 :category Result 28 @class nn::util::ResultBufferFull 29 @brief The output buffer is not big enough. 30 */ 31 NN_DEFINE_RESULT_CONST( 32 ResultBufferFull, 33 Result::LEVEL_PERMANENT, 34 Result::SUMMARY_OUT_OF_RESOURCE, 35 Result::MODULE_NN_UTIL, 36 DESCRIPTION_BUFFER_FULL 37 ); 38 39 /*! 40 :category Result 41 @class nn::util::ResultBadData 42 @brief Invalid input data. 43 */ 44 NN_DEFINE_RESULT_CONST( 45 ResultBadData, 46 Result::LEVEL_PERMANENT, 47 Result::SUMMARY_WRONG_ARGUMENT, 48 Result::MODULE_NN_UTIL, 49 DESCRIPTION_BAD_DATA 50 ); 51 52 /*! 53 :category Result 54 @class nn::util::ResultInvalidPtr 55 @brief The pointer specified as an argument is invalid. 56 */ 57 NN_DEFINE_RESULT_CONST( 58 ResultInvalidPtr, 59 Result::LEVEL_USAGE, 60 Result::SUMMARY_INVALID_ARGUMENT, 61 Result::MODULE_NN_UTIL, 62 Result::DESCRIPTION_INVALID_POINTER 63 ); 64 65 /*! 66 @brief The class for base-64 encoding and decoding. 67 */ 68 class Base64 69 { 70 public: 71 72 /*! 73 @brief Converts the entered binary data into a base 64 format string. 74 75 @param[in] pSrc Pointer to input data. 76 @param[in] sizeSrc The size of input data. 77 @param[out] pDst Pointer to the output buffer for a base-64 format string. 78 @param[in] sizeDst Size of the buffer indicated by <var>pDst</var>. 79 80 @return Returns whether the resource was successfully converted. 81 */ 82 static nn::Result ToBase64String(const void* pSrc, size_t sizeSrc, char* pDst, size_t sizeDst); 83 84 /*! 85 @brief Converts a base 64 format into binary data. 86 87 @param[in] pSrc Pointer to input data in <tt>base64</tt> format. 88 @param[out] pDst Pointer to the buffer that holds the output data. 89 @param[in] sizeDst Size of the buffer indicated by <var>pDst</var>. 90 @param[out] pNum Buffer for storing the number of characters actually output. 91 92 @return Returns whether the resource was successfully converted. 93 */ 94 static nn::Result FromBase64String(const char* pSrc, void* pDst, size_t sizeDst, size_t* pNum); 95 }; 96 97 }} 98 99 #endif // __cplusplus 100 101 #endif // ifndef NN_UTIL_UTIL_BASE64_H_ 102