NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
utils.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <algorithm>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  novasvg
 Main namespace for the NovaSVG library.
 
namespace  novasvg::render
 

Macros

#define NOVASVG_UTILS_H
 
#define NOVASVG_IS_NUM(c)   ((c) >= '0' && (c) <= '9')
 
#define NOVASVG_IS_ALPHA(c)   (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
 
#define NOVASVG_IS_ALNUM(c)   (NOVASVG_IS_ALPHA(c) || NOVASVG_IS_NUM(c))
 
#define NOVASVG_IS_WS(c)   ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r')
 
#define novasvg_alpha(c)   (((c) >> 24) & 0xff)
 
#define novasvg_red(c)   (((c) >> 16) & 0xff)
 
#define novasvg_green(c)   (((c) >> 8) & 0xff)
 
#define novasvg_blue(c)   (((c) >> 0) & 0xff)
 
#define novasvg_array_init(array)
 
#define NOVASVG_ARRAY_CAST(array, value)   (value)
 
#define novasvg_array_ensure(array, count)
 
#define novasvg_array_append_data(array, newdata, count)
 
#define novasvg_array_append(array, other)   novasvg_array_append_data(array, (other).data, (other).size)
 
#define novasvg_array_clear(array)   ((array).size = 0)
 
#define novasvg_array_destroy(array)   free((array).data)
 

Functions

NOVASVG_INLINE uint32_t novasvg::render::premultiply_argb (uint32_t color)
 
NOVASVG_INLINE bool novasvg::render::parse_number (const char **begin, const char *end, float *number)
 
NOVASVG_INLINE bool novasvg::render::skip_delim (const char **begin, const char *end, const char delim)
 
NOVASVG_INLINE bool novasvg::render::skip_string (const char **begin, const char *end, const char *data)
 
NOVASVG_INLINE bool novasvg::render::skip_ws (const char **begin, const char *end)
 
NOVASVG_INLINE bool novasvg::render::skip_ws_and_delim (const char **begin, const char *end, char delim)
 
NOVASVG_INLINE bool novasvg::render::skip_ws_and_comma (const char **begin, const char *end)
 
NOVASVG_INLINE bool novasvg::render::skip_ws_or_delim (const char **begin, const char *end, char delim, bool *has_delim)
 
NOVASVG_INLINE bool novasvg::render::skip_ws_or_comma (const char **begin, const char *end, bool *has_comma)
 
NOVASVG_INLINE void novasvg::render::skip_css_unit (const char **begin, const char *end, float *number)
 

Macro Definition Documentation

◆ novasvg_alpha

#define novasvg_alpha (   c)    (((c) >> 24) & 0xff)

Definition at line 31 of file utils.h.

◆ novasvg_array_append

#define novasvg_array_append (   array,
  other 
)    novasvg_array_append_data(array, (other).data, (other).size)

Definition at line 69 of file utils.h.

◆ novasvg_array_append_data

#define novasvg_array_append_data (   array,
  newdata,
  count 
)
Value:
do { \
if(newdata && count > 0) { \
novasvg_array_ensure(array, count); \
memcpy((array).data + (array).size, newdata, (count) * sizeof((newdata)[0])); \
(array).size += count; \
} \
} while(0)

Definition at line 60 of file utils.h.

◆ NOVASVG_ARRAY_CAST

#define NOVASVG_ARRAY_CAST (   array,
  value 
)    (value)

Definition at line 46 of file utils.h.

◆ novasvg_array_clear

#define novasvg_array_clear (   array)    ((array).size = 0)

Definition at line 70 of file utils.h.

◆ novasvg_array_destroy

#define novasvg_array_destroy (   array)    free((array).data)

Definition at line 71 of file utils.h.

◆ novasvg_array_ensure

#define novasvg_array_ensure (   array,
  count 
)
Value:
do { \
if((array).size + (count) > (array).capacity) { \
int capacity = (array).size + (count); \
int newcapacity = (array).capacity == 0 ? 8 : (array).capacity; \
while(newcapacity < capacity) { newcapacity *= 2; } \
(array).data = NOVASVG_ARRAY_CAST(array, realloc((array).data, newcapacity * sizeof((array).data[0]))); \
(array).capacity = newcapacity; \
} \
} while(0)
#define NOVASVG_ARRAY_CAST(array, value)
Definition utils.h:46

Definition at line 49 of file utils.h.

◆ novasvg_array_init

#define novasvg_array_init (   array)
Value:
do { \
(array).data = NULL; \
(array).size = 0; \
(array).capacity = 0; \
} while(0)

Definition at line 36 of file utils.h.

◆ novasvg_blue

#define novasvg_blue (   c)    (((c) >> 0) & 0xff)

Definition at line 34 of file utils.h.

◆ novasvg_green

#define novasvg_green (   c)    (((c) >> 8) & 0xff)

Definition at line 33 of file utils.h.

◆ NOVASVG_IS_ALNUM

#define NOVASVG_IS_ALNUM (   c)    (NOVASVG_IS_ALPHA(c) || NOVASVG_IS_NUM(c))

Definition at line 20 of file utils.h.

◆ NOVASVG_IS_ALPHA

#define NOVASVG_IS_ALPHA (   c)    (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))

Definition at line 19 of file utils.h.

◆ NOVASVG_IS_NUM

#define NOVASVG_IS_NUM (   c)    ((c) >= '0' && (c) <= '9')

Definition at line 18 of file utils.h.

◆ NOVASVG_IS_WS

#define NOVASVG_IS_WS (   c)    ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r')

Definition at line 21 of file utils.h.

◆ novasvg_red

#define novasvg_red (   c)    (((c) >> 16) & 0xff)

Definition at line 32 of file utils.h.

◆ NOVASVG_UTILS_H

#define NOVASVG_UTILS_H

Definition at line 4 of file utils.h.