S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_buffer.h
Go to the documentation of this file.
1/*
2 * Licensed to Systerel under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work
4 * for additional information regarding copyright ownership.
5 * Systerel licenses this file to you under the Apache
6 * License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain
8 * a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
26#ifndef SOPC_BUFFER_H_
27#define SOPC_BUFFER_H_
28
29#include <stdbool.h>
30#include <stdint.h>
31
32#include "sopc_enums.h"
33
37typedef struct
38{
39 uint32_t initial_size;
40 uint32_t current_size;
41 uint32_t maximum_size;
42 uint32_t position;
43 uint32_t length;
44 uint8_t* data;
46
54
62SOPC_Buffer* SOPC_Buffer_CreateResizable(uint32_t initial_size, uint32_t maximum_size);
63
76SOPC_Buffer* SOPC_Buffer_Attach(uint8_t* data, uint32_t size);
77
84
91
99
110
121
132
143
155SOPC_ReturnStatus SOPC_Buffer_Write(SOPC_Buffer* buffer, const uint8_t* data_src, uint32_t count);
156
169SOPC_ReturnStatus SOPC_Buffer_Read(uint8_t* data_dest, SOPC_Buffer* buffer, uint32_t count);
170
181
196
205
215int64_t SOPC_Buffer_ReadFrom(SOPC_Buffer* buffer, SOPC_Buffer* src, uint32_t n);
216
227
240
254
279
280/***
281 * \brief Print the C string value in the buffer.
282 * \param value The C-string to print. If value is NULLL "<null>" is printed.
283 * \return SOPC_STATUS_OK if succeeded, an error code otherwise (NULL pointer, non allocated buffer
284 * content, full buffer avoiding operation)
285 */
287
288#endif /* SOPC_BUFFER_H_ */
void SOPC_Buffer_Delete(SOPC_Buffer *buffer)
Deallocate buffer and its data bytes content (Clear + deallocate pointer)
void SOPC_Buffer_Reset(SOPC_Buffer *buffer)
Reset length, position and data bytes to zero value of an allocated buffer.
uint32_t SOPC_Buffer_Remaining(SOPC_Buffer *buffer)
Returns the remaining number of unread bytes in the buffer.
SOPC_Buffer * SOPC_Buffer_Attach(uint8_t *data, uint32_t size)
Wraps a raw memory area into an SOPC_Buffer.
SOPC_ReturnStatus SOPC_Buffer_PrintCString(SOPC_Buffer *buf, const char *value)
SOPC_ReturnStatus SOPC_Buffer_PrintFloatDouble(SOPC_Buffer *buf, const double value)
Print the value into the buffer data bytes from the buffer position (adapting buffer position and len...
SOPC_ReturnStatus SOPC_Buffer_ResetAfterPosition(SOPC_Buffer *buffer, uint32_t position)
reset data bytes after position (>=) to zero and set buffer position and length to given position
SOPC_ReturnStatus SOPC_Buffer_ReadFile(const char *path, SOPC_Buffer **buf)
Reads the contents of a file into a SOPC_Buffer.
SOPC_Buffer * SOPC_Buffer_Create(uint32_t size)
Allocate a buffer and its data bytes of the given definitive size and returns it.
void SOPC_Buffer_Clear(SOPC_Buffer *buffer)
Deallocate buffer data bytes content.
SOPC_Buffer * SOPC_Buffer_CreateResizable(uint32_t initial_size, uint32_t maximum_size)
Allocate a resizable buffer and its initial and maximum data bytes.
SOPC_ReturnStatus SOPC_Buffer_Write(SOPC_Buffer *buffer, const uint8_t *data_src, uint32_t count)
Write the given bytes into the buffer data bytes from the buffer position (adapting buffer position a...
SOPC_ReturnStatus SOPC_Buffer_PrintU32(SOPC_Buffer *buf, const uint32_t value)
Print the value into the buffer data bytes from the buffer position (adapting buffer position and len...
SOPC_ReturnStatus SOPC_Buffer_Copy(SOPC_Buffer *dest, SOPC_Buffer *src)
Copy the data bytes and properties from the source buffer to the destination buffer.
SOPC_ReturnStatus SOPC_Buffer_PrintI32(SOPC_Buffer *buf, const int32_t value)
Print the value into the buffer data bytes from the buffer position (adapting buffer position and len...
SOPC_ReturnStatus SOPC_Buffer_SetPosition(SOPC_Buffer *buffer, uint32_t position)
Set buffer to the given position.
SOPC_ReturnStatus SOPC_Buffer_CopyWithLength(SOPC_Buffer *dest, SOPC_Buffer *src, uint32_t limitedLength)
Copy the data bytes and properties for the given length from the source buffer to the destination buf...
int64_t SOPC_Buffer_ReadFrom(SOPC_Buffer *buffer, SOPC_Buffer *src, uint32_t n)
Reads n bytes from src into buffer.
SOPC_ReturnStatus SOPC_Buffer_GetPosition(SOPC_Buffer *buffer, uint32_t *position)
Get buffer current position.
SOPC_ReturnStatus SOPC_Buffer_Read(uint8_t *data_dest, SOPC_Buffer *buffer, uint32_t count)
Read the given bytes of the buffer data bytes from the buffer position (adapting buffer position to n...
SOPC_ReturnStatus SOPC_Buffer_SetDataLength(SOPC_Buffer *buffer, uint32_t length)
Set buffer to the given length.
enum _SOPC_ReturnStatus SOPC_ReturnStatus
Common enumerations for S2OPC.
Bytes buffer structure.
Definition sopc_buffer.h:38
uint32_t position
Definition sopc_buffer.h:42
uint8_t * data
Definition sopc_buffer.h:44
uint32_t current_size
Definition sopc_buffer.h:40
uint32_t length
Definition sopc_buffer.h:43
uint32_t initial_size
Definition sopc_buffer.h:39
uint32_t maximum_size
Definition sopc_buffer.h:41