StringPosition Class Reference

#include <string.h>

Inheritance diagram for StringPosition:

Detailed Description

Class to store the position in a string for a string operation. StringPosition just consists of an integer value. If it is positive, it indicates the absolute position. If it is negative it indicates the position from the end, e.g. -1 refers to the last character.

Here an example for GetPart. The first parameter of GetPart is the class StringPosition, the second StringCount.

res = str.GetPart(4, 3); // copy from position 4 on 3 characters
res = str.GetPart(-4, 3); // copy from the position that is 4 characters from the end of the string on 3 characters
void * str
Definition: bytesobject.h:77
Py_UCS4 * res
Definition: unicodeobject.h:1113

Public Member Functions

MAXON_IMPLICIT StringPosition (Int pos)
 
MAXON_ATTRIBUTE_FORCE_INLINE Int ResolvePosition (Int length) const
 

Protected Attributes

Int _value
 

Friends

class StringCount
 

Constructor & Destructor Documentation

◆ StringPosition()

Constructor.

Parameters
[in]posIf pos is >= 0 it designates the absolute position. If pos is negative it relative to the end. E.g. -1 refers to the last character.

Member Function Documentation

◆ ResolvePosition()

MAXON_ATTRIBUTE_FORCE_INLINE Int ResolvePosition ( Int  length) const

Calculates the absolute position in a string based on the contents of this class and a given string length.

Parameters
[in]lengthThe length of the string.
Returns
The absolute position in the string.

Friends And Related Function Documentation

◆ StringCount

friend class StringCount
friend

Member Data Documentation

◆ _value

Int _value
protected