Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkSL::Position Class Reference

#include <SkSLPosition.h>

Public Member Functions

 Position ()
 
bool valid () const
 
int line (std::string_view source) const
 
int startOffset () const
 
int endOffset () const
 
Position rangeThrough (Position end) const
 
Position after () const
 
bool operator== (const Position &other) const
 
bool operator!= (const Position &other) const
 
bool operator> (const Position &other) const
 
bool operator>= (const Position &other) const
 
bool operator< (const Position &other) const
 
bool operator<= (const Position &other) const
 

Static Public Member Functions

static Position Range (int startOffset, int endOffset)
 

Static Public Attributes

static constexpr int kMaxOffset = 0x7FFFFF
 

Detailed Description

Definition at line 18 of file SkSLPosition.h.

Constructor & Destructor Documentation

◆ Position()

SkSL::Position::Position ( )
inline

Definition at line 20 of file SkSLPosition.h.

21 : fStartOffset(-1)
22 , fLength(0) {}

Member Function Documentation

◆ after()

Position SkSL::Position::after ( ) const
inline

Definition at line 62 of file SkSLPosition.h.

62 {
63 int endOffset = this->endOffset();
64 return Range(endOffset, endOffset + 1);
65 }
static Position Range(int startOffset, int endOffset)
int endOffset() const

◆ endOffset()

int SkSL::Position::endOffset ( ) const
inline

Definition at line 45 of file SkSLPosition.h.

45 {
46 SkASSERT(this->valid());
47 return fStartOffset + fLength;
48 }
#define SkASSERT(cond)
Definition SkAssert.h:116
bool valid() const

◆ line()

int SkSL::Position::line ( std::string_view  source) const

Definition at line 14 of file SkSLPosition.cpp.

14 {
15 SkASSERT(this->valid());
16 if (fStartOffset == -1) {
17 return -1;
18 }
19 if (!source.data()) {
20 return -1;
21 }
22 // we allow the offset to equal the length, because that's where TK_END_OF_FILE is reported
23 SkASSERT(fStartOffset <= (int)source.length());
24 int offset = std::min(fStartOffset, (int)source.length());
25 int line = 1;
26 for (int i = 0; i < offset; i++) {
27 if (source[i] == '\n') {
28 ++line;
29 }
30 }
31 return line;
32}
int line(std::string_view source) const
SkBitmap source
Definition examples.cpp:28
Point offset

◆ operator!=()

bool SkSL::Position::operator!= ( const Position other) const
inline

Definition at line 71 of file SkSLPosition.h.

71 {
72 return !(*this == other);
73 }

◆ operator<()

bool SkSL::Position::operator< ( const Position other) const
inline

Definition at line 83 of file SkSLPosition.h.

83 {
84 return fStartOffset < other.fStartOffset;
85 }

◆ operator<=()

bool SkSL::Position::operator<= ( const Position other) const
inline

Definition at line 87 of file SkSLPosition.h.

87 {
88 return fStartOffset <= other.fStartOffset;
89 }

◆ operator==()

bool SkSL::Position::operator== ( const Position other) const
inline

Definition at line 67 of file SkSLPosition.h.

67 {
68 return fStartOffset == other.fStartOffset && fLength == other.fLength;
69 }

◆ operator>()

bool SkSL::Position::operator> ( const Position other) const
inline

Definition at line 75 of file SkSLPosition.h.

75 {
76 return fStartOffset > other.fStartOffset;
77 }

◆ operator>=()

bool SkSL::Position::operator>= ( const Position other) const
inline

Definition at line 79 of file SkSLPosition.h.

79 {
80 return fStartOffset >= other.fStartOffset;
81 }

◆ Range()

static Position SkSL::Position::Range ( int  startOffset,
int  endOffset 
)
inlinestatic

Definition at line 24 of file SkSLPosition.h.

24 {
29 result.fStartOffset = startOffset;
30 result.fLength = length <= 0xFF ? length : 0xFF;
31 return result;
32 }
int startOffset() const
static constexpr int kMaxOffset
GAsyncResult * result
size_t length

◆ rangeThrough()

Position SkSL::Position::rangeThrough ( Position  end) const
inline

Definition at line 51 of file SkSLPosition.h.

51 {
52 if (fStartOffset == -1 || end.fStartOffset == -1) {
53 return *this;
54 }
55 SkASSERTF(this->startOffset() <= end.startOffset() && this->endOffset() <= end.endOffset(),
56 "Invalid range: (%d-%d) - (%d-%d)\n", this->startOffset(), this->endOffset(),
57 end.startOffset(), end.endOffset());
58 return Range(this->startOffset(), end.endOffset());
59 }
#define SkASSERTF(cond, fmt,...)
Definition SkAssert.h:117
glong glong end

◆ startOffset()

int SkSL::Position::startOffset ( ) const
inline

Definition at line 40 of file SkSLPosition.h.

40 {
41 SkASSERT(this->valid());
42 return fStartOffset;
43 }

◆ valid()

bool SkSL::Position::valid ( ) const
inline

Definition at line 34 of file SkSLPosition.h.

34 {
35 return fStartOffset != -1;
36 }

Member Data Documentation

◆ kMaxOffset

constexpr int SkSL::Position::kMaxOffset = 0x7FFFFF
staticconstexpr

Definition at line 91 of file SkSLPosition.h.


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