summaryrefslogtreecommitdiff
path: root/src/str.h
blob: 2c422111ff1565e28803079ad461b9f3c86ac5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef STR_H
#define STR_H

#include "util.h"

typedef struct str_s str;

str *new_str(char *s, NUM size);

/* flag non-zero => free the stored character array as well */
void destroy_str(str *s, int flag);

/* deliberately expose this struct */
struct str_info_s {
  NUM value;
  size_t step;
};

typedef struct str_info_s str_info;

#define EMPTY_STR_INFO ((str_info) { 0, 1 })

str_info get_info(const str * const restrict s, UNUM n);

char *get_data(const str * const restrict s);

NUM str_length(const str * const restrict s);

void str_set_length(str *s, UNUM size);

void change_str_content(str *, char *, NUM);

BOOL copy_str(str *dest, str *source);

#endif