Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shell
common
base64.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_SHELL_COMMON_BASE64_H_
6
#define FLUTTER_SHELL_COMMON_BASE64_H_
7
8
#include <cstddef>
9
10
namespace
flutter
{
11
12
struct
Base64
{
13
public
:
14
enum class
Error
{
15
kNone
,
16
kBadPadding
,
17
kBadChar
,
18
};
19
20
/**
21
Base64 encodes src into dst.
22
23
@param dst a pointer to a buffer large enough to receive the result.
24
25
@return the required length of dst for encoding.
26
*/
27
static
size_t
Encode
(
const
void
* src,
size_t
length
,
void
* dst);
28
29
/**
30
Returns the length of the buffer that needs to be allocated to encode
31
srcDataLength bytes.
32
*/
33
static
size_t
EncodedSize
(
size_t
srcDataLength) {
34
// Take the floor of division by 3 to find the number of groups that need to
35
// be encoded. Each group takes 4 bytes to be represented in base64.
36
return
((srcDataLength + 2) / 3) * 4;
37
}
38
39
/**
40
Base64 decodes src into dst.
41
42
This can be called once with 'dst' nullptr to get the required size,
43
then again with an allocated 'dst' pointer to do the actual decoding.
44
45
@param dst nullptr or a pointer to a buffer large enough to receive the
46
result
47
48
@param dstLength assigned the length dst is required to be. Must not be
49
nullptr.
50
*/
51
[[nodiscard]]
static
Error
Decode
(
const
void
* src,
52
size_t
srcLength,
53
void
* dst,
54
size_t
* dstLength);
55
};
56
57
}
// namespace flutter
58
59
#endif
// FLUTTER_SHELL_COMMON_BASE64_H_
length
size_t length
Definition
key_event_handler.cc:41
flutter
Definition
asset_manager.cc:10
flutter::Base64
Definition
base64.h:12
flutter::Base64::Error
Error
Definition
base64.h:14
flutter::Base64::Error::kNone
@ kNone
flutter::Base64::Error::kBadPadding
@ kBadPadding
flutter::Base64::Error::kBadChar
@ kBadChar
flutter::Base64::Encode
static size_t Encode(const void *src, size_t length, void *dst)
Definition
base64.cc:118
flutter::Base64::Decode
static Error Decode(const void *src, size_t srcLength, void *dst, size_t *dstLength)
Definition
base64.cc:28
flutter::Base64::EncodedSize
static size_t EncodedSize(size_t srcDataLength)
Definition
base64.h:33
Generated on Fri Apr 26 2024 06:14:46 for Flutter Engine by
1.9.8