summaryrefslogtreecommitdiff
path: root/support/dktools/dk4strms.h
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/dk4strms.h
Initial commit
Diffstat (limited to 'support/dktools/dk4strms.h')
-rw-r--r--support/dktools/dk4strms.h260
1 files changed, 260 insertions, 0 deletions
diff --git a/support/dktools/dk4strms.h b/support/dktools/dk4strms.h
new file mode 100644
index 0000000000..6113340e8b
--- /dev/null
+++ b/support/dktools/dk4strms.h
@@ -0,0 +1,260 @@
+/*
+ WARNING: This file was generated by dkct.
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: dk4strms.ctr
+*/
+
+/*
+Copyright (C) 2016-2017, Dirk Krause
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above opyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the author nor the names of contributors may be used
+ to endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef DK4STRMS_H_INCLUDED
+/** Avoid multiple inclusions. */
+#define DK4STRMS_H_INCLUDED 1
+
+
+#line 8 "dk4strms.ctr"
+
+/** @file dk4strms.h Serialize data to a stream.
+
+The functions to serialize integers write the least significant byte
+first.
+
+When serializing a string, the string length is serialized first as
+16 bit unsigned number, string contents follows.
+The finalizing 0x00 byte is both counted in the string length and written
+to the stream.
+So a reader application can retrieve the length first, allocate a memory
+block of exact size and read the string. Reader applications should
+check/ensure the finalizing byte after reading string contents.
+
+When serializing a double, the double is converted to a string and the
+string is serialized to the stream. For 0.0 and values nearby
+(absolute value is below a given limit) a string length 0 is serialized
+to the stream instead, no string is written.
+
+*/
+
+
+#ifndef DK4CONF_H_INCLUDED
+#include "dk4conf.h"
+#endif
+
+#ifndef DK4TYPES_H_INCLUDED
+#include "dk4types.h"
+#endif
+
+#ifndef DK4ERROR_H_INCLUDED
+#include "dk4error.h"
+#endif
+
+#ifndef DK4STRM_H_INCLUDED
+#include <dk4strm.h>
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/** Serialize unsigned 32 bit integer to stream.
+ @param strm Destination stream.
+ @param u32 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_u32(dk4_stream_t *strm, uint32_t u32, dk4_er_t *erp);
+
+
+/** Serialize signed 32 bit integer to stream.
+ @param strm Destination stream.
+ @param i32 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_i32(dk4_stream_t *strm, int32_t i32, dk4_er_t *erp);
+
+
+/** Serialize unsigned 16 bit integer to stream.
+ @param strm Destination stream.
+ @param u16 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_u16(dk4_stream_t *strm, uint16_t u16, dk4_er_t *erp);
+
+
+/** Serialize signed 16 bit integer to stream.
+ @param strm Destination stream.
+ @param i16 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_i16(dk4_stream_t *strm, int16_t i16, dk4_er_t *erp);
+
+
+/** Serialize unsigned 8 bit integer to stream.
+ @param strm Destination stream.
+ @param u8 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_u8(dk4_stream_t *strm, uint8_t u8, dk4_er_t *erp);
+
+
+/** Serialize signed 8 bit integer to stream.
+ @param strm Destination stream.
+ @param i8 Value to serialize.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_i8(dk4_stream_t *strm, int8_t i8, dk4_er_t *erp);
+
+
+/** Serialize string to stream.
+ First the string length including the 0x00 finalizer byte
+ is written as 16 bit unsigned integer, the string including the
+ finalizer byte follows.
+ By reading the length first, a reader application can allocate
+ a memory block of exact size before reading the string contents.
+ @param strm Destination stream.
+ @param str String to serialize, max 65534 characters long.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if strm is NULL or not opened for writing,
+ - DK4_E_BUFFER_TOO_SMALL<br>
+ if the str string is too long,
+ - DK4_E_WRITE_FAILED<br>
+ if writing one ore multiple bytes to the stream failed,
+ - DK4_E_FLUSH_FAILED<br>
+ if flusing data downwards failed.
+*/
+
+int
+dk4stream_serialize_string(dk4_stream_t *strm, const char *str, dk4_er_t *erp);
+
+
+/** Serialize floating point value to stream.
+ For non-0.0 values the value is converted to a string, the string
+ is serialized to the stream. For 0.0 and values near enough
+ (absolute value is below a given limit) a string length 0 is written
+ indicating the 0.0 value to reader applications.
+ @param strm Destination stream.
+ @param d Value to serialize.
+ @param e Epsilon for check whether d is 0.
+ @param erp Error report, may be NULL.
+ @return 1 on success, 0 on error.
+*/
+
+int
+dk4stream_serialize_double(dk4_stream_t *strm,double d,double e,dk4_er_t *erp);
+
+
+/** Serialize floating point value 0 in short form.
+ @param strm Stream to write to.
+ @param erp Error report, may be NULL.
+*/
+
+int
+dk4stream_serialize_double_0(dk4_stream_t *strm, dk4_er_t *erp);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* vim: set ai sw=4 ts=4 : */
+
+
+#endif