RTI Connext Micro  Version 2.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
osapi_string.h
Go to the documentation of this file.
1 /*
2  * FILE: osapi_string.h - Definition of string interface
3  *
4  * Copyright 2012-2014 Real-Time Innovations, Inc.
5  *
6  * No duplications, whole or partial, manual or electronic, may be made
7  * without express written permission. Any such copies, or
8  * revisions thereof, must display this notice unaltered.
9  * This code contains trade secrets of Real-Time Innovations, Inc.
10  *
11  * Modification History
12  * --------------------
13  * 15may2014,as MICRO-317 (Verocel PR#1443) Added OSAPI_String_ncmp
14  * 12mar2012,tk Written
15  */
16 /*ce
17  * \file
18  * \brief String interface definition
19  */
20 #ifndef osapi_string_h
21 #define osapi_string_h
22 
23 #ifndef osapi_dll_h
24 #include "osapi/osapi_dll.h"
25 #endif
26 #ifndef osapi_types_h
27 #include "osapi/osapi_types.h"
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 /*e \file
36  * \brief Memory utilities.
37  */
38 
39 /*e \defgroup OSAPI_MemoryClass OSAPI Memory
40  * \ingroup OSAPIModule
41  *
42  * \brief These are utilities for OS-independent memory manipulation such
43  * as filling and copying.
44  */
45 
46 /*e \ingroup OSAPI_MemoryClass
47  * \brief Copies size bytes from non-overlapping src to dest.
48  *
49  * \details
50  * Valid dest and src >= size, where size >= 0. The src
51  * and dst memory regions should NOT overlap or the results will
52  * be undetermined. On success move size number of bytes from in
53  * [dest, dest+size) are identical to [src, src+size).
54  *
55  * @param dest \b Out. Pointer to destination memory region.
56  * @param src \b In. Pointer to source memory region.
57  * @param size \b In. Number of bytes to copy starting at dest.
58  *
59  * @exception None.
60  *
61  * @mtsafety src cannot be modified concurrently; dest cannot be
62  * not modified or read concurrently.
63 */
64 OSAPIDllExport void
65 OSAPI_Memory_copy(void *dest,const void *src, RTI_SIZE_T size);
66 
67 
68 /*e \ingroup OSAPI_MemoryClass
69  * \brief Sets memory region to 0.
70  *
71  * \details
72  * Clear a memory region. Valid memory >= size, where size >= 0. On On success
73  * [mem, mem+size) is filled with 0.
74  *
75  * @param mem \b Out. Pointer to memory region to be modified.
76  * @param size \b In. Number of bytes to fill with zeroes, starting at mem.
77  *
78  * @exception None.
79  *
80  * @mtsafety mem cannot be modified or read concurrently.
81  */
82 OSAPIDllExport void
83 OSAPI_Memory_zero(void *mem, int size);
84 
85 
86 /*e \ingroup OSAPI_MemoryClass
87  * \brief Byte-wise compare of two memory regions.
88  *
89  * \details
90  * This function performs a byte-wise comparison of two memory regions
91  * of size bytes. left and right must be >= 0 and size >= 0. This function
92  * does not alter any memory content.
93  * *
94  * @param left \b In. Pointer to logical "left" side of the inequality test.
95  * @param right \b In. Pointer to logical "right" side of the inequality test.
96  * @param size \b In. Number of bytes to compare, starting from left to right.
97  *
98  * @return less than, equal to, or greater than 0, according to whether left is
99  * lexicographically less than, equal to, or greater than right when
100  * taken as unsigned characters.
101  *
102  */
103 MUST_CHECK_RETURN OSAPIDllExport RTI_INT32
104 OSAPI_Memory_compare(const void *left,const void *right, RTI_SIZE_T size);
105 
106 /*e \ingroup OSAPI_MemoryClass
107  * \brief Moves size bytes from non-overlapping src to dest.
108  *
109  * \details
110  * Moves size bytes from non-overlapping src to dest. Valid dest and
111  * src >= size, where size >= 0. The src and dst memory regions may
112  * overlap. On success size number of bytes from right is moved to
113  * [dest, dest+size) and is identical to[src, src+size)
114  *
115  * @param dest \b Out. Pointer to destination memory region.
116  * @param source \b In. Pointer to source memory region.
117  * @param size \b In. Number of bytes to copy starting at dest.
118  *
119  * @exception None.
120  *
121  * @mtsafety src cannot be modified concurrently; dest cannot be
122  * not modified or read concurrently.
123  */
124 OSAPIDllExport void
125 OSAPI_Memory_move(void *dest,const void *source, RTI_SIZE_T size);
126 
127 /*e \ingroup OSAPI_MemoryClass
128  * \brief Locate byte in byte string
129  *
130  * \details
131  * Locate byte in byte string
132  *
133  * @param[in] s - Pointer to beginning of byte string
134  * @param[in] c - Byte to search for
135  * @param[in] n - Maximum search length
136  *
137  * @return pointer to first occurence of c if found, NULL otherwise.
138  */
139 MUST_CHECK_RETURN OSAPIDllExport void*
140 OSAPI_Memory_fndchr(const void *s, RTI_INT32 c, RTI_SIZE_T n);
141 
142 /*e \ingroup OSAPI_MemoryClass
143  * \brief Return length of ASCIIZ string
144  *
145  * \details
146  * Return length of ASCIIZ string not including \0
147  *
148  * @param[in] s - Pointer to beginning of byte string
149  *
150  * @return Length of string not including \0
151  */
152 MUST_CHECK_RETURN OSAPIDllExport RTI_SIZE_T
153 OSAPI_String_length(const char *s);
154 
155 /*e \ingroup OSAPI_MemoryClass
156  * \brief Compare two ASCIIZ strings
157  *
158  * \details
159  *
160  * Lexicographically compare the null-terminated strings l and r. The
161  * comparison is using unsigned arithmetic.
162  *
163  * @param[in] l - Left side string
164  * @param[in] r - Right side string
165  *
166  * @return 0 is strings are identical, > 0 if l > s and < 0 if l < s.
167  */
168 MUST_CHECK_RETURN OSAPIDllExport RTI_INT32
169 OSAPI_String_cmp(const char *l,const char *r);
170 
171 /*e \ingroup OSAPI_MemoryClass
172  * \brief Compare two ASCIIZ strings
173  *
174  * \details
175  *
176  * Lexicographically compare null-terminated strings l and r,
177  * including up to num characters (if the null terminator is not found before
178  * the specified number of characters has been compared).
179  * The comparison is using unsigned arithmetic.
180  *
181  * @param[in] l - Left side string
182  * @param[in] r - Right side string
183  * @param[in] num - Maximum number of characters to compare
184  *
185  * @return 0 is strings are identical, > 0 if l > s and < 0 if l < s.
186  */
187 MUST_CHECK_RETURN OSAPIDllExport RTI_INT32
188 OSAPI_String_ncmp(const char *l,const char *r, RTI_SIZE_T num);
189 
190 /* pick up hidden performance boosting macros and optimizations */
191 #ifdef __cplusplus
192 } /* extern "C" */
193 #endif
194 
195 #include "osapi/osapi_string_impl.h"
196 
197 #endif /* osapi_string_h */

RTI Connext Micro Version 2.4.1.0 Copyright © Thu Nov 20 2014 Real-Time Innovations, Inc