docs(*): fix params, throws

This commit is contained in:
2024-11-10 18:10:55 +03:00
parent f7cdbf4882
commit 029efbbf5e
4 changed files with 124 additions and 58 deletions

View File

@ -10,28 +10,57 @@ namespace base64
extern const char digits[65];
extern const uint8_t map[256];
/**
* @return checks what contains only alphabet chars and ends with no more than two '=' chars
*/
bool isValid(const char *str, size_t str_size) noexcept;
/**
* @param str string or string_view which you want to decode
* @return checks what contains only alphabet chars and ends with no more than two '=' chars
*/
bool isValid(std::string_view str) noexcept;
/**
* @param data vector or span of data which you want to encode
* @return exact size after encoding
* @throw basen::Exception(OVERFLOW) if there is an overflow
*/
size_t sizeEncoded(std::span<const uint8_t> data);
/**
* @param str string or string_view which you want to decode
* @return exact size after decoding
*/
size_t sizeDecoded(std::string_view str) noexcept;
/**
* @param data [in] pointer to data which you want encode
* @param str [out] pointer to string for encoded data output
* @throw basen::Exception(OVERFLOW) from base64::sizeEncoded
* @throw basen::Exception(LENGTH) if not enough allocated length
* @warning contain leading zeros, returns count of them
*/
void encode(const uint8_t *data, size_t data_size, char *str, size_t str_size);
/**
* @param data vector or span of data which you want to encode
* @return encoded string
* @throw basen::Exception(OVERFLOW) from base64::sizeEncoded
* @throw basen::Exception(LENGTH) if not enough allocated length
*/
std::string encode(std::span<const uint8_t> data);
/**
* @param str [in] pointer to string which you want decode
* @param data [out] pointer to data for encoded string output
* @throw basen::Exception(LENGTH) if not enough allocated length
* @throw basen::Exception(OUT_OF_ALPH) if out of digits map
* @throw basen::Exception(PADDING) if incorrect padding
* @warning contain leading zeros, returns count of them
*/
void decode(const char *str, size_t str_size, uint8_t *data, size_t data_size);
/**
* @param str string or string_view which you want to decode
* @return decoded data
* @throw basen::Exception(LENGTH) if not enough allocated length
* @throw basen::Exception(OUT_OF_ALPH) if out of digits map
* @throw basen::Exception(PADDING) if incorrect padding
*/
std::vector<uint8_t> decode(std::string_view str);
}