Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
SkPlainTextEditor::StringSlice Class Reference

#include <stringslice.h>

Public Member Functions

 StringSlice ()=default
 
 StringSlice (const char *s, std::size_t l)
 
 StringSlice (StringSlice &&)
 
 StringSlice (const StringSlice &that)
 
 ~StringSlice ()=default
 
StringSliceoperator= (StringSlice &&)
 
StringSliceoperator= (const StringSlice &)
 
const char * begin () const
 
const char * end () const
 
std::size_t size () const
 
SkPlainTextEditor::StringView view () const
 
void insert (std::size_t offset, const char *text, std::size_t length)
 
void remove (std::size_t offset, std::size_t length)
 
void reserve (std::size_t size)
 
void shrink ()
 

Detailed Description

Definition at line 13 of file stringslice.h.

Constructor & Destructor Documentation

◆ StringSlice() [1/4]

SkPlainTextEditor::StringSlice::StringSlice ( )
default

◆ StringSlice() [2/4]

SkPlainTextEditor::StringSlice::StringSlice ( const char *  s,
std::size_t  l 
)
inline

Definition at line 16 of file stringslice.h.

16{ this->insert(0, s, l); }
void insert(std::size_t offset, const char *text, std::size_t length)
struct MyStruct s

◆ StringSlice() [3/4]

StringSlice::StringSlice ( StringSlice &&  that)

Definition at line 15 of file stringslice.cpp.

16 : fPtr(std::move(that.fPtr))
17 , fLength(that.fLength)
18 , fCapacity(that.fCapacity)
19{
20 that.fLength = 0;
21 that.fCapacity = 0;
22}

◆ StringSlice() [4/4]

SkPlainTextEditor::StringSlice::StringSlice ( const StringSlice that)
inline

Definition at line 18 of file stringslice.h.

18: StringSlice(that.begin(), that.size()) {}

◆ ~StringSlice()

SkPlainTextEditor::StringSlice::~StringSlice ( )
default

Member Function Documentation

◆ begin()

const char * SkPlainTextEditor::StringSlice::begin ( ) const
inline

Definition at line 25 of file stringslice.h.

25{ return fPtr.get(); }

◆ end()

const char * SkPlainTextEditor::StringSlice::end ( ) const
inline

Definition at line 26 of file stringslice.h.

26{ return fPtr ? fPtr.get() + fLength : nullptr; }

◆ insert()

void StringSlice::insert ( std::size_t  offset,
const char *  text,
std::size_t  length 
)

Definition at line 42 of file stringslice.cpp.

42 {
43 if (length) {
44 offset = std::min(fLength, offset);
45 this->reserve(fLength + length);
46 char* s = fPtr.get();
47 assert(s);
48 if (offset != fLength) {
49 std::memmove(s + offset + length, s + offset, fLength - offset);
50 }
51 if (text) {
52 std::memcpy(s + offset, text, length);
53 } else {
54 std::memset(s + offset, 0, length);
55 }
56 fLength += length;
57 }
58}
void reserve(std::size_t size)
Definition stringslice.h:35
size_t length
std::u16string text
Point offset

◆ operator=() [1/2]

StringSlice & StringSlice::operator= ( const StringSlice that)

Definition at line 32 of file stringslice.cpp.

32 {
33 if (this != &that) {
34 fLength = 0;
35 if (that.size() > 0) {
36 this->insert(0, that.begin(), that.size());
37 }
38 }
39 return *this;
40}
std::size_t size() const
Definition stringslice.h:27
const char * begin() const
Definition stringslice.h:25

◆ operator=() [2/2]

StringSlice & StringSlice::operator= ( StringSlice &&  that)

Definition at line 24 of file stringslice.cpp.

24 {
25 if (this != &that) {
26 this->~StringSlice();
27 new (this)StringSlice(std::move(that));
28 }
29 return *this;
30}

◆ remove()

void StringSlice::remove ( std::size_t  offset,
std::size_t  length 
)

Definition at line 60 of file stringslice.cpp.

60 {
61 if (length && offset < fLength) {
62 length = std::min(length, fLength - offset);
63 assert(length > 0);
64 assert(length + offset <= fLength);
65 if (length + offset < fLength) {
66 char* s = fPtr.get();
67 assert(s);
68 std::memmove(s + offset, s + offset + length, fLength - (length + offset));
69 }
70 fLength -= length;
71 }
72}

◆ reserve()

void SkPlainTextEditor::StringSlice::reserve ( std::size_t  size)
inline

Definition at line 35 of file stringslice.h.

35{ if (size > fCapacity) { this->realloc(size); } }

◆ shrink()

void SkPlainTextEditor::StringSlice::shrink ( )
inline

Definition at line 36 of file stringslice.h.

36{ this->realloc(fLength); }

◆ size()

std::size_t SkPlainTextEditor::StringSlice::size ( ) const
inline

Definition at line 27 of file stringslice.h.

27{ return fLength; }

◆ view()

SkPlainTextEditor::StringView SkPlainTextEditor::StringSlice::view ( ) const
inline

Definition at line 28 of file stringslice.h.

28{ return {fPtr.get(), fLength}; }

The documentation for this class was generated from the following files: