diff -r 59656cd16411 -r b9a6af0ae41a src/ucx/string.h
--- a/src/ucx/string.h Mon Apr 06 16:36:25 2015 +0200
+++ b/src/ucx/string.h Fri Oct 16 19:23:49 2015 +0200
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 2013 Olaf Wintermann. All rights reserved.
+ * Copyright 2015 Olaf Wintermann. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -119,38 +119,36 @@
*/
size_t sstrnlen(size_t count, sstr_t string, ...);
+/**
+ * Concatenates two or more strings.
+ *
+ * The resulting string will be allocated by standard malloc()
.
+ * So developers MUST pass the sstr_t.ptr to free()
.
+ *
+ * The sstr_t.ptr of the return value will always be NULL
-
+ * terminated.
+ *
+ * @param count the total number of strings to concatenate
+ * @param s1 first string
+ * @param s2 second string
+ * @param ... all remaining strings
+ * @return the concatenated string
+ */
+sstr_t sstrcat(size_t count, sstr_t s1, sstr_t s2, ...);
/**
- * Concatenates strings.
- *
- * At least one string must be specified and there must be enough memory
- * available referenced by the destination sstr_t.ptr for this function to
- * successfully concatenate all specified strings.
- *
- * The sstr_t.length of the destination string specifies the capacity and
- * should match the total memory available referenced by the destination
- * sstr_t.ptr. This function never copies data beyond the capacity and
- * does not modify any of the source strings.
+ * Concatenates two or more strings using an UcxAllocator.
*
- * Attention:
- *
NULL
-terminatedNULL
-terminated string by performing
- * mystring.ptr[mystring.length]='\0'
after calling this
- * functiondest
is returned
+ * @param s1 first string
+ * @param s2 second string
+ * @param ... all remaining strings
+ * @return the concatenated string
*/
-sstr_t sstrncat(sstr_t dest, size_t count, sstr_t src, ...);
+sstr_t sstrcat_a(UcxAllocator *a, size_t count, sstr_t s1, sstr_t s2, ...);
/**
@@ -227,7 +225,7 @@
*
*
* The integer referenced by count
is used as input and determines
- * the maximum size of the resulting list, i.e. the maximum count of splits to
+ * the maximum size of the resulting array, i.e. the maximum count of splits to
* perform + 1.
*
* The integer referenced by count
is also used as output and is
@@ -237,36 +235,36 @@
* free()
. Use sstrsplit_a() with
* an allocator to managed memory, to avoid this.
*
* @param string the string to split
* @param delim the delimiter string
- * @param count IN: the maximum size of the resulting list (0 for an
- * unbounded list), OUT: the actual size of the list
- * @return a list of the split strings as sstr_t array or
+ * @param count IN: the maximum size of the resulting array (0 = no limit),
+ * OUT: the actual size of the array
+ * @return a sstr_t array containing the split strings or
* NULL
on error
*
* @see sstrsplit_a()
*/
-sstr_t* sstrsplit(sstr_t string, sstr_t delim, size_t *count);
+sstr_t* sstrsplit(sstr_t string, sstr_t delim, ssize_t *count);
/**
* Performing sstrsplit() using an UcxAllocator.
*
* Read the description of sstrsplit() for details.
*
- * The memory for the sstr_t.ptr pointers of the list items and the memory for
+ * The memory for the sstr_t.ptr pointers of the array items and the memory for
* the sstr_t array itself are allocated by using the UcxAllocator.malloc()
* function.
*
@@ -276,15 +274,15 @@
* @param allocator the UcxAllocator used for allocating memory
* @param string the string to split
* @param delim the delimiter string
- * @param count IN: the maximum size of the resulting list (0 for an
- * unbounded list), OUT: the actual size of the list
- * @return a list of the split strings as sstr_t array or
+ * @param count IN: the maximum size of the resulting array (0 = no limit),
+ * OUT: the actual size of the array
+ * @return a sstr_t array containing the split strings or
* NULL
on error
*
* @see sstrsplit()
*/
sstr_t* sstrsplit_a(UcxAllocator *allocator, sstr_t string, sstr_t delim,
- size_t *count);
+ ssize_t *count);
/**
* Compares two UCX strings with standard memcmp()
.
@@ -385,6 +383,56 @@
*/
int sstrsuffix(sstr_t string, sstr_t suffix);
+/**
+ * Returns a lower case version of a string.
+ *
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup() for the implications.
+ *
+ * @param string the input string
+ * @return the resulting lower case string
+ * @see sstrdup()
+ */
+sstr_t sstrlower(sstr_t string);
+
+/**
+ * Returns a lower case version of a string.
+ *
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup_a() for the implications.
+ *
+ * @param allocator the allocator used for duplicating the string
+ * @param string the input string
+ * @return the resulting lower case string
+ * @see sstrdup_a()
+ */
+sstr_t sstrlower_a(UcxAllocator *allocator, sstr_t string);
+
+/**
+ * Returns a upper case version of a string.
+ *
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup() for the implications.
+ *
+ * @param string the input string
+ * @return the resulting upper case string
+ * @see sstrdup()
+ */
+sstr_t sstrupper(sstr_t string);
+
+/**
+ * Returns a upper case version of a string.
+ *
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup_a() for the implications.
+ *
+ * @param allocator the allocator used for duplicating the string
+ * @param string the input string
+ * @return the resulting upper case string
+ * @see sstrdup_a()
+ */
+sstr_t sstrupper_a(UcxAllocator *allocator, sstr_t string);
+
#ifdef __cplusplus
}
#endif