6 #ifndef _INC_cTextPos_H
7 #define _INC_cTextPos_H
38 , m_iLineNum(iLineNum)
52 return(m_lOffset == 0 && m_iLineNum == 0);
58 return(m_iLineNum >= 0);
67 return this->m_iLineNum;
71 return this->m_iLineNum + 1;
75 return this->m_iColNum + 1;
80 m_lOffset += nLenOffsetSrc;
81 m_iColNum += nLenOffsetSrc;
86 m_lOffset += nLenOffsetSrc;
92 m_lOffset += nLenChar;
98 m_lOffset += nLenChar;
122 , m_pszStart(pszStart)
124 , m_iTabSize(nTabSize)
134 if (m_nLenMax < (
StrLen_t)m_lOffset)
136 return m_nLenMax - (
StrLen_t)m_lOffset;
140 return ((UINT)m_lOffset) < (UINT)m_nLenMax;
145 return m_pszStart !=
nullptr && isValidIndex();
150 return m_pszStart + this->m_lOffset;
154 ASSERT(m_pszStart !=
nullptr);
157 return m_pszStart[this->m_lOffset];
166 char ch = get_CursorChar();
174 m_lOffset += nLenChar;
178 m_iColNum = (m_iColNum / m_iTabSize + 1) * m_iTabSize;
185 if (get_CursorChar() ==
'\n')
187 m_lOffset += nLenChar;
195 return(get_CursorChar() ==
'\0');
200 m_pszStart = pszStart;
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define ASSERT(exp)
Definition: cDebugAssert.h:87
static const StrLen_t k_TabSize
default desired spaces for a tab.
Definition: StrConst.h:47
Definition: cTextPos.h:18
ITERATE_t get_LineNum() const noexcept
< Get 0 based line.
Definition: cTextPos.h:65
void IncLine(StrLen_t nLenChar=1) noexcept
Definition: cTextPos.h:95
bool isTopLine() const noexcept
Definition: cTextPos.h:49
static const cTextPos k_Zero
Top of file.
Definition: cTextPos.h:27
StrLen_t get_Column1() const noexcept
< Get 1 based column.
Definition: cTextPos.h:73
void IncChar(StrLen_t nLenChar=1) noexcept
Definition: cTextPos.h:89
void InitTop() noexcept
Definition: cTextPos.h:43
ITERATE_t m_iLineNum
0 based row/line, for debug purposes if there is an error.
Definition: cTextPos.h:31
static const cTextPos k_Invalid
Set to invalid values.
Definition: cTextPos.h:26
void IncOffset(StrLen_t nLenOffsetSrc) noexcept
Definition: cTextPos.h:78
STREAM_POS_t get_Offset() const noexcept
Definition: cTextPos.h:60
StrLen_t m_iColNum
0 based column number. if used. # of characters, not bytes. UTF can have multi bytes per char.
Definition: cTextPos.h:32
STREAM_POS_t m_lOffset
byte offset into the file. 0 based
Definition: cTextPos.h:30
void IncOffset(StrLen_t nLenOffsetSrc, StrLen_t nLenCol) noexcept
Definition: cTextPos.h:83
ITERATE_t get_Line1() const noexcept
< Get 1 based line.
Definition: cTextPos.h:69
bool isValidPos() const noexcept
Definition: cTextPos.h:55
cTextPos(STREAM_POS_t lOffset=(STREAM_POS_t) k_ITERATE_BAD, ITERATE_t iLineNum=k_ITERATE_BAD, StrLen_t iColNum=k_StrLen_UNK) noexcept
Definition: cTextPos.h:36
Definition: cTextPos.h:107
StrLen_t get_LenMax() const noexcept
Definition: cTextPos.h:128
const char * get_CursorPtr() const noexcept
Definition: cTextPos.h:147
char get_CursorChar() const noexcept
Definition: cTextPos.h:152
void IncToks(StrLen_t nLen=1)
Definition: cTextPos.h:160
bool isValidIndex() const noexcept
Definition: cTextPos.h:138
bool isEOF() const
Definition: cTextPos.h:193
cTextReader(const char *pszStart, StrLen_t nLenMax=StrT::k_LEN_MAX, StrLen_t nTabSize=cStrConst::k_TabSize)
Definition: cTextPos.h:120
const char * m_pszStart
starting read position in the data parsing stream/buffer. cTextPos cursor = m_pszStart + m_lOffset.
Definition: cTextPos.h:113
StrLen_t m_nLenMax
don't advance cTextPos::m_lOffset past this.
Definition: cTextPos.h:114
StrLen_t get_LenRemaining() const noexcept
Definition: cTextPos.h:132
bool isValidPos() const noexcept
Definition: cTextPos.h:142
void SetStartPtr(const char *pszStart, StrLen_t nLenMax=StrT::k_LEN_MAX)
Definition: cTextPos.h:198
const StrLen_t m_iTabSize
for proper tracking of the column number on errors. and m_CursorPos. 0 = not used/don't care.
Definition: cTextPos.h:117
void IncTab(StrLen_t nLenChar=1)
Definition: cTextPos.h:171
StrLen_t IncLineCR(StrLen_t nLenChar=1)
Definition: cTextPos.h:180
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
const StrLen_t k_StrLen_UNK
use the default/current length of the string argument.
Definition: StrConst.h:34
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
int ITERATE_t
like size_t but signed
Definition: Index.h:28
ULONG_PTR STREAM_POS_t
NOT same as FILE_SIZE_t in 32 bit. Why not ?
Definition: cOSHandle.h:54
const ITERATE_t k_ITERATE_BAD
Definition: Index.h:30
static bool IsSpaceX(wchar_t ch) noexcept
Definition: StrChar.h:94
static const StrLen_t k_LEN_MAX
arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384
Definition: StrT.h:75