/*---------------------------------------------------------------------------* Project: Horizon File: util_Base64.h Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 27772 $ *---------------------------------------------------------------------------*/ #ifndef NN_UTIL_UTIL_BASE64_H_ #define NN_UTIL_UTIL_BASE64_H_ #include #include #ifdef __cplusplus namespace nn { namespace util { /*! :category Result @class nn::util::ResultBufferFull @brief The output buffer is not big enough. */ NN_DEFINE_RESULT_CONST( ResultBufferFull, Result::LEVEL_PERMANENT, Result::SUMMARY_OUT_OF_RESOURCE, Result::MODULE_NN_UTIL, DESCRIPTION_BUFFER_FULL ); /*! :category Result @class nn::util::ResultBadData @brief Invalid input data. */ NN_DEFINE_RESULT_CONST( ResultBadData, Result::LEVEL_PERMANENT, Result::SUMMARY_WRONG_ARGUMENT, Result::MODULE_NN_UTIL, DESCRIPTION_BAD_DATA ); /*! :category Result @class nn::util::ResultInvalidPtr @brief The pointer specified as an argument is invalid. */ NN_DEFINE_RESULT_CONST( ResultInvalidPtr, Result::LEVEL_USAGE, Result::SUMMARY_INVALID_ARGUMENT, Result::MODULE_NN_UTIL, Result::DESCRIPTION_INVALID_POINTER ); /*! @brief The class for base-64 encoding and decoding. */ class Base64 { public: /*! @brief Converts the entered binary data into a base 64 format string. @param[in] pSrc Pointer to input data. @param[in] sizeSrc The size of input data. @param[out] pDst Pointer to the output buffer for a base-64 format string. @param[in] sizeDst Size of the buffer indicated by pDst. @return Returns whether the resource was successfully converted. */ static nn::Result ToBase64String(const void* pSrc, size_t sizeSrc, char* pDst, size_t sizeDst); /*! @brief Converts a base 64 format into binary data. @param[in] pSrc Pointer to input data in base64 format. @param[out] pDst Pointer to the buffer that holds the output data. @param[in] sizeDst Size of the buffer indicated by pDst. @param[out] pNum Buffer for storing the number of characters actually output. @return Returns whether the resource was successfully converted. */ static nn::Result FromBase64String(const char* pSrc, void* pDst, size_t sizeDst, size_t* pNum); }; }} #endif // __cplusplus #endif // ifndef NN_UTIL_UTIL_BASE64_H_