// Copyright 2019 The Crashpad Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "util/stream/base94_output_stream.h" #include <algorithm> #include "base/check.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" namespace crashpad { namespace { // To improve the space efficiency, we can encode 14 bits into two symbols // if 14-bit number is less than 94^2 which is total number can be encoded // by 2 digits of base94 number, in another word, if 13 bit number is // smaller than 643, we could read one more bit, because even if the 14th // bit is 1, the 14-bit number doesn’t exceed the max value. constexpr uint16_t kMaxValueOf14BitEncoding = …; constexpr size_t kMaxBuffer = …; inline uint8_t EncodeByte(uint8_t byte) { … } inline uint8_t DecodeByte(uint8_t byte) { … } } // namespace Base94OutputStream::Base94OutputStream( Mode mode, std::unique_ptr<OutputStreamInterface> output_stream) : … { … } Base94OutputStream::~Base94OutputStream() { … } bool Base94OutputStream::Write(const uint8_t* data, size_t size) { … } bool Base94OutputStream::Flush() { … } bool Base94OutputStream::Encode(const uint8_t* data, size_t size) { … } bool Base94OutputStream::Decode(const uint8_t* data, size_t size) { … } bool Base94OutputStream::FinishEncoding() { … } bool Base94OutputStream::FinishDecoding() { … } bool Base94OutputStream::WriteOutputStream() { … } } // namespace crashpad