CattleTape: Cattle Reference Manual

## CattleTape CattleTape — Infinite-length memory tape |

## Functions

CattleTape * | cattle_tape_new ()
void | cattle_tape_set_current_value ()
gint8 | cattle_tape_get_current_value ()
void | cattle_tape_increase_current_value ()
void | cattle_tape_increase_current_value_by ()
void | cattle_tape_decrease_current_value ()
void | cattle_tape_decrease_current_value_by ()
void | cattle_tape_move_left ()
void | cattle_tape_move_left_by ()
void | cattle_tape_move_right ()
void | cattle_tape_move_right_by ()
gboolean | cattle_tape_is_at_beginning ()
gboolean | cattle_tape_is_at_end ()
void | cattle_tape_push_bookmark ()
gboolean | cattle_tape_pop_bookmark ()

## Properties

gchar | current-value | Read / Write

## Types and Values

struct | CattleTape

## Object Hierarchy

        GObject
        ╰── CattleTape

## Includes

    #include <cattle/cattle.h>

## Description

A CattleTape represents an infinte-length memory tape, which is used by a CattleInterpreter to store its data. The tape contains a virtually infinte number of memory cells, each one able to store a single byte.

A tape supports three kinds of operations: reading the value of the current cell, updating the value of the current cell (either by increasing/decreasing it or by setting it to a certain value), and moving the current cell pointer (either to the left or to the right).

The tape grows automatically as more cells are needed, the only limit being the amount of available memory. It is possible to check if the current cell is at the beginning or at the end of the tape using `cattle_tape_is_at_beginning()` and `cattle_tape_is_at_end()`.

## Functions

### cattle_tape_new ()

    CattleTape *
    cattle_tape_new (void);

Create and initialize a new memory tape.

#### Returns

a new CattleTape.

[transfer full]

### cattle_tape_set_current_value ()

    void
    cattle_tape_set_current_value (CattleTape *tape,
                                   gint8 value);

Set the value of the current cell.

Accepted values range from `G_MININT8` to `G_MAXINT8`.

#### Parameters

tape | a CattleTape |
value | the current cell's new value |

### cattle_tape_get_current_value ()

    gint8
    cattle_tape_get_current_value (CattleTape *tape);

Get the value of the current cell. See `cattle_tape_set_current_value()`.

#### Parameters

tape | a CattleTape |

#### Returns

the value of the current cell

### cattle_tape_increase_current_value ()

    void
    cattle_tape_increase_current_value (CattleTape *tape);

Increase the value in the current cell by one.

#### Parameters

tape | a CattleTape |

### cattle_tape_increase_current_value_by ()

    void
    cattle_tape_increase_current_value_by (CattleTape *tape,
                                           gulong value);

Increase the value in the current cell by `value` .

Increasing the value this way is much faster than calling `cattle_tape_increase_current_value()` multiple times.

#### Parameters

tape | a CattleTape |
value | increase amount |

### cattle_tape_decrease_current_value ()

    void
    cattle_tape_decrease_current_value (CattleTape *tape);

Decrease the value in the current cell by one.

#### Parameters

tape | a CattleTape |

### cattle_tape_decrease_current_value_by ()

    void
    cattle_tape_decrease_current_value_by (CattleTape *tape,
                                           gulong value);

Decrease the value in the current cell by `value` .

Decreasing the value this way is much faster than calling `cattle_tape_decrease_current_value()` multiple times.

#### Parameters

tape | a CattleTape |
value | decrease amount |

### cattle_tape_move_left ()

    void
    cattle_tape_move_left (CattleTape *tape);

Move `tape` one cell to the left.

If there are no memory cells on the left of the current one, one will be created on the fly.

#### Parameters

tape | a CattleTape |

### cattle_tape_move_left_by ()

    void
    cattle_tape_move_left_by (CattleTape *tape,
                              gulong steps);

Move `tape` `steps` cells to the left.

Moving this way is much faster than calling `cattle_tape_move_left()` multiple times.

#### Parameters

tape | a CattleTape |
steps | number of steps |

### cattle_tape_move_right ()

    void
    cattle_tape_move_right (CattleTape *tape);

Move `tape` one cell to the right.

If there are no memory cells on the right of the current one, one will be created on the fly.

#### Parameters

tape | a CattleTape |

### cattle_tape_move_right_by ()

    void
    cattle_tape_move_right_by (CattleTape *tape,
                               gulong steps);

Move `tape` `steps` cells to the right.

Moving this way is much faster than calling `cattle_tape_move_right()` multiple times.

#### Parameters

tape | a CattleTape |
steps | number of steps |

### cattle_tape_is_at_beginning ()

    gboolean
    cattle_tape_is_at_beginning (CattleTape *tape);

Check if the current cell is the first one of `tape` .

Since the tape grows automatically as more cells are needed, it is possible to move left from the first cell.

#### Parameters

tape | a CattleTape |

#### Returns

`TRUE` if the current cell is the first one, `FALSE` otherwise

### cattle_tape_is_at_end ()

    gboolean
    cattle_tape_is_at_end (CattleTape *tape);

Check if the current cell is the last one of `tape` .

Since the tape grows automatically as more cells are needed, it is possible to move right from the last cell.

#### Parameters

tape | a CattleTape |

#### Returns

`TRUE` if the current cell is the last one, `FALSE` otherwise

### cattle_tape_push_bookmark ()

    void
    cattle_tape_push_bookmark (CattleTape *tape);

Create a bookmark to the current tape position and save it on the bookmark stack.

#### Parameters

tape | a CattleTape |

### cattle_tape_pop_bookmark ()

    gboolean
    cattle_tape_pop_bookmark (CattleTape *tape);

Restore the previously-saved tape position. See `cattle_tape_push_bookmark()`.

#### Parameters

tape | a CattleTape |

#### Returns

`FALSE` if the bookmarks stack is empty, `TRUE` otherwise

## Types and Values

### struct CattleTape

    struct CattleTape;

Opaque data structure representing a memory tape. It should never be accessed directly.

## Property Details

### The `“current-value”` property

      “current-value”            gchar

Value of the current cell.

Changes to this property are not notified.

Owner: CattleTape

Flags: Read / Write

Default value: 0