-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharvector.h
37 lines (29 loc) · 993 Bytes
/
charvector.h
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
36
37
#ifndef CHARVECTOR_H_
#define CHARVECTOR_H_
#include <stdlib.h>
#include <stdarg.h>
typedef char el_t;
typedef struct
{
el_t* data;
size_t length, capacity;
} cv_t; // Short for "Char Vector Type"
//cv_sprintf notwithstanding, cv_t has C++ std::vector<char>-like semantics and should be
//used that way
void cv_swap(cv_t* a, cv_t* b);
void cv_copy(cv_t* dest, cv_t* source);
void cv_strncpy(cv_t* dest, const el_t* source, size_t len);
void cv_strncat(cv_t* dest, const el_t* source, size_t len);
int cv_init(cv_t* cv, size_t startsize);
void cv_destroy(cv_t* cv);
int cv_push(cv_t* cv, el_t newel);
int cv_pushlimited(cv_t* cv, el_t newel);
int cv_resize(cv_t* cv, size_t newsize);
int cv_appendstr(cv_t* cv, const el_t* data, size_t len);
int cv_appendcv(cv_t* dest, cv_t* src);
int cv_append(cv_t* cv, const el_t* data, size_t len);
void cv_clear(cv_t* cv);
el_t cv_at(cv_t* cv, size_t idx);
size_t cv_len(cv_t* cv);
void cv_sprintf(cv_t* pcv, const char* fmt, ...);
#endif