Class CCodePos#

Class Documentation#

class CCodePos#

Code string with position information.

Unnamed Group

void UpdateLocation(CToken &rtoken) const#

Update the length of the token with current position. Persists the code if composed from (part of) prepended code.

Parameters:

rtoken[inout] Reference to the token to be updated.

void UpdateLocation(CToken &rtoken, ETokenLiteralType eLiteralType) const#

Update the length of the token with current position. Persists the code if composed from (part of) prepended code.

Parameters:
  • rtoken[inout] Reference to the token to be updated.

  • eLiteralType[in] The literal type to be assigned to the token (if any).

void UpdateLocation(CToken &rtoken, ETokenMetaType eMetaType) const#

Update the length of the token with current position. Persists the code if composed from (part of) prepended code.

Parameters:
  • rtoken[inout] Reference to the token to be updated.

  • eMetaType[in] The meta type to be assigned to the token (if any).

void PrependCode(const std::string &rssCode)#

Insert code at the current position allowing to parse the prepended code.

This function prepends code at the current position. The code could be a macro expansion or precedence parsing.

Attention

This function might invalidate tokens that have a start location, but no fixed location.

Parameters:

rssCode[in] Reference to a string object representing the code to prepend

bool CurrentPositionInMacroExpansion() const#

Return whether the current position is part of the prepended code.

Returns:

Returns ‘true’ when the current position is within the prepended code; otherwise returns ‘false’.

CCodePos &operator=(const CCodePos &rCode)#

Assignment operator.

Parameters:

rCode[in] Reference to the code to copy.

Returns:

Returns reference to this class.

CCodePos &operator=(CCodePos &&rCode) noexcept#

Move operator.

Parameters:

rCode[in] Reference to the code to move.

Returns:

Returns reference to this class.

char operator[](uint32_t uiOffset) const#

Get current character (with offset)

Attention

The caller must make certain, that a valid character is available at the provided offset by interpreting the characters before.

Parameters:

uiOffset[in] The offset of the character to read relative to the current character.

Returns:

The current character or ‘\0’ when there is no current character.

char operator*() const#

Get current character.

Attention

The caller must make certain, that a valid character is available at the provided offset by interpreting the characters before.

Returns:

The current character or ‘\0’ when there is no current character.

operator const char*() const#

Get the code at the current position.

Attention

The caller must make certain, that a valid character is available at the provided offset by interpreting the characters before.

Returns:

Pointer to the code at the current location or nullptr when there is no code.

CCodePos operator++(int)#

Increment the current position.

Returns:

Copy of the code position before incrementation.

CCodePos &operator++()#

Increment the current position.

Returns:

Reference to this class.

CCodePos &operator+=(uint32_t uiOffset)#

Increment the current position.

Parameters:

uiOffset[in] The offset of the character to increment to.

Returns:

Reference to this class.

Unnamed Group

bool IsValid() const#

Is the code position class initialized correctly?

Returns:

Returns whether the class is initialized.

operator bool() const#

Is the code position class initialized correctly?

Returns:

Returns whether the class is initialized.

Public Functions

CCodePos()#

Default constructor.

Remark

Use the assignment operator to set the code to be covered by the code position class.

CCodePos(const char *szCode)#

Constructor.

Parameters:

szCode[in] Pointer to zero terminated string containing the IDL code. Must not be NULL.

CCodePos(const CCodePos &rCode)#

Copy constructor.

Parameters:

rCode[in] Reference to the code to copy.

CCodePos(CCodePos &&rCode) noexcept#

Move constructor.

Parameters:

rCode[in] Reference to the code to move.

void Reset()#

Reset the current navigation.

Attention

Any prepended code will be removed.

uint32_t GetLine() const#

Return the current line.

Returns:

The current line.

uint32_t GetCol() const#

Return the current column.

Returns:

The current column.

bool HasEOF() const#

Check for EOF.

Returns:

Returns ‘true’ when EOF has been reached. Otherwise returns ‘false’.

bool HasEOL() const#

Check for EOL.

Returns:

Returns ‘true’ when EOL has been reached. Otherwise returns ‘false’.

CToken GetLocation(ETokenType eTokenType = ETokenType::token_none) const#

Get the token at the current location.

Attention

The returned position is volatile and might be invalid as soon as code is prepended. Once the UpdateLocation has been called, the code is persistent.

Parameters:

eTokenType[in] The type of token this token is referring to.

Returns:

The token at the current location.