INGOR
ytStrBuff.h
1/*
2 util/ytStrBuff.{h,c} : String Buffer
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of The Kyoto University nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35#ifndef __YTLIB_STR_BUFF_H
36#define __YTLIB_STR_BUFF_H
37#include <stdlib.h>
38typedef struct ytStrBuff_t ytStrBuff;
40void ytStrBuff_delete(void * this);
41ytStrBuff * ytStrBuff_expand(ytStrBuff * this, size_t length);
42ytStrBuff * ytStrBuff_add(ytStrBuff * this, char c);
43ytStrBuff * ytStrBuff_addStr(ytStrBuff * this, const char * str);
44size_t ytStrBuff_length(const ytStrBuff * this);
45size_t ytStrBuff_len(const ytStrBuff * this);
46const char * ytStrBuff_str(const ytStrBuff * this);
47void * ytStrBuff_ptr(const ytStrBuff * this);
48void ytStrBuff_clear(ytStrBuff * this);
49char * ytStrBuff_gen(const ytStrBuff * this);
50#endif /* __YTLIB_STR_BUFF_H */
Expandable String Buffer.
ytStrBuff * ytStrBuff_expand(ytStrBuff *this, size_t length)
Expands the size of the allocated buffer memory.
Definition: ytStrBuff.c:102
ytStrBuff * ytStrBuff_new()
Generates the new ytStrBuff instance.
Definition: ytStrBuff.c:59
ytStrBuff * ytStrBuff_add(ytStrBuff *this, char c)
Adds a character to the end of the buffer.
Definition: ytStrBuff.c:127
char * ytStrBuff_gen(const ytStrBuff *this)
Generates a new string identical to the string buffer.
Definition: ytStrBuff.c:241
size_t ytStrBuff_length(const ytStrBuff *this)
Returns the length of the string in the buffer.
Definition: ytStrBuff.c:169
void * ytStrBuff_ptr(const ytStrBuff *this)
Returns the pointer pointing to the current string.
Definition: ytStrBuff.c:212
ytStrBuff * ytStrBuff_addStr(ytStrBuff *this, const char *str)
Adds a string to the end of the buffer.
Definition: ytStrBuff.c:146
const char * ytStrBuff_str(const ytStrBuff *this)
Returns the pointer pointing to the current string.
Definition: ytStrBuff.c:196
size_t ytStrBuff_len(const ytStrBuff *this)
Returns the length of the string in the buffer.
Definition: ytStrBuff.c:183
void ytStrBuff_delete(void *this)
Deletes the ytStrBuff instance.
Definition: ytStrBuff.c:77
void ytStrBuff_clear(ytStrBuff *this)
Clears the buffer.
Definition: ytStrBuff.c:225
Definition: ytStrBuff.c:41