1311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// Copyright 2008 Google Inc. 2311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// Author: Lincoln Smith 3311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 4311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// Licensed under the Apache License, Version 2.0 (the "License"); 5311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// you may not use this file except in compliance with the License. 6311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// You may obtain a copy of the License at 7311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 8311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// http://www.apache.org/licenses/LICENSE-2.0 9311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 10311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// Unless required by applicable law or agreed to in writing, software 11311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// distributed under the License is distributed on an "AS IS" BASIS, 12311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// See the License for the specific language governing permissions and 14311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// limitations under the License. 15311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 16311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#ifndef OPEN_VCDIFF_ENCODETABLE_H_ 17311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define OPEN_VCDIFF_ENCODETABLE_H_ 18311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 19311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include <config.h> 2028db8079f707ebdf43ce62cdfd96eb39c8f889e0openvcdiff#include <stddef.h> // size_t 2128db8079f707ebdf43ce62cdfd96eb39c8f889e0openvcdiff#include <stdint.h> // int32_t 22311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include <string> 23311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "addrcache.h" 24311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "checksum.h" 25311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "codetable.h" 26d18457863096b3685e56f5a8919959f6afbdb121openvcdiff#include "codetablewriter_interface.h" 27311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 28311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffnamespace open_vcdiff { 29311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 30311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffclass OutputStringInterface; 31311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffclass VCDiffInstructionMap; 32311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 33311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// The method calls after construction *must* conform 34311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// to the following pattern: 35311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// {{Add|Copy|Run}* [AddChecksum] Output}* 36311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 37311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// When Output has been called in this sequence, a complete target window 38311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// (as defined in RFC 3284 section 4.3) will have been appended to 39311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// out (unless no calls to Add, Run, or Copy were made, in which 40311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// case Output will do nothing.) The output will not be available for use 41311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// until after each call to Output(). 42311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 43311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// NOT threadsafe. 44311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff// 45d18457863096b3685e56f5a8919959f6afbdb121openvcdiffclass VCDiffCodeTableWriter : public CodeTableWriterInterface { 46311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff public: 47311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // This constructor uses the default code table. 48311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // If interleaved is true, the encoder writes each delta file window 49311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // by interleaving instructions and sizes with their corresponding 50311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // addresses and data, rather than placing these elements into three 51311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // separate sections. This facilitates providing partially 52311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // decoded results when only a portion of a delta file window 53311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // is received (e.g. when HTTP over TCP is used as the 54311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // transmission protocol.) The interleaved format is 55311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // not consistent with the VCDIFF draft standard. 56311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 57311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff explicit VCDiffCodeTableWriter(bool interleaved); 58311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 59311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Uses a non-standard code table and non-standard cache sizes. The caller 60311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // must guarantee that code_table_data remains allocated for the lifetime of 61311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // the VCDiffCodeTableWriter object. Note that this is different from how 62311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // VCDiffCodeTableReader::UseCodeTable works. It is assumed that a given 63311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // encoder will use either the default code table or a statically-defined 64311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // non-standard code table, whereas the decoder must have the ability to read 65311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // an arbitrary non-standard code table from a delta file and discard it once 66311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // the file has been decoded. 67311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 68311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff VCDiffCodeTableWriter(bool interleaved, 69311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int near_cache_size, 70311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int same_cache_size, 71311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const VCDiffCodeTableData& code_table_data, 72311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned char max_mode); 73311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 74d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual ~VCDiffCodeTableWriter(); 75311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 76311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Initializes the constructed object for use. 77311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // This method must be called after a VCDiffCodeTableWriter is constructed 78311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // and before any of its other methods can be called. It will return 79311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // false if there was an error initializing the object, or true if it 80311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // was successful. After the object has been initialized and used, 81311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Init() can be called again to restore the initial state of the object. 82311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 83732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com virtual bool Init(size_t dictionary_size); 84732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com 85732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // Write the header (as defined in section 4.1 of the RFC) to *out. 86732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // This includes information that can be gathered 87732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // before the first chunk of input is available. 88732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com virtual void WriteHeader(OutputStringInterface* out, 89732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com VCDiffFormatExtensionFlags format_extensions); 90311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 91d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual size_t target_length() const { return target_length_; } 92311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 93311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Encode an ADD opcode with the "size" bytes starting at data 94d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual void Add(const char* data, size_t size); 95311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 96311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Encode a COPY opcode with args "offset" (into dictionary) and "size" bytes. 97d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual void Copy(int32_t offset, size_t size); 98311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 99311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Encode a RUN opcode for "size" copies of the value "byte". 100d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual void Run(size_t size, unsigned char byte); 101311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 102732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com virtual void AddChecksum(VCDChecksum checksum) { 103311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff add_checksum_ = true; 104311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff checksum_ = checksum; 105311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff } 106311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 107732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // Appends the encoded delta window to the output 108311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // string. The output string is not null-terminated and may contain embedded 109311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // '\0' characters. 110d18457863096b3685e56f5a8919959f6afbdb121openvcdiff virtual void Output(OutputStringInterface* out); 111311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 112732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // There should not be any need to output more data 113732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // since EncodeChunk() encodes a complete target window 114732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com // and there is no end-of-delta-file marker. 115732fff248e662ec47aa27c124632f406f27b6c8dopenvcdiff@gmail.com virtual void FinishEncoding(OutputStringInterface* /*out*/) {} 116311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 117311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff private: 11828db8079f707ebdf43ce62cdfd96eb39c8f889e0openvcdiff typedef std::string string; 11928db8079f707ebdf43ce62cdfd96eb39c8f889e0openvcdiff 120311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The maximum value for the mode of a COPY instruction. 121311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const unsigned char max_mode_; 122311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 123311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // If interleaved is true, sets data_for_add_and_run_ and 124311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // addresses_for_copy_ to point at instructions_and_sizes_, 125311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // so that instructions, sizes, addresses and data will be 126311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // combined into a single interleaved stream. 127311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // If interleaved is false, sets data_for_add_and_run_ and 128311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // addresses_for_copy_ to point at their corresponding 129311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // separate_... strings, so that the three sections will 130311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // be generated separately from one another. 131311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 132311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff void InitSectionPointers(bool interleaved); 133311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 134311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Determines the best opcode to encode an instruction, and appends 135311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // or substitutes that opcode and its size into the 136311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // instructions_and_sizes_ string. 137311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 138311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff void EncodeInstruction(VCDiffInstructionType inst, 139311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size_t size, 140311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned char mode); 141311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 142311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff void EncodeInstruction(VCDiffInstructionType inst, size_t size) { 143311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff return EncodeInstruction(inst, size, 0); 144311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff } 145311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 146311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Calculates the number of bytes needed to store the given size value as a 147311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // variable-length integer (VarintBE). 148311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff static size_t CalculateLengthOfSizeAsVarint(size_t size); 149311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 150311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Appends the size value to the string as a variable-length integer. 151311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff static void AppendSizeToString(size_t size, string* out); 152311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 153311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Appends the size value to the output string as a variable-length integer. 154311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff static void AppendSizeToOutputString(size_t size, OutputStringInterface* out); 155311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 156311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Calculates the "Length of the delta encoding" field for the delta window 157311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // header, based on the sizes of the sections and of the other header 158311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // elements. 159311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size_t CalculateLengthOfTheDeltaEncoding() const; 160311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 161311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // None of the following 'string' objects are null-terminated. 162311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 163311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // A series of instruction opcodes, each of which may be followed 164311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // by one or two Varint values representing the size parameters 165311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // of the first and second instruction in the opcode. 166311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string instructions_and_sizes_; 167311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 168311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // A series of data arguments (byte values) used for ADD and RUN 169311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // instructions. Depending on whether interleaved output is used 170311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // for streaming or not, the pointer may point to 171311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // separate_data_for_add_and_run_ or to instructions_and_sizes_. 172311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string *data_for_add_and_run_; 173311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string separate_data_for_add_and_run_; 174311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 175311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // A series of Varint addresses used for COPY instructions. 176311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // For the SAME mode, a byte value is stored instead of a Varint. 177311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Depending on whether interleaved output is used 178311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // for streaming or not, the pointer may point to 179311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // separate_addresses_for_copy_ or to instructions_and_sizes_. 180311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string *addresses_for_copy_; 181311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string separate_addresses_for_copy_; 182311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 183311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff VCDiffAddressCache address_cache_; 184311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 185311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size_t dictionary_size_; 186311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 187311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The number of bytes of target data that has been encoded so far. 188311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Each time Add(), Copy(), or Run() is called, this will be incremented. 189311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The target length is used to compute HERE mode addresses 190311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // for COPY instructions, and is also written into the header 191311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // of the delta window when Output() is called. 192311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 193311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size_t target_length_; 194311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 195311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const VCDiffCodeTableData* code_table_data_; 196311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 197311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The instruction map facilitates finding an opcode quickly given an 198311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // instruction inst, size, and mode. This is an alternate representation 199311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // of the same information that is found in code_table_data_. 200311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 201311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const VCDiffInstructionMap* instruction_map_; 202311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 203311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The zero-based index within instructions_and_sizes_ of the byte 204311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // that contains the last single-instruction opcode generated by 205311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // EncodeInstruction(). (See that function for exhaustive details.) 206311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // It is necessary to use an index rather than a pointer for this value 207311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // because instructions_and_sizes_ may be resized, which would invalidate 208311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // any pointers into its data buffer. The value -1 is reserved to mean that 209311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // either no opcodes have been generated yet, or else the last opcode 210311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // generated was a double-instruction opcode. 211311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 212311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int last_opcode_index_; 213311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 214311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // If true, an Adler32 checksum of the target window data will be written as 215311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // a variable-length integer, just after the size of the addresses section. 216311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 217311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff bool add_checksum_; 218311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 219311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // The checksum to be written to the current target window, 220311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // if add_checksum_ is true. 221311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // This will not be calculated based on the individual calls to Add(), Run(), 222311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // and Copy(), which would be unnecessarily expensive. Instead, the code 223311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // that uses the VCDiffCodeTableWriter object is expected to calculate 224311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // the checksum all at once and to call AddChecksum() with that value. 225311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Must be called sometime before calling Output(), though it can be called 226311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // either before or after the calls to Add(), Run(), and Copy(). 227311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // 228311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff VCDChecksum checksum_; 229311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 230311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff // Making these private avoids implicit copy constructor & assignment operator 231311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff VCDiffCodeTableWriter(const VCDiffCodeTableWriter&); // NOLINT 232311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff void operator=(const VCDiffCodeTableWriter&); 233311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff}; 234311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 235311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff}; // namespace open_vcdiff 236311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 237311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif // OPEN_VCDIFF_ENCODETABLE_H_ 238