void ReadBinaryDataUri()

in GLTFSDK/Inc/GLTFSDK/GLTFResourceReader.h [217:266]


            void ReadBinaryDataUri(Base64StringView encodedData, Base64BufferView decodedData, const std::streamoff* offsetOverride = nullptr) const
            {
                // The number of unwanted extra bytes that must be decoded for the specified byte offset
                size_t offsetAdjustment = 0;

                if (offsetOverride)
                {
                    if (*offsetOverride < 0)
                    {
                        throw GLTFException("Negative offsets are not supported");
                    }

                    auto byteCount = static_cast<size_t>(*offsetOverride);
                    offsetAdjustment = ByteCountToCharCountRemainder(byteCount);
                    const size_t offsetBegin = ByteCountToCharCount(byteCount);

                    if (offsetBegin < encodedData.GetCharCount())
                    {
                        encodedData.itBegin += offsetBegin;
                    }
                    else
                    {
                        throw GLTFException("Offset position as a base64 character index is outside the input range");
                    }
                }

                auto offsetByteCount = decodedData.bufferByteLength + offsetAdjustment;
                size_t offsetEnd = ByteCountToCharCount(offsetByteCount);

                switch (ByteCountToCharCountRemainder(offsetByteCount))
                {
                case 1U:
                    offsetEnd += 2U;// Decode 2 more characters for 1 extra byte
                    break;
                case 2U:
                    offsetEnd += 3U;// Decode 3 more characters for 2 extra bytes
                    break;
                }

                if (offsetEnd <= encodedData.GetCharCount())
                {
                    encodedData.itEnd = encodedData.itBegin + offsetEnd;
                }
                else
                {
                    throw GLTFException("Offset position as a base64 character index is outside the input range");
                }

                Base64Decode(encodedData, decodedData, offsetAdjustment);
            }