Home | History | Annotate | Download | only in bsdiff
      1 // Copyright 2017 The Chromium OS Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef _BSDIFF_SUFFIX_ARRAY_INDEX_INTERFACE_H_
      6 #define _BSDIFF_SUFFIX_ARRAY_INDEX_INTERFACE_H_
      7 
      8 // The SuffixArrayIndexInterface encapsulates a search index based on a
      9 // suffix-array with a common string search interface. The implementations of
     10 // this index can vary on technical details, such as the size of the internal
     11 // suffix array elements, which are not visible in this interface.
     12 
     13 #include <stddef.h>
     14 #include <stdint.h>
     15 
     16 namespace bsdiff {
     17 
     18 class SuffixArrayIndexInterface {
     19  public:
     20   virtual ~SuffixArrayIndexInterface() = default;
     21 
     22   // Search in the index the longest prefix of the string |target| of length
     23   // |length|. The length of the longest prefix found, which could be 0, is
     24   // stored in |out_length| and a position in the source text where this prefix
     25   // was found is store in |out_pos|.
     26   virtual void SearchPrefix(const uint8_t* target,
     27                             size_t length,
     28                             size_t* out_length,
     29                             uint64_t* out_pos) const = 0;
     30 
     31  protected:
     32   SuffixArrayIndexInterface() = default;
     33 };
     34 
     35 }  // namespace bsdiff
     36 
     37 #endif  // _BSDIFF_SUFFIX_ARRAY_INDEX_INTERFACE_H_
     38