Mathematic Expressions Library  0.1
The core math data structures and manipulators
types.c File Reference
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include "errors.h"
#include "expression.h"
#include "types.h"
Include dependency graph for types.c:

Functions

value_t value_new_type (enum value_types type)
 
value_t value_new_lint (sys_int_long lint)
 
value_t string_to_value (size_t src_str_len, char const *src_str)
 Create value from a string. More...
 
void value_to_string (char *dst_str, value_t src_val)
 
pindex_t find_matching (size_t str_len, const char *str, pindex_t start)
 Find the index of the matching closing paren in a string. More...
 

Detailed Description

Date
Apr 23, 2014
Author
Craig Hesling

Contains standard types, macros, and functions used throughout the library. Most notably, this is the home of the value_t.

Function Documentation

◆ find_matching()

pindex_t find_matching ( size_t  str_len,
const char *  str,
pindex_t  start 
)

Find the index of the matching closing paren in a string.

Parameters
str_lenOverall string length.
strString to search in.
startIndex of the open paren to match.
Returns
The index of the matching paren or PINDEX_BAD if no match was found.
Note
Assumes start is the index of the open paren to match and then moves forward.

◆ string_to_value()

value_t string_to_value ( size_t  src_str_len,
char const *  src_str 
)

Create value from a string.

Parameters
src_str_lenThe length of the actual buffer (not the number size).
src_strThe source string.
Returns
The value in the source string.
Note
Must have first char be digit
Currently we only do Long Ints

<

Note
Here we assume it is a Long Int

<

Warning
Uses system atol() function at index 0 on the bare string given
Here is the call graph for this function:

◆ value_new_lint()

value_t value_new_lint ( sys_int_long  lint)

◆ value_new_type()

value_t value_new_type ( enum value_types  type)

◆ value_to_string()

void value_to_string ( char *  dst_str,
value_t  src_val 
)

<

Warning
Unknown types of value_t will just assert(false) here.