- HandlerMinelayerData: BUILD_RTI Guards für RTI-Abhängigkeiten - svcTabCommon: Export-Header-Fix via Fallback-Target - TrainingAreaBase: Stub-Header für BUILD_RTI=OFF - ddsfts: Include-Pfad und Dependency-Fixes - BUILD_RTI=OFF Compilation vollständig unterstützt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 01M0JNZA586SACX1PRZ2DJAE5S
952 lines
31 KiB
C
952 lines
31 KiB
C
/*
|
|
* (c) Copyright, Real-Time Innovations, 2002-2026.
|
|
* All rights reserved.
|
|
* No duplications, whole or partial, manual or electronic, may be made
|
|
* without express written permission. Any such copies, or
|
|
* revisions thereof, must display this notice unaltered.
|
|
* This code contains trade secrets of Real-Time Innovations, Inc.
|
|
*/
|
|
|
|
#ifndef reda_string_h
|
|
#define reda_string_h
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "osapi/osapi_type.h"
|
|
#include "reda/reda_dll.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Doxygen file & module documentation ==================================*/
|
|
/*e \file
|
|
|
|
\brief Defines the REDAString
|
|
*/
|
|
|
|
/*e \defgroup REDAStringClass REDAString
|
|
\ingroup REDAModule
|
|
@brief string utilities.
|
|
*/
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
Portable isspace
|
|
*/
|
|
extern REDADllExport int REDAString_isspace(int ch);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/**
|
|
* @ingroup REDAStringClass
|
|
*
|
|
* @brief Returns the first character position in @p str after the leading
|
|
* spaces.
|
|
*
|
|
* @param[in] str String to be processed.
|
|
*
|
|
* @return Pointer to the first non-space character in @p str, or to the
|
|
* end of the string if no non-space character is found.
|
|
*/
|
|
extern REDADllExport const char *REDAString_skipSpaces(const char *str);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/**
|
|
* @ingroup REDAStringClass
|
|
*
|
|
* @brief Returns a pointer to the end of the string, excluding trailing spaces.
|
|
*
|
|
* This function scans the string from the beginning, tracking the last
|
|
* non-whitespace character found, and returns a pointer to the character
|
|
* immediately after that.
|
|
*
|
|
* @param[in] str String to be processed.
|
|
*
|
|
* @return Pointer to the position just after the last non-space character in @p
|
|
* str, or the start of the string if the string contains only spaces.
|
|
*/
|
|
extern REDADllExport const char *REDAString_skipTailSpaces(const char *str);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
Skips a word at the beginning of str ignoring any leading spaces
|
|
in str. The function returns the position in str where word ends,
|
|
or NULL if no such word exists.
|
|
*/
|
|
extern REDADllExport const char *REDAString_skipWord(
|
|
const char *str,
|
|
const char *word);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Get the length of the token pointed by "s", given that character "c" is
|
|
the delimitor.
|
|
|
|
This method has the advantage over strtok() in that it doesn't alter
|
|
the string being passed in. Instead, a pointer to the next token is
|
|
returned.
|
|
|
|
@param tokenLength \b Out. The length of the current token pointed by s.
|
|
@param s \b In. The string to be tokenized. Cannot be NULL.
|
|
@param c \b In. Character to be used as the delimitor.
|
|
|
|
@return Pointer to the next token.
|
|
*/
|
|
extern REDADllExport const char *REDAString_getToken(
|
|
size_t *tokenLength,
|
|
const char *s,
|
|
char c);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
|
|
@brief Get a pointer to the last token pointed by "str", where tokens are
|
|
delimited by "separator"
|
|
|
|
@param str \st_in. The string to be tokenized. Cannot be NULL.
|
|
@param separator \st_in. Character to be used as the delimitor.
|
|
|
|
@return Pointer to the last token.
|
|
*/
|
|
extern REDADllExport const char *REDAString_getLastToken(
|
|
const char *str,
|
|
char separator);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
|
|
@brief Get the number of tokens delimited by \c separator in the
|
|
string \c string.
|
|
|
|
@param string \st_in. The string to be tokenized. Can be NULL.
|
|
@param separator \st_in. Character to be used as the delimitor.
|
|
|
|
@return Number of tokens separated by \c separator.
|
|
*/
|
|
extern REDADllExport size_t
|
|
REDAString_getTokenCount(const char *str, char separator);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to determine if the given strings,
|
|
containing elements separated by the given
|
|
delimitor, have a common element. Note that spaces before and after a
|
|
delimitor will be counted as part of the element as well.
|
|
Elements of zero length are considered as valid strings.
|
|
|
|
@param delimitorSeparatedString1 \b In. String containing elements separated
|
|
by delimitor. Cannot be NULL.
|
|
|
|
@param delimitorSeparatedString2 \b In. String containing elements separated
|
|
by delimitor. Cannot be NULL.
|
|
|
|
@param delimitor \b In. Delimitor to be used to separate elements in strings.
|
|
|
|
@return RTI_TRUE if there is a common element. RTI_FALSE otherwise.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_hasCommonElement(
|
|
const char *delimitorSeparatedString1,
|
|
const char *delimitorSeparatedString2,
|
|
char delimitor);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/**
|
|
* @ingroup REDAStringClass
|
|
*
|
|
* @brief Determines whether two delimiter-separated string lists share an
|
|
* element after ignoring leading and trailing whitespace from each element.
|
|
* Comparison is case-insensitive and elements of zero length are considered
|
|
* valid.
|
|
*
|
|
* @param[in] delimitorSeparatedString1 String containing elements separated by
|
|
* @p delimitor. Cannot be \c NULL.
|
|
* @param[in] delimitorSeparatedString2 String containing elements separated by
|
|
* @p delimitor. Cannot be \c NULL.
|
|
* @param[in] delimitor Delimiter used to separate elements in the strings.
|
|
*
|
|
* @return `RTI_TRUE` if the lists share a common element; `RTI_FALSE`
|
|
* otherwise.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_iHasCommonElementTrimmed(
|
|
const char *delimitorSeparatedString1,
|
|
const char *delimitorSeparatedString2,
|
|
char delimitor);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to determine if the given strings,
|
|
containing elements separated by the given
|
|
delimitor, have a matching element (wild card matching).
|
|
Note that spaces before and after a
|
|
delimitor will be counted as part of the element as well.
|
|
Elements of zero length are considered as valid element and be treated
|
|
as a normal string.
|
|
|
|
@param delimitorSeparatedString \b In. String containing elements separated
|
|
by delimitor. Cannot be NULL.
|
|
|
|
@param delimitorSeparatedString \b In. String containing elements
|
|
separated by delimitor. Cannot be NULL.
|
|
|
|
@param delimitor \b In. Delimitor to be used to separate elements in strings.
|
|
|
|
@return RTI_TRUE if there is a matching element. RTI_FALSE otherwise.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_hasMatchingElement(
|
|
const char *delimitorSeparatedString1,
|
|
const char *delimitorSeparatedString2,
|
|
char delimitor);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Returns true if two input list of patterns (delimitorSeparatedString1 and
|
|
delimitorSeparatedString2) intersect with each other.
|
|
|
|
A pattern has the form:
|
|
|
|
<fnmatch expr 1>/../<fnmatch expr n>[<delimitor><fnmatch expr 1>/../<fnmatch
|
|
expr n>]
|
|
|
|
@param delimitorSeparatedString1 \b In. First list of patterns
|
|
@param delimitorSeparatedString1 \b In. Second list of patterns
|
|
@param delimitor \b In. List delimitor
|
|
@param matchFlags \b In. Match flags. Match flags is a mask where the bits
|
|
are the constants with prefix REDA_STRING_FNM_xxx
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_hasIntersectingPattern(
|
|
const char *delimitorSeparatedString1,
|
|
const char *delimitorSeparatedString2,
|
|
char delimitor,
|
|
int *matchFlags);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to determine if the given string is a pattern (wildcard).
|
|
|
|
@param str \b In. String to determine if it is a pattern. Cannot be NULL.
|
|
|
|
@return RTI_TRUE if string is a pattern. RTI_FALSE otherwise.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_isPattern(const char *str);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to determine if the given string,
|
|
containing elements separated by the given
|
|
delimitor, have only pattern elements (wildcard elements).
|
|
|
|
@param delimitorSeparatedString \b In. String containing elements separated
|
|
by delimitor. Cannot be NULL.
|
|
|
|
@param delimitor \b In. Delimitor to be used to separate elements in strings.
|
|
|
|
@return RTI_TRUE if all elements are patterns. RTI_FALSE otherwise.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_hasPatternsOnly(const char *s, char c);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to copy supply strdup on OSes that lack it.
|
|
|
|
@note may be macroed for performance
|
|
*/
|
|
extern REDADllExport char *REDAString_duplicate(const char *s);
|
|
|
|
/*e
|
|
* \ingroup REDAStringClass
|
|
*
|
|
* Static method to allocate a buffer and copy s into the buffer. We will
|
|
* only copy a maximum of maxBytes bytes into the string and
|
|
* will NULL terminate the buffer.
|
|
*
|
|
* @param s string to copy
|
|
* @param maxBytes maximum number of bytes to duplicate from s into new string.
|
|
* The string will be null terminated, so the maximum size allocated for the
|
|
* new string will be (maxBytes + 1)
|
|
*
|
|
* @return pointer to new string
|
|
*/
|
|
extern REDADllExport char *REDAString_nDuplicate(
|
|
const char *s,
|
|
size_t maxBytes);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Removes trailing spaces by zeroing them
|
|
|
|
*/
|
|
extern void REDAString_trimEnd(char *s);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Static method to print the byte value of the given buffer in hex format.
|
|
|
|
@param buffer \b In. Buffer to be printed.
|
|
@param bufferSize \b In. Number of bytes to be printed from buffer.
|
|
*/
|
|
extern REDADllExport void REDAString_printBytes(
|
|
const char *buffer,
|
|
int bufferSize);
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Default amount of indentation for each level.
|
|
*/
|
|
extern REDADllVariable const int REDA_STRING_INDENT_AMOUNT;
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Print indentation according to the default indent amount.
|
|
|
|
@param indent \b In. Indentation level.
|
|
*/
|
|
extern REDADllExport void REDAString_printIndent(int indent);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
|
|
Print space.
|
|
|
|
@param count \b In. Number of space.
|
|
*/
|
|
extern REDADllExport void REDAString_printSpace(int count);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* String comparison.
|
|
* @param s1 \b In. String to compare.
|
|
* @param s2 \b In. String to compare.
|
|
*/
|
|
extern REDADllExport int REDAString_compare(const char *s1, const char *s2);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Case insensitive comparison
|
|
*/
|
|
extern REDADllExport int REDAString_iCompare(const char *s1, const char *s2);
|
|
|
|
/**
|
|
* @ingroup REDAStringClass
|
|
*
|
|
* @brief Compares two strings case-insensitively, ignoring leading and
|
|
* trailing whitespaces.
|
|
*
|
|
* @param[in] s1 First string to compare. Cannot be \c NULL.
|
|
* @param[in] s2 Second string to compare. Cannot be \c NULL.
|
|
*
|
|
* @return Negative value if @p s1 is lexicographically less than @p s2,
|
|
* positive value if @p s1 is greater, or zero if they are equal after
|
|
* trimming and ignoring case.
|
|
*/
|
|
extern REDADllExport int REDAString_iCompareTrimmed(
|
|
const char *s1,
|
|
const char *s2);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Case insensitive comparison
|
|
*/
|
|
extern REDADllExport int REDAString_inCompare(
|
|
const char *s1,
|
|
const char *s2,
|
|
size_t n);
|
|
|
|
/* e \ingroup REDAStringClass
|
|
* Gives the last occurrance of needle in the haystack by efficiently searching
|
|
* from the end of the string.
|
|
* @param haystack \b In. String to conduct the search in.
|
|
* @param needle \b In. String to search for.
|
|
*/
|
|
extern REDADllExport char *REDAString_strstrLast(
|
|
const char *haystack,
|
|
const char *needle);
|
|
|
|
/* e \ingroup REDAStringClass
|
|
* Gives the last occurrance of needle in the haystack by efficiently searching
|
|
* from the end of the string as indicated by haystackLength.
|
|
* @param haystack \b In. String to conduct the search in.
|
|
* @param haystackLength \b In. The length of the haystack to conduct the search
|
|
* in.
|
|
* @param needle \b In. String to search for.
|
|
*/
|
|
extern REDADllExport char *REDAString_strstrnLast(
|
|
const char *haystack,
|
|
size_t haystackLength,
|
|
const char *needle);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Find a string s2 in string s1 ( Case Insensitive)
|
|
*/
|
|
extern REDADllExport char *REDAString_iFindSubString(
|
|
const char *s1,
|
|
const char *s2);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Returns the Boolean represented by str.
|
|
|
|
Valid values are: 1,0,true,false,yes,no (case insensitive)
|
|
*/
|
|
extern REDADllExport RTIBool
|
|
REDAString_strToBoolean(const char *str, RTIBool *boolOut);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
This method validates if in_string is present in reference_strings
|
|
array. If inString is not present then it will provide the index
|
|
of the string in the reference_strings which is the closest match.
|
|
The method expects the last string in the reference_strings array
|
|
to be a empty string.
|
|
|
|
The method returns RTI_TRUE if a perfect match is found else it
|
|
returns RTI_FALSE,index will have the index of the string
|
|
within the reference_strings array which is the closest match and
|
|
diff will have distance between the input string and the closest
|
|
match.
|
|
*/
|
|
extern REDADllExport RTIBool REDAString_validateName(
|
|
int *index,
|
|
int *diff,
|
|
char *inString,
|
|
const char **referenceStrings,
|
|
RTIBool caseSensitive);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
|
|
* Compares a filename or pathname to a pattern.
|
|
*/
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* fnmatch() return values. */
|
|
#define REDA_STRING_FNM_NOMATCH 1 /* Match failed. */
|
|
|
|
/* fnmatch() flags. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Normally, every occurrence of a backslash ('\') followed by a character
|
|
in pattern is replaced by that character.
|
|
|
|
If REDA_STRING_FNM_NOESCAPE flag is set, a backslash character in pattern
|
|
parameter is treated as an ordinary character.
|
|
*/
|
|
#define REDA_STRING_FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
If the REDA_STRING_FNM_PATHNAME flag is not set, the / in string parameter is
|
|
treated as an ordinary character.
|
|
|
|
If the REDA_STRING_FNM_PATHNAME flag is set in the flags parameter, a /
|
|
(slash) in the string parameter is explicitly matched by a / in the pattern
|
|
parameter. It is not matched by either the * (asterisk) or ? (question-mark)
|
|
special characters, nor by a bracket expression. Slash in the string parameter
|
|
only matches slash in the pattern parameter.
|
|
*/
|
|
#define REDA_STRING_FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
If REDA_STRING_FNM_PERIOD is not set, no special restrictions are placed on
|
|
matching a period in string parameter.
|
|
|
|
If REDA_STRING_FNM_PERIOD is set in the flags parameter, then a leading period
|
|
in the string parameter only matches a period in the pattern parameter; it is
|
|
not matched by either the asterisk or question-mark special characters, not by
|
|
a bracket expression. A period is determined to be leading according to the
|
|
setting of the REDA_STRING_FNM_PATHNAME flag, according to the following
|
|
rules:
|
|
|
|
If the REDA_STRING_FNM_PATHNAME flag is set, a period is leading only if it is
|
|
the first character in the string parameter or if it immediately follows a
|
|
slash.
|
|
|
|
If the REDA_STRING_FNM_PATHNAME flag is not set, a period is leading only if
|
|
it is the first character of the string parameter.
|
|
*/
|
|
#define REDA_STRING_FNM_PERIOD 0x04 /* Period must be matched by period. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
If this flag is set, the pattern is considered to be matched if it
|
|
matches an initial segment of string which is followed by a slash.
|
|
*/
|
|
#define REDA_STRING_FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
The pattern is matched in a case-insensitive fashion.
|
|
*/
|
|
#define REDA_STRING_FNM_CASEFOLD 0x10 /* Case insensitive search. */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Applies if REDA_STRING_FNM_PATHNAME and NOT REDA_STRING_FNM_PERIOD.
|
|
Redefines the path delimiter as a "." instead of a "/"
|
|
*/
|
|
#define REDA_STRING_FNM_DOTTED_PATH 0x20 /* Changes Slash to a Period */
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* Indicates if the matching is done between UTF-8 strings
|
|
*/
|
|
#define REDA_STRING_FNM_UTF8 0x40
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* Indicates if quotes should be removed from the input filter expression.
|
|
* Quotes are not removed when using the SQL filter because the quotes are
|
|
* considered part of the expression.
|
|
* For example, the following filter expression:
|
|
* "x MATCH '\\'hello\\''"
|
|
*
|
|
* should match 'hello', not hello.
|
|
*
|
|
* When the SQL filter is not being used, the quotes should be removed because
|
|
* they are artifacts of how the expressions are stored in memory and not part
|
|
* of the expression themselves.
|
|
*/
|
|
#define REDA_STRING_FNM_REMOVE_QUOTES 0x80
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Returns zero if string matches pattern, REDA_STRING_FNM_NOMATCH if there is
|
|
no match or another non-zero value if there is an error.
|
|
*/
|
|
extern REDADllExport int REDAString_fnmatch(
|
|
const char *matchPattern,
|
|
const char *matchString,
|
|
int matchFlags);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Returns REDA_STRING_FNM_MATCH if patterns intersect, or
|
|
REDA_STRING_FNM_NOMATCH if there is no match.
|
|
*/
|
|
extern REDADllExport int REDAString_isCommonPattern(
|
|
const char *left,
|
|
const char *right,
|
|
void *flagRef);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
typedef enum {
|
|
SQL_OP_EQ,
|
|
SQL_OP_NE,
|
|
SQL_OP_GT,
|
|
SQL_OP_LT,
|
|
SQL_OP_GE,
|
|
SQL_OP_LE,
|
|
SQL_OP_BT,
|
|
SQL_OP_MATCH
|
|
} SQLRelationshipKind;
|
|
|
|
typedef struct SQL_filter_term *SQL_filter_term_ptr;
|
|
|
|
typedef struct SQL_filter_term {
|
|
SQL_filter_term_ptr next_AND; /* next term in AND expression */
|
|
SQL_filter_term_ptr next_OR; /* next term in OR expression */
|
|
SQL_filter_term_ptr tail; /* last term in AND expression */
|
|
SQL_filter_term_ptr clone_tail; /* last cloneable term in AND expression */
|
|
char *field; /* sample field name */
|
|
char *expr; /* filter expression */
|
|
char *expr_two; /* second expression for BETWEEN */
|
|
SQLRelationshipKind opcode; /* SQL opcode */
|
|
RTIBool cloned; /* cloned node owns no memory */
|
|
} SQL_filter_term;
|
|
|
|
typedef struct {
|
|
char *filterParameters;
|
|
int parameterLength;
|
|
} SQL_filter_parameters;
|
|
|
|
extern REDADllExport RTIBool REDAString_isSQLNumericRelationshipIntersect(
|
|
SQL_filter_term *left,
|
|
SQL_filter_term *right);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Character encodings
|
|
*/
|
|
typedef enum {
|
|
REDA_CHARACTER_ENCODING_UTF8,
|
|
REDA_CHARACTER_ENCODING_ISO_8859_1,
|
|
REDA_CHARACTER_ENCODING_UNKNOWN
|
|
} REDACharacterEncodingKind;
|
|
|
|
/*e \ingroup REDAStringClass
|
|
Unicode normalization kinds
|
|
*/
|
|
typedef enum {
|
|
REDA_UNICODE_NORMALIZATION_OFF,
|
|
REDA_UNICODE_NORMALIZATION_NFD,
|
|
REDA_UNICODE_NORMALIZATION_NFC,
|
|
REDA_UNICODE_NORMALIZATION_NFKD,
|
|
REDA_UNICODE_NORMALIZATION_NFKC,
|
|
REDA_UNICODE_NORMALIZATION_NFKC_CASEFOLD,
|
|
REDA_UNICODE_NORMALIZATION_UNKNOWN
|
|
} REDAUnicodeNormalizationKind;
|
|
|
|
extern REDADllExport RTIBool REDAString_hasIntersectingFilter(
|
|
const char *s1,
|
|
const char *s2,
|
|
char c,
|
|
SQL_filter_parameters *contentFilter,
|
|
REDACharacterEncodingKind characterEncodingKind,
|
|
REDAUnicodeNormalizationKind normalizationKind,
|
|
RTIBool supportsEscapedCharacters);
|
|
|
|
extern REDADllExport RTIBool
|
|
REDAString_strToLong(const char *str, RTI_INT32 *longOut);
|
|
|
|
extern REDADllExport RTIBool
|
|
REDAString_strToLongLong(const char *str, RTI_INT64 *longOut);
|
|
|
|
extern REDADllExport RTIBool
|
|
REDAString_strToUnsignedShort(const char *str, RTI_UINT16 *shortOut);
|
|
|
|
extern REDADllExport RTIBool
|
|
REDAString_strToUnsignedLong(const char *str, RTI_UINT32 *unsignedLongOut);
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
/*e \ingroup REDAStringClass
|
|
A version of strtok that doesn't have any internal state. To use it:
|
|
|
|
\verbatim
|
|
char * token;
|
|
char * strTokenSave;
|
|
|
|
token = strtoken(expression, DELIM, &strTokenSave);
|
|
token = strtoken(NULL, DELIM, &strTokenSave);
|
|
\endverbatim
|
|
*/
|
|
extern REDADllExport char *REDAString_strToken(
|
|
char *s1,
|
|
const char *delim,
|
|
char **save);
|
|
|
|
/** @ingroup REDAStringClass
|
|
*
|
|
* Performs an strstr() of 'substr' on the unescaped part of the specified
|
|
* string.
|
|
*
|
|
* This operation will attempt to find the substring, skipping first a escaped
|
|
* part between double quotes. For example, given the string:
|
|
* "first::second"::third
|
|
*
|
|
* This operation will start looking for the input substring only after the
|
|
* second '"'. If the input substring is '::', this operation will return
|
|
* a pointer to the substring '::third'.
|
|
|
|
* If the input string is not escaped, or the closing '"' is not found,
|
|
* this operation returns performs the strstr() starting on the first character.
|
|
|
|
*
|
|
* @param[in] str Input string to search within. It may be escaped.
|
|
* @param[in] substr Substring to be found
|
|
*
|
|
* @return A pointer within \p str where the first occurrence of \p substr is
|
|
* found, or NULL otherwise
|
|
*/
|
|
extern REDADllExport const char *REDAString_strstrEscaped(
|
|
const char *str,
|
|
const char *substr);
|
|
|
|
/** @ingroup REDAStringClass
|
|
*
|
|
* Performs an strcmp() of 'left' and 'right'.
|
|
*
|
|
* This function is a wrapper around RTIOsapiUtility_strcmp (which is a macro).
|
|
* Sometimes we require a function that we can cast to the
|
|
* REDAOrderedDataTypeCompareFunction type.
|
|
*
|
|
* @see strcmp
|
|
*/
|
|
extern REDADllExport RTI_INT32
|
|
REDAString_strcmp(const char *left, const char *right);
|
|
|
|
/** @ingroup REDAStringClass
|
|
*
|
|
* Performs an strcmp() of the unescaped part of 'left' and 'right'.
|
|
*
|
|
* The unescaped part of the input parameters is the part between the
|
|
* name-escaping double quoutes '"'. If the input string is not escaped, it
|
|
* will be used as such
|
|
*
|
|
* @see strcmp
|
|
* @see REDAString_strstrEscaped
|
|
*/
|
|
extern REDADllExport RTI_INT32
|
|
REDAString_strcmpEscaped(const char *left, const char *right);
|
|
|
|
/**
|
|
* @brief Returns the unscaped part of the specified name
|
|
*
|
|
* This operation will attempt to extract the substring contained between double
|
|
* quotes. For example, given the string:
|
|
* "[name]"
|
|
*
|
|
* This operation will copy [name] into the specified output parameter, and
|
|
* also provide as return value. Note that if the provide name has more
|
|
* content, this operation will ignore the rest. For example:
|
|
* "[name]"otherpart
|
|
*
|
|
* will ignore "otherparh" and still return [name].
|
|
*
|
|
* If the input escaped name is actually not escaped, this operation returns
|
|
* directly the input value.
|
|
*
|
|
* If the syntax is incorrect, this operation will log an error and return NULL.
|
|
*
|
|
* @param[out] outName Contains the copy of the unescaped part of the name.
|
|
* Buffer size must RTIXML_OBJECT_MAX_NAME_LENGTH + 1.
|
|
* @param[in] outNameLengthMax Maximum length that \p outName can hold
|
|
* @param[in] escapedName Input escaped name.
|
|
*
|
|
* @return outName if the name is properly escaped,
|
|
* escapedName if the name is not escaped or,
|
|
* NULL if the syntax is valid or the name bigger than
|
|
* outNameLengthMax
|
|
*/
|
|
extern REDADllExport const char *REDAString_getEscapedName(
|
|
char *outName,
|
|
RTI_UINT32 outNameLengthMax,
|
|
const char *escapedName);
|
|
|
|
#define REDAString_nullSafe(str, strWhenNull) (str != NULL ? str : strWhenNull)
|
|
|
|
/******************************************************************************/
|
|
/* UTF-8 String operations */
|
|
/******************************************************************************/
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Converts a character encoding to the corresponding
|
|
* enumeration value.
|
|
*
|
|
* The possible value for strings:
|
|
* "UTF-8", "ISO-8859-1"
|
|
*
|
|
* If none of these strings are provided the function returns
|
|
* REDA_CHARACTER_ENCODING_UNKNOWN
|
|
*/
|
|
extern REDADllExport REDACharacterEncodingKind
|
|
REDACharacterEncodingKind_fromString(const char *str);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Converts a string value to the corresponding
|
|
* normalization enumeration value.
|
|
*
|
|
* The possible value for strings:
|
|
* "OFF", "NFD", "NFC", "NFKC", "NFKD", "NFKC_CASEFOLD"
|
|
*
|
|
* If none of these strings are provided the function returns
|
|
* REDA_UNICODE_NORMALIZATION_UNKNOWN
|
|
*/
|
|
extern REDADllExport REDAUnicodeNormalizationKind
|
|
REDAUnicodeNormalizationKind_fromString(const char *str);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Invalid UTF-8 string error code.
|
|
*/
|
|
#define REDA_UNICODE_INVALID_UTF8 -1
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Not enough space to store string error code.
|
|
*/
|
|
#define REDA_UNICODE_NOT_ENOUGH_SPACE -2
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Error code.
|
|
*/
|
|
#define REDA_UNICODE_ERROR -3
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Success return code
|
|
*/
|
|
#define REDA_UNICODE_OK 0
|
|
|
|
typedef RTI_INT32 REDAUnicodeRetCode;
|
|
|
|
extern REDADllExport RTIBool REDAString_hasMatchingElementX(
|
|
RTIBool *hasMatchingElement,
|
|
const char *delimitorSeparatedString1,
|
|
const char *delimitorSeparatedString2,
|
|
char delimitor,
|
|
RTI_INT32 flags,
|
|
REDAUnicodeNormalizationKind normalizationKind,
|
|
RTIBool tokenizeS1);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Normalizes the input UTF-8 string 'str' and return the result in
|
|
* 'normalizedStr'.
|
|
*
|
|
* @param str \b In. UTF-8 String to be normalized. Cannot be NULL.
|
|
* @param normalizedStr \b Out. String that will contain the result of the
|
|
* normalization.
|
|
* @param normalizedStrLength \b InOut. When \p normalizedStr is set to NULL,
|
|
* after the function executes, \p normalizedStrLength will contain the length
|
|
* in bytes of the normalized string without including the NULL-terminated
|
|
* character. When \p normalizedStr is not NULL, \p normalizedStrLength
|
|
* must contain the maximum length of the normalized string when the function
|
|
* is invoked. After the function is invoked, \p normalizedStrLength will be
|
|
* updated to contain the actual length of the normalized string if the return
|
|
* codes are REDA_UNICODE_NOT_OK or REDA_UNICODE_NOT_ENOUGH_SPACE.
|
|
*
|
|
* @return REDA_UNICODE_OK if success. REDA_UNICODE_NOT_ENOUGH_SPACE if the
|
|
* input normalizedStrLength is not enough to store the normalized result into
|
|
* normalizedStr. REDA_UNICODE_INVALID_UTF8 if the input string is not
|
|
* valid. Otherwise, REDA_UNICODE_ERROR.
|
|
*/
|
|
extern REDADllExport REDAUnicodeRetCode REDAString_utf8Normalize(
|
|
const char *str,
|
|
char *normalizedStr,
|
|
RTI_UINT32 *normalizedStrLength,
|
|
REDAUnicodeNormalizationKind normalizationKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Compares two UTF-8 strings using the normalization schema provided
|
|
* as a parameter.
|
|
*
|
|
* The function may allocate memory if the length of the normalized strings
|
|
* is greater than 128 characters. If for some reason the memory allocation
|
|
* fails, the method will print return REDA_UNICODE_ERROR.
|
|
*
|
|
*
|
|
* @param result \b Out. < 0 if s1 < s2. > 0 if s1 > s2. 0 if s1 = s2.
|
|
* @param s1 \b In. First string.
|
|
* @param s2 \b In. Second string.
|
|
* @param normalizationKind \b In. Normalization schema.
|
|
*
|
|
* @return REDA_UNICODE_OK if success. Otherwise, REDA_UNICODE_ERROR.
|
|
*/
|
|
extern REDADllExport REDAUnicodeRetCode REDAString_utf8Compare(
|
|
int *result,
|
|
const char *s1,
|
|
const char *s2,
|
|
REDAUnicodeNormalizationKind normalizationKind);
|
|
|
|
/*i \ingroup REDAStringClass
|
|
* @brief Determine if a string is numeric.
|
|
*
|
|
* @param s1 String to check
|
|
* @param isFloat Out. Set to TRUE if the string contains a decimal ('.') or
|
|
* an exponent ('e' or 'E').
|
|
*
|
|
* @return RTI_TRUE if string is numeric, RTI_FALSE if it is not.
|
|
*/
|
|
extern REDADllExport RTIBool
|
|
REDAString_isNumeric(const char *s1, RTIBool *isFloat);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Gets the first character and advances to the next.
|
|
*
|
|
* @param str \b InOut. *str will be set to the position of the next character.
|
|
* @param c \b Out. Codepoint representing the first character.
|
|
* @param encodingSize \b Out. Size of the first character.
|
|
* @param encodingKind \In. Encoding kind.
|
|
*
|
|
* If the first character is not a valid UTF-8 character, the implementation
|
|
* assumes that the character is one byte long.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
void REDAString_getCharAndNext(
|
|
char **str,
|
|
RTI_INT32 *c,
|
|
RTI_INT32 *encodingSize,
|
|
REDACharacterEncodingKind encodingKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Gets the first character.
|
|
*
|
|
* @param str \b In. The string.
|
|
* @param c \b Out. Codepoint representing the first character.
|
|
* @param encodingSize \b Out. Size of the first character.
|
|
* @param encodingKind \In. Encoding kind.
|
|
*
|
|
* If the first character is not a valid UTF-8 character, the
|
|
* implementation assumes that the character is one byte long.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
void REDAString_getChar(
|
|
const char *str,
|
|
RTI_INT32 *c,
|
|
RTI_INT32 *encodingSize,
|
|
REDACharacterEncodingKind encodingKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Gets the character at position 'position'.
|
|
*
|
|
* The position starts at 0.
|
|
*
|
|
* @param str \b In. The string.
|
|
* @param c \b Out. Codepoint representing the character at position.
|
|
* @param encodingSize \b Out. Size of the the character at position.
|
|
* @param position \b In. Character position.
|
|
* @param encodingKind \In. Encoding kind.
|
|
*
|
|
* If any of the characters up to the one in position are not valid, the
|
|
* implementation assumes that all the characters including the one at
|
|
* position are one byte long.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
void REDAString_getCharAt(
|
|
const char *str,
|
|
RTI_INT32 *c,
|
|
RTI_INT32 *encodingSize,
|
|
RTI_INT32 position,
|
|
REDACharacterEncodingKind encodingKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Advances to the next character.
|
|
*
|
|
* @param str \b InOut. *str will be set to the position of the next
|
|
* character.
|
|
* @param encodingKind \In. Encoding kind.
|
|
*
|
|
* If the next character is not a valid UTF-8 character, the
|
|
* implementation assumes that the next character is one byte long.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
void REDAString_nextChar(
|
|
const char **str,
|
|
REDACharacterEncodingKind encodingKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Goes to the previous character.
|
|
*
|
|
* @param str \b InOut. *str will be set to the position of the previous
|
|
* character.
|
|
* @param encodingKind \In. Encoding kind.
|
|
*
|
|
* If the previous character is not a valid UTF-8 character, the implementation
|
|
* assumes that the previous character is one byte long.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
void REDAString_prevChar(
|
|
const char **str,
|
|
REDACharacterEncodingKind encodingKind);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Return the codepoint of the corresponding lower-case character.
|
|
*
|
|
* @param c \b In. The codepoint.
|
|
*
|
|
* @return The codepoint of the corresponding
|
|
* lower-case character, if any; otherwise (if there is no lower-case
|
|
* variant, or if `c` is not a valid codepoint) return 'c'.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
RTI_INT32 REDAChar_toLower(RTI_INT32 c);
|
|
|
|
/*e \ingroup REDAStringClass
|
|
* @brief Return the codepoint of the corresponding upper-case character.
|
|
*
|
|
* @param c \b In. The codepoint.
|
|
*
|
|
* @return The codepoint of the corresponding
|
|
* upper-case character, if any; otherwise (if there is no upper-case
|
|
* variant, or if `c` is not a valid codepoint) return 'c'.
|
|
*
|
|
* @note This is implemented as a macro for performance reasons.
|
|
*/
|
|
RTI_INT32 REDAChar_toUpper(RTI_INT32 c);
|
|
|
|
#include "reda/reda_string_impl.h"
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif /* reda_string_h */
|