Mapper  0.9.0
API documentation
Macros | Functions
string.c File Reference

(f662771 on 7 Mar 2013)

#include <string.h>
#include "libocad.h"
Include dependency graph for string.c:

Macros

#define F_TEMPL   "\ts%d\tx%d\ty%d\ta%lg\tu%lg\tv%lg\td%d\tp%d\tt%d\to%d"
 

Functions

int ocad_to_background (OCADBackground *bg, OCADCString *templ)
 Converts an OCAD string of the correct type into an OCADBackground structure. More...
 
int ocad_string_size_background (OCADBackground *bg)
 
void ocad_background_to_string (char *buf, int size, OCADBackground *bg)
 
OCADStringIndex * ocad_string_index_first (OCADFile *pfile)
 Returns a pointer to the first string index block, or nullptr if the file isn't valid. More...
 
OCADStringIndex * ocad_string_index_next (OCADFile *pfile, OCADStringIndex *current)
 Returns a pointer to the next string index block after the given one, or nullptr if there is none. More...
 
OCADStringEntry * ocad_string_entry_at (OCADFile *pfile, OCADStringIndex *current, int index)
 Returns a pointer to the given string index entry, or nullptr if the file isn't valid. More...
 
OCADStringEntry * ocad_string_entry_new (OCADFile *pfile, u32 size)
 Creates a new string entry large enough to fit the specified number of bytes. More...
 
int ocad_string_remove (OCADFile *pfile, OCADStringEntry *entry)
 Removes the string at the given entry. More...
 
bool ocad_string_entry_iterate (OCADFile *pfile, OCADStringEntryCallback callback, void *param)
 Iterates over all string entries in the file. More...
 
OCADCString * ocad_string_at (OCADFile *pfile, OCADStringIndex *current, int index)
 Returns a pointer to the string in the specified location within the index block, or nullptr if there is no such string. More...
 
OCADCString * ocad_string (OCADFile *pfile, OCADStringEntry *entry)
 Returns a pointer to a string, given a valid pointer to its index entry. More...
 
int ocad_string_add_background (OCADFile *pfile, OCADBackground *bg)
 Adds a background template to the file. More...
 

Macro Definition Documentation

◆ F_TEMPL

#define F_TEMPL   "\ts%d\tx%d\ty%d\ta%lg\tu%lg\tv%lg\td%d\tp%d\tt%d\to%d"

Function Documentation

◆ ocad_background_to_string()

void ocad_background_to_string ( char *  buf,
int  size,
OCADBackground bg 
)

◆ ocad_string()

OCADCString* ocad_string ( OCADFile pfile,
OCADStringEntry *  entry 
)

Returns a pointer to a string, given a valid pointer to its index entry.

Returns nullptr if the file isn't valid or the index entry is empty.

◆ ocad_string_add_background()

int ocad_string_add_background ( OCADFile pfile,
OCADBackground bg 
)

Adds a background template to the file.

◆ ocad_string_at()

OCADCString* ocad_string_at ( OCADFile pfile,
OCADStringIndex *  current,
int  index 
)

Returns a pointer to the string in the specified location within the index block, or nullptr if there is no such string.

◆ ocad_string_entry_at()

OCADStringEntry* ocad_string_entry_at ( OCADFile pfile,
OCADStringIndex *  current,
int  index 
)

Returns a pointer to the given string index entry, or nullptr if the file isn't valid.

Also returns nullptr if the index is out of range, but always returns a valid pointer if the file, index block, and index are valid.

◆ ocad_string_entry_iterate()

bool ocad_string_entry_iterate ( OCADFile pfile,
OCADStringEntryCallback  callback,
void *  param 
)

Iterates over all string entries in the file.

◆ ocad_string_entry_new()

OCADStringEntry* ocad_string_entry_new ( OCADFile pfile,
u32  size 
)

Creates a new string entry large enough to fit the specified number of bytes.

If there is an empty string index entry of sufficient size, it will be used; otherwise, a new entry will be allocated. The entry returned will have its ptr and size fields set; the size field may be larger than the size requested in the parameter. The caller is responsible for copying data into the actual string (retrieved via ocad_string()). If there is not enough memory to create a new entry, nullptr is returned.

◆ ocad_string_index_first()

OCADStringIndex* ocad_string_index_first ( OCADFile pfile)

Returns a pointer to the first string index block, or nullptr if the file isn't valid.

Also returns nullptr if the file contains no object.

◆ ocad_string_index_next()

OCADStringIndex* ocad_string_index_next ( OCADFile pfile,
OCADStringIndex *  current 
)

Returns a pointer to the next string index block after the given one, or nullptr if there is none.

◆ ocad_string_remove()

int ocad_string_remove ( OCADFile pfile,
OCADStringEntry *  entry 
)

Removes the string at the given entry.

The string type is set to zero and the entry becomes eligibile to be returned by ocad_string_entry_new().

◆ ocad_string_size_background()

int ocad_string_size_background ( OCADBackground bg)

◆ ocad_to_background()

int ocad_to_background ( OCADBackground bg,
OCADCString *  templ 
)

Converts an OCAD string of the correct type into an OCADBackground structure.