NUGU SDK Linux  1.7.6
nugu_buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NUGU_BUFFER_H__
18 #define __NUGU_BUFFER_H__
19 
20 #include <stddef.h>
21 #include <nugu.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
47 #define NUGU_BUFFER_NOT_FOUND ((size_t) - 1)
48 
52 typedef struct _nugu_buffer NuguBuffer;
53 
61 NUGU_API NuguBuffer *nugu_buffer_new(size_t default_size);
62 
72 NUGU_API void *nugu_buffer_free(NuguBuffer *buf, int is_data_free);
73 
81 NUGU_API size_t nugu_buffer_add(NuguBuffer *buf, const void *data,
82  size_t data_len);
83 
90 NUGU_API size_t nugu_buffer_add_byte(NuguBuffer *buf, unsigned char byte);
91 
101 NUGU_API int nugu_buffer_set_byte(NuguBuffer *buf, size_t pos,
102  unsigned char byte);
103 
110 NUGU_API const void *nugu_buffer_peek(NuguBuffer *buf);
111 
118 NUGU_API size_t nugu_buffer_get_size(NuguBuffer *buf);
119 
127 
135 NUGU_API size_t nugu_buffer_find_byte(NuguBuffer *buf, unsigned char want);
136 
143 NUGU_API unsigned char nugu_buffer_peek_byte(NuguBuffer *buf, size_t pos);
144 
153 NUGU_API int nugu_buffer_clear(NuguBuffer *buf);
154 
164 NUGU_API int nugu_buffer_clear_from(NuguBuffer *buf, size_t pos);
165 
174 NUGU_API int nugu_buffer_shift_left(NuguBuffer *buf, size_t size);
175 
182 NUGU_API void *nugu_buffer_pop(NuguBuffer *buf, size_t size);
183 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif
struct _nugu_buffer NuguBuffer
Buffer object.
Definition: nugu_buffer.h:52
NUGU_API size_t nugu_buffer_add(NuguBuffer *buf, const void *data, size_t data_len)
Append the data to buffer object.
NUGU_API int nugu_buffer_set_byte(NuguBuffer *buf, size_t pos, unsigned char byte)
Append the data to buffer object.
NUGU_API size_t nugu_buffer_get_alloc_size(NuguBuffer *buf)
Gets the size of the entire data allocated for the buffer.
NUGU_API int nugu_buffer_shift_left(NuguBuffer *buf, size_t size)
Delete a certain amount of data and move the remaining data forward.
NUGU_API const void * nugu_buffer_peek(NuguBuffer *buf)
Get the internal buffer.
NUGU_API int nugu_buffer_clear_from(NuguBuffer *buf, size_t pos)
Clear data from a specific position to the end.
NUGU_API void * nugu_buffer_pop(NuguBuffer *buf, size_t size)
Extract data by a certain size.
NUGU_API size_t nugu_buffer_add_byte(NuguBuffer *buf, unsigned char byte)
Append the data to buffer object.
NUGU_API void * nugu_buffer_free(NuguBuffer *buf, int is_data_free)
Destroy the buffer object.
NUGU_API NuguBuffer * nugu_buffer_new(size_t default_size)
Create new buffer object.
NUGU_API unsigned char nugu_buffer_peek_byte(NuguBuffer *buf, size_t pos)
Get data at a specific position.
NUGU_API size_t nugu_buffer_get_size(NuguBuffer *buf)
Gets the size of the entire data added to the buffer.
NUGU_API size_t nugu_buffer_find_byte(NuguBuffer *buf, unsigned char want)
Get the position of the data you want to find.
NUGU_API int nugu_buffer_clear(NuguBuffer *buf)
Clear the buffer.