Skip to content

File notation_wptt.c

FileList > note-wptt > src > notation_wptt.c

Go to the source code of this file

Notation module for weighted planar tangle trees. More...

  • #include "notation_wptt.h"
  • #include "stdio.h"
  • #include "stdlib.h"
  • #include "stdbool.h"

Classes

Type Name
struct note_wptt_decode_char_dic_t
The type for the elements of the decode dictionary.

Public Types

Type Name
typedef uint8_t(* char_handler_funptr_t
The function pointer type for decode dictionary functions.
typedef struct note_wptt_decode_char_dic_t note_wptt_decode_char_dic_t
The type for the elements of the decode dictionary.

Public Attributes

Type Name
uint8_t child_idx_stack
The stack containing the current child index used in the encode path functions.

Public Static Attributes

Type Name
note_wptt_node_buffer_t * decode_buffer = NULL
Pointer to a buffer of wptt nodes. Used by decode path functions.
note_wptt_node_t * wptt_node_stack = { NULL }
The wptt stack used in the encode and decode functions. This needs to be initialized at the beginning of the using function.
size_t wptt_stack_len = 0
The current number of elements on the wptt stack.

Public Functions

Type Name
uint8_t note_wptt_decode (char * str, note_wptt_t * wptt)
Function to take a note_wptt_t and decode it as a string.
STATIC_INLINE_UINT8 note_wptt_decode_add_child ()
Makes the active node on the wptt stack a child of the node below it on the stack.
STATIC_INLINE bool note_wptt_decode_check_charset (const char * valid_chars, const char str)
Determine if a character from the input string is one of the valid characters.
STATIC_INLINE_UINT8 note_wptt_decode_cls_handler (char ** str)
Dictionary function to pop a node off of the wptt stack and advance to the next character of the string.
STATIC_INLINE note_wptt_V4_label_e note_wptt_decode_get_v4_label (char label)
Get the label for the input string.
STATIC_INLINE_UINT8 note_wptt_decode_opn_a_handler (char ** str)
Dictionary function to initialize and push a child node onto the stack with a ring number.
STATIC_INLINE_UINT8 note_wptt_decode_opn_b_handler (char ** str)
Dictionary function to process and create a stick subtree.
STATIC_INLINE_UINT8 note_wptt_decode_opn_p_handler (char ** str)
Dictionary function to initialize and push a child node onto the stack.
STATIC_INLINE_UINT8 note_wptt_decode_push_node ()
Initializes and pushes a node to the wptt stack.
STATIC_INLINE_UINT8 note_wptt_decode_space_handler (char ** str)
Dictionary function to consume and advance the to the the next character of the input string.
STATIC_INLINE_UINT8 note_wptt_decode_weight_handler (char ** str)
Dictionary function to process an integer weight and advance the input string.
uint8_t note_wptt_encode (note_wptt_t wptt, char * str, size_t buffer_size)
Function to take a string and decode it as a note_wptt_t . NOTE: This function modifies the input WPTT. The input is normalized so all nodes have "forward" order. This does not change the topology.
STATIC_INLINE_UINT8 note_wptt_encode_complete_active_node (const note_wptt_node_t * active_node_p, char ** str_p, size_t ordered_child_idx, const char * buffer_start_p, const char * buffer_end_p)
Cap off the string representation of a node.
STATIC_INLINE_UINT8 note_wptt_encode_insert_char (char new_char, char ** str_p, const char * buffer_end_p)
Insert a character into the output string.
STATIC_INLINE_UINT8 note_wptt_encode_insert_int (int8_t new_int, char ** str_p, const char * buffer_end_p)
Insert the base 10 string representation of an integer into the output string.
STATIC_INLINE_UINT8 note_wptt_encode_insert_label (note_wptt_V4_label_e label, char ** str_p, const char * buffer_end_p)
Insert the V4 label into the output string.
STATIC_INLINE_UINT8 note_wptt_encode_insert_space (char ** str_p, const char * buffer_start_p, const char * buffer_end_p)
Insert a space into the output string to delimit two integers.
STATIC_INLINE_UINT8 note_wptt_encode_insert_stick (note_wptt_node_t * active_node_p, char ** str_p, const char * buffer_end_p)
Process and insert a stick subtree into the output string.
STATIC_INLINE void note_wptt_encode_normalize_node_order (note_wptt_node_t * active_node_p)
Determine the next child index by the order of the active node.
STATIC_INLINE_UINT8 note_wptt_encode_process_active_node (note_wptt_node_t * active_node_p, char ** str_p, size_t ordered_child_idx, const char * buffer_start_p, const char * buffer_end_p)
Determine the next action in the processing of the active node.
STATIC_INLINE bool note_wptt_encode_stick_check (note_wptt_node_t * active_node_p)
Determine whether the active node is the root of stick.

Macros

Type Name
define NOTE_WPTT_DECODE_DICT_SIZE (6u)
The size of the dictionary of decode functions.
define NOTE_WPTT_INT_BASE (10u)
The number base used for string->int functions.
define NOTE_WPTT_STACK_SIZE ([**UTIL\_TANG\_DEFS\_MAX\_CROSSINGNUM**](tang__defs_8h.md#define-util_tang_defs_max_crossingnum))
The size of the decode stack.
define NOTE_WPTT_V4_LABEL_I_STR ('i')
The character for the identity label.
define NOTE_WPTT_V4_LABEL_X_STR ('x')
The character for the x rotation label.
define NOTE_WPTT_V4_LABEL_Y_STR ('y')
The character for the y rotation label.
define NOTE_WPTT_V4_LABEL_Z_STR ('z')
The character for the z rotation label.

Detailed Description

Author:

Joe Starr

Public Types Documentation

typedef char_handler_funptr_t

The function pointer type for decode dictionary functions.

typedef uint8_t(* char_handler_funptr_t) (char **str);


typedef note_wptt_decode_char_dic_t

The type for the elements of the decode dictionary.

typedef struct note_wptt_decode_char_dic_t note_wptt_decode_char_dic_t;


Public Attributes Documentation

variable child_idx_stack

The stack containing the current child index used in the encode path functions.

uint8_t child_idx_stack[UTIL_TANG_DEFS_MAX_CROSSINGNUM];


Public Static Attributes Documentation

variable decode_buffer

Pointer to a buffer of wptt nodes. Used by decode path functions.

note_wptt_node_buffer_t* decode_buffer;


variable wptt_node_stack

The wptt stack used in the encode and decode functions. This needs to be initialized at the beginning of the using function.

note_wptt_node_t* wptt_node_stack[NOTE_WPTT_STACK_SIZE];


variable wptt_stack_len

The current number of elements on the wptt stack.

size_t wptt_stack_len;


Public Functions Documentation

function note_wptt_decode

Function to take a note_wptt_t and decode it as a string.

uint8_t note_wptt_decode (
    char * str,
    note_wptt_t * wptt
) 

Parameters:

Returns:

uint8_t The return code for the decoding operation.


function note_wptt_decode_add_child

Makes the active node on the wptt stack a child of the node below it on the stack.

STATIC_INLINE_UINT8 note_wptt_decode_add_child () 

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_check_charset

Determine if a character from the input string is one of the valid characters.

STATIC_INLINE bool note_wptt_decode_check_charset (
    const char * valid_chars,
    const char str
) 

Parameters:

  • valid_chars The list of valid characters.
  • str_char A character form the input string.

Returns:

The truthiness of if the character is one of the valid characters.


function note_wptt_decode_cls_handler

Dictionary function to pop a node off of the wptt stack and advance to the next character of the string.

STATIC_INLINE_UINT8 note_wptt_decode_cls_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer a the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_get_v4_label

Get the label for the input string.

STATIC_INLINE note_wptt_V4_label_e note_wptt_decode_get_v4_label (
    char label
) 

Parameters:

  • label The first char of the input string.

Returns:

The designator for the label.


function note_wptt_decode_opn_a_handler

Dictionary function to initialize and push a child node onto the stack with a ring number.

STATIC_INLINE_UINT8 note_wptt_decode_opn_a_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer a the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_opn_b_handler

Dictionary function to process and create a stick subtree.

STATIC_INLINE_UINT8 note_wptt_decode_opn_b_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer for the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_opn_p_handler

Dictionary function to initialize and push a child node onto the stack.

STATIC_INLINE_UINT8 note_wptt_decode_opn_p_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer a the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_push_node

Initializes and pushes a node to the wptt stack.

STATIC_INLINE_UINT8 note_wptt_decode_push_node () 

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_space_handler

Dictionary function to consume and advance the to the the next character of the input string.

STATIC_INLINE_UINT8 note_wptt_decode_space_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer a the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_decode_weight_handler

Dictionary function to process an integer weight and advance the input string.

STATIC_INLINE_UINT8 note_wptt_decode_weight_handler (
    char ** str
) 

Parameters:

  • str A pointer to the pointer a the current character of the input string.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode

Function to take a string and decode it as a note_wptt_t . NOTE: This function modifies the input WPTT. The input is normalized so all nodes have "forward" order. This does not change the topology.

uint8_t note_wptt_encode (
    note_wptt_t wptt,
    char * str,
    size_t buffer_size
) 

Parameters:

Returns:

uint8_t The return code for the encoding operation.


function note_wptt_encode_complete_active_node

Cap off the string representation of a node.

STATIC_INLINE_UINT8 note_wptt_encode_complete_active_node (
    const note_wptt_node_t * active_node_p,
    char ** str_p,
    size_t ordered_child_idx,
    const char * buffer_start_p,
    const char * buffer_end_p
) 

Parameters:

  • active_node The node under investigation.
  • str_p A pointer to the pointer of current index of the output string.
  • ordered_child_idx The next child index in the order of the active node.
  • buffer_start_p A pointer to the start of the output string buffer.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_insert_char

Insert a character into the output string.

STATIC_INLINE_UINT8 note_wptt_encode_insert_char (
    char new_char,
    char ** str_p,
    const char * buffer_end_p
) 

Parameters:

  • new_char A character to insert.
  • str_p A pointer to the pointer of current index of the output string.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_insert_int

Insert the base 10 string representation of an integer into the output string.

STATIC_INLINE_UINT8 note_wptt_encode_insert_int (
    int8_t new_int,
    char ** str_p,
    const char * buffer_end_p
) 

Parameters:

  • new_int An integer to insert.
  • str_p A pointer to the pointer of current index of the output string.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_insert_label

Insert the V4 label into the output string.

STATIC_INLINE_UINT8 note_wptt_encode_insert_label (
    note_wptt_V4_label_e label,
    char ** str_p,
    const char * buffer_end_p
) 

Parameters:

  • label The V4 of a wptt.
  • str_p A pointer to the pointer of current index of the output string.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_insert_space

Insert a space into the output string to delimit two integers.

STATIC_INLINE_UINT8 note_wptt_encode_insert_space (
    char ** str_p,
    const char * buffer_start_p,
    const char * buffer_end_p
) 

Parameters:

  • str_p A pointer to the pointer of current index of the output string.
  • buffer_start_p A pointer to the start of the output string buffer.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_insert_stick

Process and insert a stick subtree into the output string.

STATIC_INLINE_UINT8 note_wptt_encode_insert_stick (
    note_wptt_node_t * active_node_p,
    char ** str_p,
    const char * buffer_end_p
) 

Parameters:

  • active_node The node under investigation.
  • str_p A pointer to the pointer of current index of the output string.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_normalize_node_order

Determine the next child index by the order of the active node.

STATIC_INLINE void note_wptt_encode_normalize_node_order (
    note_wptt_node_t * active_node_p
) 

Parameters:

  • active_node The node under investigation.

Returns:

The next ordered child index.


function note_wptt_encode_process_active_node

Determine the next action in the processing of the active node.

STATIC_INLINE_UINT8 note_wptt_encode_process_active_node (
    note_wptt_node_t * active_node_p,
    char ** str_p,
    size_t ordered_child_idx,
    const char * buffer_start_p,
    const char * buffer_end_p
) 

Parameters:

  • active_node The node under investigation.
  • str_p A pointer to the pointer of current index of the output string.
  • ordered_child_idx The next child index in the order of the active node.
  • buffer_start_p A pointer to the start of the output string buffer.
  • buffer_end_p A pointer to the end of the output string buffer.

Returns:

A status flag indicating successful completion of the subroutine.


function note_wptt_encode_stick_check

Determine whether the active node is the root of stick.

STATIC_INLINE bool note_wptt_encode_stick_check (
    note_wptt_node_t * active_node_p
) 

Parameters:

  • active_node A wptt node and potential stick root.

Returns:

The truthiness of whether the active node is the root of stick.


Macro Definition Documentation

define NOTE_WPTT_DECODE_DICT_SIZE

The size of the dictionary of decode functions.

#define NOTE_WPTT_DECODE_DICT_SIZE `(6u)`


define NOTE_WPTT_INT_BASE

The number base used for string->int functions.

#define NOTE_WPTT_INT_BASE `(10u)`


define NOTE_WPTT_STACK_SIZE

The size of the decode stack.

#define NOTE_WPTT_STACK_SIZE `( UTIL_TANG_DEFS_MAX_CROSSINGNUM )`


define NOTE_WPTT_V4_LABEL_I_STR

The character for the identity label.

#define NOTE_WPTT_V4_LABEL_I_STR `('i')`


define NOTE_WPTT_V4_LABEL_X_STR

The character for the x rotation label.

#define NOTE_WPTT_V4_LABEL_X_STR `('x')`


define NOTE_WPTT_V4_LABEL_Y_STR

The character for the y rotation label.

#define NOTE_WPTT_V4_LABEL_Y_STR `('y')`


define NOTE_WPTT_V4_LABEL_Z_STR

The character for the z rotation label.

#define NOTE_WPTT_V4_LABEL_Z_STR `('z')`



The documentation for this class was generated from the following file source/note-wptt/src/notation_wptt.c