Toy 1.1.6
The Toy programming language is an imperative bytecode-intermediate embedded scripting language
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
toy_refstring.h File Reference

@???@ More...

#include <string.h>
#include <stdbool.h>
#include <stddef.h>
#include "toy_common.h"

Go to the source code of this file.

Data Structures

struct  Toy_RefString
 

Typedefs

typedef void *(* Toy_RefStringAllocatorFn) (void *pointer, size_t oldSize, size_t newSize)
 Prototype for interface conforms to Toy's memory API, and generally shouldn't be used.
 
typedef struct Toy_RefString Toy_RefString
 @???@
 

Functions

TOY_API void Toy_setRefStringAllocatorFn (Toy_RefStringAllocatorFn)
 Conforms to and is invoked by Toy's memory API, and generally shouldn't be used.
 
TOY_API Toy_RefString * Toy_createRefString (const char *cstring)
 Wraps Toy_CreateRefStringLength, by determining the length of the given cstring and passing it to the other function.
 
TOY_API Toy_RefString * Toy_createRefStringLength (const char *cstring, size_t length)
 Returns a new Toy_RefString, containing a copy of cstring, or NULL on error. This function also sets the returned refstring's reference counter to 1.
 
TOY_API void Toy_deleteRefString (Toy_RefString *refString)
 Reduces the refString's reference counter by 1 and, if it reaches 0, frees the memory.
 
TOY_API int Toy_countRefString (Toy_RefString *refString)
 Returns the total number of references to refString, for debugging.
 
TOY_API size_t Toy_lengthRefString (Toy_RefString *refString)
 Returns the length of the underlying cstring of refString.
 
TOY_API Toy_RefString * Toy_copyRefString (Toy_RefString *refString)
 Increases the reference counter of refString by 1, before returning the given pointer.
 
TOY_API Toy_RefString * Toy_deepCopyRefString (Toy_RefString *refString)
 Behaves identically to Toy_copyRefString, except that it explicitly preforms a deep copy of the internal memory. Using this function should be done carefully, as it incurs a performance penalty that negates the benefit of this module.
 
TOY_API const char * Toy_toCString (Toy_RefString *refString)
 Exposes the interal cstring of refString. Only use this function when dealing with external APIs.
 
TOY_API bool Toy_equalsRefString (Toy_RefString *lhs, Toy_RefString *rhs)
 Returns true when the two refstrings are either the same refstring, or contain the same value. Otherwise it returns false.
 
TOY_API bool Toy_equalsRefStringCString (Toy_RefString *lhs, char *cstring)
 Returns true when the refString contains the same value as the cstring. Otherwise it returns false.
 

Detailed Description

@???@

Typedef Documentation

◆ Toy_RefString

@???@

◆ Toy_RefStringAllocatorFn

void *(* Toy_RefStringAllocatorFn)(void *pointer, size_t oldSize, size_t newSize)

Prototype for interface conforms to Toy's memory API, and generally shouldn't be used.

Parameters
pointer
oldSize
newSize

Function Documentation

◆ Toy_copyRefString()

Toy_RefString * Toy_copyRefString ( Toy_RefString *  refString)

Increases the reference counter of refString by 1, before returning the given pointer.

Parameters
refString
Returns

◆ Toy_countRefString()

int Toy_countRefString ( Toy_RefString *  refString)

Returns the total number of references to refString, for debugging.

Parameters
refString
Returns

◆ Toy_createRefString()

Toy_RefString * Toy_createRefString ( const char *  cstring)

Wraps Toy_CreateRefStringLength, by determining the length of the given cstring and passing it to the other function.

Parameters
cstring
Returns

◆ Toy_createRefStringLength()

Toy_RefString * Toy_createRefStringLength ( const char *  cstring,
size_t  length 
)

Returns a new Toy_RefString, containing a copy of cstring, or NULL on error. This function also sets the returned refstring's reference counter to 1.

Parameters
cstring
length
Returns

◆ Toy_deepCopyRefString()

Toy_RefString * Toy_deepCopyRefString ( Toy_RefString *  refString)

Behaves identically to Toy_copyRefString, except that it explicitly preforms a deep copy of the internal memory. Using this function should be done carefully, as it incurs a performance penalty that negates the benefit of this module.

Parameters
refString
Returns

◆ Toy_deleteRefString()

void Toy_deleteRefString ( Toy_RefString *  refString)

Reduces the refString's reference counter by 1 and, if it reaches 0, frees the memory.

Parameters
refString

◆ Toy_equalsRefString()

bool Toy_equalsRefString ( Toy_RefString *  lhs,
Toy_RefString *  rhs 
)

Returns true when the two refstrings are either the same refstring, or contain the same value. Otherwise it returns false.

Parameters
lhs
rhs
Returns

◆ Toy_equalsRefStringCString()

bool Toy_equalsRefStringCString ( Toy_RefString *  lhs,
char *  cstring 
)

Returns true when the refString contains the same value as the cstring. Otherwise it returns false.

Parameters
lhs
cstring
Returns

◆ Toy_lengthRefString()

size_t Toy_lengthRefString ( Toy_RefString *  refString)

Returns the length of the underlying cstring of refString.

Parameters
refString
Returns

◆ Toy_setRefStringAllocatorFn()

void Toy_setRefStringAllocatorFn ( Toy_RefStringAllocatorFn  )

Conforms to and is invoked by Toy's memory API, and generally shouldn't be used.

Parameters
Toy_RefStringAllocatorFn

◆ Toy_toCString()

const char * Toy_toCString ( Toy_RefString *  refString)

Exposes the interal cstring of refString. Only use this function when dealing with external APIs.

Parameters
refString
Returns