LangTag.String

Fields

None

Methods

class

new (string)

append (str)

append_c (c)

at (pos)

clear ()

free (free_segment)

length ()

ref ()

replace_c (pos, c)

truncate (len)

unref ()

value ()

Details

class LangTag.String

All the fields in the LangTag.String structure are private to the LangTag.String implementation.

classmethod new(string)
Parameters:

string (str) – an initial string to set

Returns:

a new instance of LangTag.String.

Return type:

LangTag.String

Creates an instance of LangTag.String with string.

append(str)
Parameters:

str (str) – the string to append onto the end of self

Returns:

the same self object

Return type:

LangTag.String

Adds a string onto the end of a LangTag.String, expanding it if necessary.

append_c(c)
Parameters:

c (int) – the byte to append onto the end of self

Returns:

the same self object.

Return type:

LangTag.String

Adds a byte onto the end of a LangTag.String, expanding it if necessary.

at(pos)
Parameters:

pos (int) – position in self where to obtain the byte

Returns:

the byte in self at pos

Return type:

int

Obtain a byte in a LangTag.String at pos. If pos is a negative, the position is calculated from current size. i.e. if the buffer contains “abc”, and pos is -1, this will returns ‘c’ then.

clear()

Clean up the buffer in self.

free(free_segment)
Parameters:

free_segment (int) – if True, the actual character data is freed as well

Returns:

the character data of self (i.e. None if free_segment is True)

Return type:

str

Frees the memory allocated for the LangTag.String. If free_segment is True it also frees the character data. If it’s False, the caller gains ownership of the buffer and must free it after use with free().

length()
Returns:

the number of characters

Return type:

int

Returns the number of characters in buffer for self.

ref()
Returns:

the same self object.

Return type:

LangTag.String

Increases the reference count of self.

replace_c(pos, c)
Parameters:
  • pos (int) – position in self where replacement should happen

  • c (int) – the byte to replace

Returns:

the same self object

Return type:

LangTag.String

Replaces a character in self at pos.

truncate(len)
Parameters:

len (int) –

Return type:

LangTag.String

unref()

Decreases the reference count of self. when its reference count drops to 0, the object is finalized (i.e. its memory is freed).

value()
Returns:

a string which self has.

Return type:

str

Returns the buffer in self.