MCPcopy Create free account
hub / github.com/Kitware/VTK / Encode

Method Encode

IO/Core/vtkBase64Utilities.cxx:60–103  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

58
59//------------------------------------------------------------------------------
60unsigned long vtkBase64Utilities::Encode(
61 const unsigned char* input, unsigned long length, unsigned char* output, int mark_end)
62{
63
64 const unsigned char* ptr = input;
65 const unsigned char* end = input + length;
66 unsigned char* optr = output;
67
68 // Encode complete triplet
69
70 while ((end - ptr) >= 3)
71 {
72 vtkBase64Utilities::EncodeTriplet(
73 ptr[0], ptr[1], ptr[2], &optr[0], &optr[1], &optr[2], &optr[3]);
74 ptr += 3;
75 optr += 4;
76 }
77
78 // Encodes a 2-byte ending into 3 bytes and 1 pad byte and writes.
79
80 if (end - ptr == 2)
81 {
82 vtkBase64Utilities::EncodePair(ptr[0], ptr[1], &optr[0], &optr[1], &optr[2], &optr[3]);
83 optr += 4;
84 }
85
86 // Encodes a 1-byte ending into 2 bytes and 2 pad bytes
87
88 else if (end - ptr == 1)
89 {
90 vtkBase64Utilities::EncodeSingle(ptr[0], &optr[0], &optr[1], &optr[2], &optr[3]);
91 optr += 4;
92 }
93
94 // Do we need to mark the end
95
96 else if (mark_end)
97 {
98 optr[0] = optr[1] = optr[2] = optr[3] = '=';
99 optr += 4;
100 }
101
102 return optr - output;
103}
104
105//------------------------------------------------------------------------------
106static constexpr unsigned char vtkBase64UtilitiesDecodeTable[256] = {

Callers 2

GetWebGLBinaryDataMethod · 0.80
WriteDataMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected