libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::List Class Reference

The List class represents a Scratch list. More...

#include <scratchcpp/list.h>

Inheritance diagram for libscratchcpp::List:
Collaboration diagram for libscratchcpp::List:

Public Member Functions

 List (const std::string &id, const std::string &name)
 
 List (const List &)=delete
 
 ~List ()
 
const std::string & name ()
 
void setName (const std::string &name)
 
Targettarget () const
 
void setTarget (Target *target)
 
Monitormonitor () const
 
void setMonitor (Monitor *monitor)
 
ValueDatadata () const
 
ValueData *const * dataPtr () const
 
size_t * sizePtr ()
 
const size_t * allocatedSizePtr () const
 
size_t size () const
 
bool empty () const
 
size_t indexOf (const ValueData &value) const
 
size_t indexOf (const Value &value) const
 
bool contains (const ValueData &value) const
 
bool contains (const Value &value) const
 
void clear ()
 
ValueDataappendEmpty ()
 
void append (const ValueData &value)
 
void append (const Value &value)
 
void removeAt (size_t index)
 
ValueDatainsertEmpty (size_t index)
 
void insert (size_t index, const ValueData &value)
 
void insert (size_t index, const Value &value)
 
void replace (size_t index, const ValueData &value)
 
void replace (size_t index, const Value &value)
 
ValueDataoperator[] (size_t index)
 
void toStringPtr (StringPtr *dst) const
 
std::string toString () const
 
std::shared_ptr< Listclone ()
 
const std::string & id () const
 
void setId (const std::string &newId)
 

Detailed Description

The List class represents a Scratch list.

Due to the high optimization of the methods, indices out of range will result in undefined behavior!

Constructor & Destructor Documentation

◆ List() [1/2]

List::List ( const std::string & id,
const std::string & name )

Constructs List.

◆ List() [2/2]

libscratchcpp::List::List ( const List & )
delete

◆ ~List()

List::~List ( )

Destroys List.

Member Function Documentation

◆ allocatedSizePtr()

const size_t * libscratchcpp::List::allocatedSizePtr ( ) const
inline

Returns a pointer to the allocated list size.

Note
This is used internally by compiled code for various optimizations.

◆ append() [1/2]

void libscratchcpp::List::append ( const Value & value)
inline

Appends an item.

◆ append() [2/2]

void libscratchcpp::List::append ( const ValueData & value)
inline

Appends an item.

◆ appendEmpty()

ValueData & libscratchcpp::List::appendEmpty ( )
inline

Appends an empty item and returns the reference to it. Can be used for custom initialization.

◆ clear()

void libscratchcpp::List::clear ( )
inline

Clears the list.

◆ clone()

std::shared_ptr< List > List::clone ( )

Creates a copy of the list.

◆ contains() [1/2]

bool libscratchcpp::List::contains ( const Value & value) const
inline

Returns true if the list contains the given item.

◆ contains() [2/2]

bool libscratchcpp::List::contains ( const ValueData & value) const
inline

Returns true if the list contains the given item.

◆ data()

ValueData * libscratchcpp::List::data ( ) const
inline

Returns a pointer to the raw list data.

◆ dataPtr()

ValueData *const * libscratchcpp::List::dataPtr ( ) const
inline

Returns a pointer to pointer to the raw list data.

Note
This is used internally by compiled code for various optimizations.

◆ empty()

bool libscratchcpp::List::empty ( ) const
inline

Returns true if the list is empty.

◆ id()

const std::string & Entity::id ( ) const
inherited

Returns the ID.

◆ indexOf() [1/2]

size_t libscratchcpp::List::indexOf ( const Value & value) const
inline

Returns the index of the given item.

◆ indexOf() [2/2]

size_t libscratchcpp::List::indexOf ( const ValueData & value) const
inline

Returns the index of the given item.

◆ insert() [1/2]

void libscratchcpp::List::insert ( size_t index,
const Value & value )
inline

Inserts an item at index.

◆ insert() [2/2]

void libscratchcpp::List::insert ( size_t index,
const ValueData & value )
inline

Inserts an item at index.

◆ insertEmpty()

ValueData & libscratchcpp::List::insertEmpty ( size_t index)
inline

Inserts an empty item at index and returns the reference to it. Can be used for custom initialization.

◆ monitor()

Monitor * List::monitor ( ) const

Returns the monitor of this list.

◆ name()

const std::string & List::name ( )

Returns the name of the list.

◆ operator[]()

ValueData & libscratchcpp::List::operator[] ( size_t index)
inline

◆ removeAt()

void libscratchcpp::List::removeAt ( size_t index)
inline

Removes the item at index.

◆ replace() [1/2]

void libscratchcpp::List::replace ( size_t index,
const Value & value )
inline

Replaces the item at index.

◆ replace() [2/2]

void libscratchcpp::List::replace ( size_t index,
const ValueData & value )
inline

Replaces the item at index.

◆ setId()

void Entity::setId ( const std::string & newId)
inherited

Sets the ID.

◆ setMonitor()

void List::setMonitor ( Monitor * monitor)

Sets the monitor of this list.

◆ setName()

void List::setName ( const std::string & name)

Sets the name of the list.

◆ setTarget()

void List::setTarget ( Target * target)

Sets the sprite or stage this list belongs to.

◆ size()

size_t libscratchcpp::List::size ( ) const
inline

Returns the list size.

◆ sizePtr()

size_t * libscratchcpp::List::sizePtr ( )
inline

Returns a pointer to the list size.

Note
This is used internally by compiled code for various optimizations.

◆ target()

Target * List::target ( ) const

Returns the sprite or stage this list belongs to.

◆ toString()

std::string List::toString ( ) const

Same as the other method, but returns the result as std::string.

◆ toStringPtr()

void libscratchcpp::List::toStringPtr ( StringPtr * dst) const
inline

Joins the list items with spaces or without any separator if there are only digits and returns the result as StringPtr.


The documentation for this class was generated from the following files: