Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/leb128.h
1 /* 2 * Copyright 2017 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_LEB128_H_ 18 #define WABT_LEB128_H_ 19 20 #include <cstdint> 21 22 #include "wabt/common.h" 23 24 namespace wabt { 25 26 class Stream; 27 28 // Returns the length of the leb128. 29 Offset U32Leb128Length(uint32_t value); 30 31 void WriteU32Leb128(Stream* stream, uint32_t value, const char* desc); 32 void WriteS32Leb128(Stream* stream, uint32_t value, const char* desc); 33 void WriteU64Leb128(Stream* stream, uint64_t value, const char* desc); 34 void WriteS64Leb128(Stream* stream, uint64_t value, const char* desc); 35 void WriteFixedS32Leb128(Stream* stream, uint32_t value, const char* desc); 36 void WriteFixedU32Leb128(Stream* stream, uint32_t value, const char* desc); 37 38 Offset WriteU32Leb128At(Stream* stream, 39 Offset offset, 40 uint32_t value, 41 const char* desc); 42 43 Offset WriteFixedU32Leb128At(Stream* stream, 44 Offset offset, 45 uint32_t value, 46 const char* desc); 47 48 Offset WriteU32Leb128Raw(uint8_t* data, uint8_t* end, uint32_t value); 49 Offset WriteFixedU32Leb128Raw(uint8_t* data, uint8_t* end, uint32_t value); 50 51 // Convenience functions for writing enums as LEB128s. 52 template <typename T> 53 void WriteU32Leb128(Stream* stream, T value, const char* desc) { 54 WriteU32Leb128(stream, static_cast<uint32_t>(value), desc); 55 } 56 57 template <typename T> 58 void WriteS32Leb128(Stream* stream, T value, const char* desc) { 59 WriteS32Leb128(stream, static_cast<uint32_t>(value), desc); 60 } 61 62 // Returns the length of the leb128. 63 size_t ReadU32Leb128(const uint8_t* p, const uint8_t* end, uint32_t* out_value); 64 size_t ReadU64Leb128(const uint8_t* p, const uint8_t* end, uint64_t* out_value); 65 size_t ReadS32Leb128(const uint8_t* p, const uint8_t* end, uint32_t* out_value); 66 size_t ReadS64Leb128(const uint8_t* p, const uint8_t* end, uint64_t* out_value); 67 68 } // namespace wabt 69 70 #endif // WABT_LEB128_H_