14 #ifndef LLVM_CLANG_REWRITE_CORE_REWRITEROPE_H 15 #define LLVM_CLANG_REWRITE_CORE_REWRITEROPE_H 17 #include "llvm/ADT/IntrusiveRefCntPtr.h" 18 #include "llvm/ADT/StringRef.h" 41 assert(RefCount > 0 &&
"Reference count is already zero.");
43 delete [] (
char*)
this;
61 unsigned StartOffs = 0;
67 : StrData(
std::move(Str)), StartOffs(Start), EndOffs(End) {}
70 return StrData->Data[Offset+StartOffs];
73 return StrData->Data[Offset+StartOffs];
76 unsigned size()
const {
return EndOffs-StartOffs; }
88 public std::iterator<std::forward_iterator_tag, const char, ptrdiff_t> {
90 const void *CurNode =
nullptr;
104 return (*CurPiece)[CurChar];
108 return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar;
115 if (CurChar+1 < CurPiece->
size())
127 return llvm::StringRef(&(*CurPiece)[0], CurPiece->
size());
130 void MoveToNextPiece();
150 unsigned size()
const;
151 unsigned empty()
const {
return size() == 0; }
157 void erase(
unsigned Offset,
unsigned NumBytes);
173 enum { AllocChunkSize = 4080 };
174 unsigned AllocOffs = AllocChunkSize;
194 Chunks.
insert(0, MakeRopeString(Start, End));
198 assert(Offset <= size() &&
"Invalid position to insert!");
199 if (Start == End)
return;
200 Chunks.
insert(Offset, MakeRopeString(Start, End));
204 assert(Offset+NumBytes <= size() &&
"Invalid region to erase!");
205 if (NumBytes == 0)
return;
206 Chunks.
erase(Offset, NumBytes);
210 RopePiece MakeRopeString(
const char *Start,
const char *
End);
215 #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