Base64.hpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2025, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #pragma once
  35. #ifndef AI_BASE64_HPP_INC
  36. #define AI_BASE64_HPP_INC
  37. #include <assimp/defs.h>
  38. #include <stdint.h>
  39. #include <vector>
  40. #include <string>
  41. namespace Assimp {
  42. namespace Base64 {
  43. /// @brief Will encode the given character buffer from UTF64 to ASCII
  44. /// @param in The UTF-64 buffer.
  45. /// @param inLength The size of the buffer
  46. /// @param out The encoded ASCII string.
  47. ASSIMP_API void Encode(const uint8_t *in, size_t inLength, std::string &out);
  48. /// @brief Will encode the given character buffer from UTF64 to ASCII.
  49. /// @param in A vector, which contains the buffer for encoding.
  50. /// @param out The encoded ASCII string.
  51. ASSIMP_API void Encode(const std::vector<uint8_t> &in, std::string &out);
  52. /// @brief Will encode the given character buffer from UTF64 to ASCII.
  53. /// @param in A vector, which contains the buffer for encoding.
  54. /// @return The encoded ASCII string.
  55. ASSIMP_API std::string Encode(const std::vector<uint8_t> &in);
  56. /// @brief Will decode the given character buffer from ASCII to UTF64.
  57. /// @param in The ASCII buffer to decode.
  58. /// @param inLength The size of the buffer.
  59. /// @param out The decoded buffer.
  60. /// @return The new buffer size.
  61. ASSIMP_API size_t Decode(const char *in, size_t inLength, uint8_t *&out);
  62. /// @brief Will decode the given character buffer from ASCII to UTF64.
  63. /// @param in The ASCII buffer to decode as a std::string.
  64. /// @param out The decoded buffer.
  65. /// @return The new buffer size.
  66. ASSIMP_API size_t Decode(const std::string &in, std::vector<uint8_t> &out);
  67. /// @brief Will decode the given character buffer from ASCII to UTF64.
  68. /// @param in The ASCII string.
  69. /// @return The decoded buffer in a vector.
  70. ASSIMP_API std::vector<uint8_t> Decode(const std::string &in);
  71. } // namespace Base64
  72. } // namespace Assimp
  73. #endif // AI_BASE64_HPP_INC