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;
60 unsigned StartOffs = 0;
66 : StrData(
std::move(Str)), StartOffs(Start), EndOffs(End) {}
69 return StrData->Data[Offset+StartOffs];
72 return StrData->Data[Offset+StartOffs];
75 unsigned size()
const {
return EndOffs-StartOffs; }
87 public std::iterator<std::forward_iterator_tag, const char, ptrdiff_t> {
89 const void *CurNode =
nullptr;
103 return (*CurPiece)[CurChar];
107 return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar;
114 if (CurChar+1 < CurPiece->
size())
126 return llvm::StringRef(&(*CurPiece)[0], CurPiece->
size());
129 void MoveToNextPiece();
149 unsigned size()
const;
150 unsigned empty()
const {
return size() == 0; }
156 void erase(
unsigned Offset,
unsigned NumBytes);
172 enum { AllocChunkSize = 4080 };
173 unsigned AllocOffs = AllocChunkSize;
193 Chunks.
insert(0, MakeRopeString(Start, End));
197 assert(Offset <= size() &&
"Invalid position to insert!");
198 if (Start == End)
return;
199 Chunks.
insert(Offset, MakeRopeString(Start, End));
203 assert(Offset+NumBytes <= size() &&
"Invalid region to erase!");
204 if (NumBytes == 0)
return;
205 Chunks.
erase(Offset, NumBytes);
209 RopePiece MakeRopeString(
const char *Start,
const char *
End);
214 #endif // LLVM_CLANG_REWRITE_CORE_REWRITEROPE_H void insert(unsigned Offset, const char *Start, const char *End)
bool operator==(CanQual< T > x, CanQual< U > y)
void insert(unsigned Offset, const RopePiece &R)
RewriteRope - A powerful string class.
llvm::StringRef piece() const
void erase(unsigned Offset, unsigned NumBytes)
RopePieceBTreeIterator & operator++()
RopeRefCountString - This struct is allocated with 'new char[]' from the heap, and represents a refer...
const char & operator[](unsigned Offset) const
RopePiece - This class represents a view into a RopeRefCountString object.
llvm::IntrusiveRefCntPtr< RopeRefCountString > StrData
void erase(unsigned Offset, unsigned NumBytes)
RewriteRope(const RewriteRope &RHS)
RopePieceBTreeIterator iterator
RopePiece(llvm::IntrusiveRefCntPtr< RopeRefCountString > Str, unsigned Start, unsigned End)
Dataflow Directional Tag Classes.
RopePieceBTreeIterator - This class provides read-only forward iteration over bytes that are in a Rop...
bool operator==(const RopePieceBTreeIterator &RHS) const
void assign(const char *Start, const char *End)
char & operator[](unsigned Offset)
RopePieceBTreeIterator operator++(int)
bool operator!=(const RopePieceBTreeIterator &RHS) const