13#ifndef LLVM_CLANG_REWRITE_CORE_REWRITEROPE_H
14#define LLVM_CLANG_REWRITE_CORE_REWRITEROPE_H
16#include "llvm/ADT/IntrusiveRefCntPtr.h"
17#include "llvm/ADT/StringRef.h"
40 assert(
RefCount > 0 &&
"Reference count is already zero.");
42 delete [] (
char*)
this;
88 const void *CurNode =
nullptr;
108 return (*CurPiece)[CurChar];
112 return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar;
119 if (CurChar+1 < CurPiece->
size())
131 return llvm::StringRef(&(*CurPiece)[0], CurPiece->
size());
154 unsigned size()
const;
177 enum { AllocChunkSize = 4080 };
178 unsigned AllocOffs = AllocChunkSize;
195 void assign(
const char *Start,
const char *End) {
198 Chunks.
insert(0, MakeRopeString(Start, End));
202 assert(
Offset <=
size() &&
"Invalid position to insert!");
203 if (Start == End)
return;
208 assert(
Offset+NumBytes <=
size() &&
"Invalid region to erase!");
209 if (NumBytes == 0)
return;
214 RopePiece MakeRopeString(
const char *Start,
const char *End);
RewriteRope - A powerful string class.
RewriteRope(const RewriteRope &RHS)
void erase(unsigned Offset, unsigned NumBytes)
void assign(const char *Start, const char *End)
void insert(unsigned Offset, const char *Start, const char *End)
RopePieceBTreeIterator - This class provides read-only forward iteration over bytes that are in a Rop...
std::ptrdiff_t difference_type
bool operator!=(const RopePieceBTreeIterator &RHS) const
std::forward_iterator_tag iterator_category
RopePieceBTreeIterator operator++(int)
RopePieceBTreeIterator & operator++()
bool operator==(const RopePieceBTreeIterator &RHS) const
llvm::StringRef piece() const
RopePieceBTreeIterator()=default
RopePieceBTreeIterator iterator
void insert(unsigned Offset, const RopePiece &R)
void erase(unsigned Offset, unsigned NumBytes)
RopePieceBTree & operator=(const RopePieceBTree &)=delete
RopePiece - This class represents a view into a RopeRefCountString object.
const char & operator[](unsigned Offset) const
llvm::IntrusiveRefCntPtr< RopeRefCountString > StrData
RopePiece(llvm::IntrusiveRefCntPtr< RopeRefCountString > Str, unsigned Start, unsigned End)
char & operator[](unsigned Offset)
RopeRefCountString - This struct is allocated with 'new char[]' from the heap, and represents a refer...