exip  Alpha 0.5.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
ASCII_stringManipulate.c File Reference

String manipulation functions used for UCS <-> ASCII transformations. More...

#include "stringManipulate.h"
#include "memManagement.h"

Go to the source code of this file.

Macros

#define PARSING_STRING_MAX_LENGTH   100
 

Functions

errorCode allocateStringMemory (CharType **str, Index UCSchars)
 Allocate a memory for a string with UCSchars number of UCS characters It depends on the representation of the characters. More...
 
errorCode allocateStringMemoryManaged (CharType **str, Index UCSchars, AllocList *memList)
 Allocate a memory for a string with UCSchars number of UCS characters It depends on the representation of the characters. More...
 
errorCode writeCharToString (String *str, uint32_t code_point, Index *writerPosition)
 Simple translation working only for ASCII characters. More...
 
void getEmptyString (String *emptyStr)
 Creates an empty string. More...
 
boolean isStringEmpty (const String *str)
 Checks if an string is empty. More...
 
errorCode asciiToString (const char *inStr, String *outStr, AllocList *memList, boolean clone)
 Transform a NULL terminated string of ASCII chars to String allocating memory for the CharType*. More...
 
boolean stringEqual (const String str1, const String str2)
 Tests if two strings are equal. More...
 
boolean stringEqualToAscii (const String str1, const char *str2)
 Checks if a String string and ASCII string are equal. More...
 
int stringCompare (const String str1, const String str2)
 Compare two strings lexicographically. More...
 
uint32_t readCharFromString (const String *str, Index *readerPosition)
 Returns the UCS [ISO/IEC 10646] code point at particular index from a String. More...
 
errorCode cloneString (const String *src, String *newStr)
 Makes a copy of the string in a new location. More...
 
errorCode cloneStringManaged (const String *src, String *newStr, AllocList *memList)
 Makes a copy of the string in a new location. More...
 
Index getIndexOfChar (const String *src, CharType sCh)
 Returns the index of the first occurrence of a character in a string. More...
 
errorCode stringToInteger (const String *src, int *number)
 Converts a string to int representation. More...
 
errorCode stringToInt64 (const String *src, int64_t *number)
 Converts a string to int64 representation. More...
 
void printString (const String *inStr)
 Prints out a String Used for debugging purposes. More...
 

Detailed Description

Date
Sep 3, 2010
Author
Rumen Kyusakov
Version
0.5
[Revision] $Id: ASCII_stringManipulate.c 348 2014-11-21 12:34:51Z kjussakov $

Definition in file ASCII_stringManipulate.c.

Macro Definition Documentation

#define PARSING_STRING_MAX_LENGTH   100

Definition at line 21 of file ASCII_stringManipulate.c.

Function Documentation

errorCode allocateStringMemory ( CharType **  str,
Index  UCSchars 
)
Parameters
[in,out]stra pointer to the uninitialized string
[in]UCScharsthe number of characters (as described by UCS [ISO/IEC 10646])
Returns
Error handling code

Definition at line 23 of file ASCII_stringManipulate.c.

errorCode allocateStringMemoryManaged ( CharType **  str,
Index  UCSchars,
AllocList memList 
)
Parameters
[in,out]stra pointer to the uninitialized string
[in]UCScharsthe number of characters (as described by UCS [ISO/IEC 10646])
[in,out]memListA list storing the memory allocations
Returns
Error handling code

Definition at line 31 of file ASCII_stringManipulate.c.

errorCode asciiToString ( const char *  inStr,
String outStr,
AllocList memList,
boolean  clone 
)
Parameters
[in]inStrASCII stream
[in,out]outStrresulted string
[in,out]memListA list storing the memory allocations
[in]cloneBoolean indicating if outStr should reuse the memory allocated for inStr if possible. FALSE - if String implementation allows it - do not allocate new memory for the string TRUE - always allocate fresh memory for outStr and copy inStr there
Returns
Error handling code

Definition at line 64 of file ASCII_stringManipulate.c.

errorCode cloneString ( const String src,
String newStr 
)
Parameters
[in]srcthe string to be copied
[in]newStrwill point to the newly allocated memory with scr->CharType* copied there
Returns
Error handling code

Definition at line 155 of file ASCII_stringManipulate.c.

errorCode cloneStringManaged ( const String src,
String newStr,
AllocList memList 
)
Parameters
[in]srcthe string to be copied
[in]newStrwill point to the newly allocated memory with scr->CharType* copied there
[in,out]memListA list storing the memory allocations
Returns
Error handling code

Definition at line 167 of file ASCII_stringManipulate.c.

void getEmptyString ( String emptyStr)
Parameters
[in,out]emptyStrempty string

Definition at line 51 of file ASCII_stringManipulate.c.

Index getIndexOfChar ( const String src,
CharType  sCh 
)
Parameters
[in]srcthe source string
[in]sCha character that is searched
Returns
the index of first occurrence; INDEX_MAX if not found

Definition at line 179 of file ASCII_stringManipulate.c.

boolean isStringEmpty ( const String str)
Parameters
[in]strstring to check
Returns
FALSE if not empty, TRUE if empty

Definition at line 57 of file ASCII_stringManipulate.c.

void printString ( const String inStr)
Parameters
[in]inStrInput string to be printed

Definition at line 272 of file ASCII_stringManipulate.c.

uint32_t readCharFromString ( const String str,
Index readerPosition 
)
Parameters
[in]strstring
[in,out]readerPosition,:[in] The position that marks the beginning of the character to be read [out] The position of the next character to be passed to a subsequent calls to readCharFromString
Returns
UCS code point

Definition at line 148 of file ASCII_stringManipulate.c.

int stringCompare ( const String  str1,
const String  str2 
)
Parameters
[in]str1string to compare
[in]str2string to compare
Returns
0 when the strings are equal; negative int when str1<str2; positive when str1>str2

Definition at line 122 of file ASCII_stringManipulate.c.

boolean stringEqual ( const String  str1,
const String  str2 
)
Parameters
[in]str1string to compare
[in]str2string to compare
Returns
TRUE if the strings are equal, FALSE - otherwise

Definition at line 88 of file ASCII_stringManipulate.c.

boolean stringEqualToAscii ( const String  str1,
const char *  str2 
)
Parameters
[in]str1string to compare
[in]str2null terminated string to compare
Returns
TRUE if the strings are equal, FALSE - otherwise

Definition at line 106 of file ASCII_stringManipulate.c.

errorCode stringToInt64 ( const String src,
int64_t number 
)

Only 10-base representation

Parameters
[in]srcthe source string
[out]numberthe int64 representation of the string
Returns
Error handling code

Definition at line 216 of file ASCII_stringManipulate.c.

errorCode stringToInteger ( const String src,
int *  number 
)

Only 10-base representation

Parameters
[in]srcthe source string
[out]numberthe int representation of the string
Returns
Error handling code

Definition at line 191 of file ASCII_stringManipulate.c.

errorCode writeCharToString ( String str,
uint32_t  code_point,
Index writerPosition 
)

Writes a UCS [ISO/IEC 10646] code point to a string It depends on the representation of the characters.

Definition at line 42 of file ASCII_stringManipulate.c.