Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

/var/home/joerg/c/CDB/include/string_forward.h File Reference

#include "sysdep.h"
#include <unicode/ustdio.h>
#include <unicode/ustring.h>
#include <unicode/utf16.h>
#include <unicode/ucnv.h>
#include <wchar.h>
#include <wctype.h>
#include <stdlib.h>
#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  st_string_forward_conversion
 Structure for initialized converter data. More...

Defines

#define CharToIcu(cnv, dst, dst_size, src, src_size)
 Convert from char* to icu (UChar*).
#define CharToWchar(cnv, dst, dst_size, src, src_size)   mbstowcs(dst, src, dst_size)
 Convert from char* to UTF32 (wchar_t*).
#define IcuToChar(cnv, dst, dst_size, src, src_size)
 Convert from icu (UChar*) to char*.
#define IcuToWchar(cnv, dst, dst_size, src, src_size)   wcsncpy(dst, src, dst_size)
 Copy from icu (UChar*) to UTF16 (wchar_t*).
#define MAsciiFrom(cnv, dst, dst_size, src, src_size)   Mstrncpy(dst, src, ((size_t)dst_size > (size_t)src_size ? src_size + 1 : dst_size))
 Convert a Mchar string to a Ascii (char*) string literal.
#define MAsciiTo(cnv, dst, dst_size, src, src_size)   Mstrncpy(dst, src, ((size_t)dst_size > (size_t)src_size ? src_size + 1 : dst_size))
 Convert Ascii string (char*) to a Mchar literal.
#define Mchar   char
 Forward definition to char as character type.
#define Mdecl(name, value)   static Mchar name[] = value
 Declaration for static string literals.
#define Mdecln(name, value, len)   static Mchar name[len] = value
 Declaration for static string literals up to len characters.
#define MicuFrom(cnv, dst, dst_size, src, src_size)   CharToIcu(cnv, dst, dst_size, src, src_size)
 Convert from Mchar to icu (UChar*).
#define MicuTo(cnv, dst, dst_size, src, src_size)   IcuToChar(cnv, dst, dst_size, src, src_size)
 Convert from icu (UChar*) to Mchar.
#define Minit(name, value)
 Initialisation for static string literals.
#define Minitn(name, value, len)
 Initialisation for static string literals up to len characters.
#define MSC   "%s"
 Mchar format string character.
#define Msizeof(s)   sizeof(s)
 Get size (number of characters) of static allocated string literal.
#define Msnprintf(dst, s, fmt...)   snprintf(dst, s, fmt)
 Formatted output to a string.
#define Mstrcmp(s1, s2)   strcmp(s1, s2)
 Compare to Mchar* literals.
#define Mstrdup(s)   strdup(s)
 Make dynamic allocated duplicated of string.
#define Mstrlen(s)   strlen(s)
 Mchars implementation of strlen.
#define Mstrncat(dst, src, dst_size)   strncat((Mchar*)dst, (const Mchar*)src, dst_size)
 strncat implementation with buffer overflow protection
#define Mstrncmp(s1, s2, c)   strncmp(s1, s2, c)
 Compare two strings with maximum number of characters.
#define Mstrncpy(dst, src, dst_size)   strncpy((char*)(dst), (const char*)(src), dst_size)
 strncpy implementation with buffer overflow protection
#define Mstrsize(s)   (Mstrlen(s)+1)
 Get the number of chacters needed to store the literal.
#define Mstrstr(in, for)   strstr(in, for)
 Search for part in string.
#define Mtolower(c)   tolower(c)
#define Mtoupper(c)   toupper(c)
#define MwcharFrom(cnv, dst, dst_size, src, src_size)   CharToWchar(cnv, dst, dst_size, src, src_size)
 Convert from Mchar to wchar_t.
#define MwcharTo(cnv, dst, dst_size, src, src_size)   WcharToChar(cnv, dst, dst_size, src, src_size)
 Convert from wchar_t to Mchar.
#define WcharToChar(cnv, dst, dst_size, src, src_size)   wcstombs(dst, src, dst_size)
 Convert from UTF32 (wchar_t*) to char*.
#define WcharToIcu(cnv, dst, dst_size, src, src_size)   wcsncpy(dst, src, dst_size)
 Copy from UTF16 (wchar_t*) to icu (UChar*).

Typedefs

typedef st_string_forward_conversion string_forward_conversion_t
 Structure for initialized converter data.

Functions

void Acopy2M (char *dst, const char *src, int size)
double Matof (const char *s)
int Matoi (const char *s)
int64_t Matoll (const char *s)
void Mcopy2A (char *dst, const char *src, int size)
char * MdupAsciiFrom (const char *s)
char * MdupAsciiTo (const char *s)
void MfreeConversion (string_forward_conversion_t *)
 Destroy a new conversion structure.
string_forward_conversion_tMprepareConversion (void)
 Prepare a new conversion structure.
int MUtf8From (string_forward_conversion_t *cnv, char *dst, size_t dst_size, const char *src, size_t src_size)
int MUtf8To (string_forward_conversion_t *cnv, char *dst, size_t dst_size, const char *src, size_t src_size)
int WcharSnprintf (wchar_t *dst, int s, const char *fmt,...)
 snprintf() implementation for wchar_t bases fmt on char*.


Define Documentation

#define CharToIcu cnv,
dst,
dst_size,
src,
src_size   ) 
 

Value:

({ \
        register int _ret = 0; \
        UErrorCode errorCode=U_ZERO_ERROR; \
        ucnv_toUChars(cnv->icu_cnv, dst, dst_size, src, src_size, &errorCode); \
        if(U_FAILURE(errorCode) || errorCode==U_STRING_NOT_TERMINATED_WARNING) { \
                printf("problem converting string to Unicode: %s\n", u_errorName(errorCode)); \
                _ret = -1; \
        } \
        _ret; \
})
Convert from char* to icu (UChar*).

#define CharToWchar cnv,
dst,
dst_size,
src,
src_size   )     mbstowcs(dst, src, dst_size)
 

Convert from char* to UTF32 (wchar_t*).

#define IcuToChar cnv,
dst,
dst_size,
src,
src_size   ) 
 

Value:

({ \
        register int _ret = 0; \
        UErrorCode errorCode=U_ZERO_ERROR; \
        ucnv_fromUChars(cnv->icu_cnv, dst, dst_size, src, src_size, &errorCode); \
        if(U_FAILURE(errorCode) || errorCode==U_STRING_NOT_TERMINATED_WARNING) { \
                printf("problem converting string from Unicode: %s\n", u_errorName(errorCode)); \
                _ret = -1; \
        } \
        _ret; \
})
Convert from icu (UChar*) to char*.

#define IcuToWchar cnv,
dst,
dst_size,
src,
src_size   )     wcsncpy(dst, src, dst_size)
 

Copy from icu (UChar*) to UTF16 (wchar_t*).

#define MAsciiFrom cnv,
dst,
dst_size,
src,
src_size   )     Mstrncpy(dst, src, ((size_t)dst_size > (size_t)src_size ? src_size + 1 : dst_size))
 

Convert a Mchar string to a Ascii (char*) string literal.

#define MAsciiTo cnv,
dst,
dst_size,
src,
src_size   )     Mstrncpy(dst, src, ((size_t)dst_size > (size_t)src_size ? src_size + 1 : dst_size))
 

Convert Ascii string (char*) to a Mchar literal.

#define Mchar   char
 

Forward definition to char as character type.

#define Mdecl name,
value   )     static Mchar name[] = value
 

Declaration for static string literals.

#define Mdecln name,
value,
len   )     static Mchar name[len] = value
 

Declaration for static string literals up to len characters.

#define MicuFrom cnv,
dst,
dst_size,
src,
src_size   )     CharToIcu(cnv, dst, dst_size, src, src_size)
 

Convert from Mchar to icu (UChar*).

#define MicuTo cnv,
dst,
dst_size,
src,
src_size   )     IcuToChar(cnv, dst, dst_size, src, src_size)
 

Convert from icu (UChar*) to Mchar.

#define Minit name,
value   ) 
 

Initialisation for static string literals.

#define Minitn name,
value,
len   ) 
 

Initialisation for static string literals up to len characters.

#define MSC   "%s"
 

Mchar format string character.

This definition is very usefull to include a Mchar* into a Msnprintf()-call. Example: Msnprintf(literal, Msizeof(literal), "TEST " MSC, input);

#define Msizeof  )     sizeof(s)
 

Get size (number of characters) of static allocated string literal.

This macro is used to determine how many characters have been allocated statically on stack or heap. With some special character types it is needed to uses sizeof(s)/sizeof(Mchar). This is done by this macro Note: The implemenation for Mchar = char is a forward to sizeof().

#define Msnprintf dst,
s,
fmt...   )     snprintf(dst, s, fmt)
 

Formatted output to a string.

Here comes Mchars implementation of simple string format.

#define Mstrcmp s1,
s2   )     strcmp(s1, s2)
 

Compare to Mchar* literals.

#define Mstrdup  )     strdup(s)
 

Make dynamic allocated duplicated of string.

#define Mstrlen  )     strlen(s)
 

Mchars implementation of strlen.

#define Mstrncat dst,
src,
dst_size   )     strncat((Mchar*)dst, (const Mchar*)src, dst_size)
 

strncat implementation with buffer overflow protection

#define Mstrncmp s1,
s2,
 )     strncmp(s1, s2, c)
 

Compare two strings with maximum number of characters.

#define Mstrncpy dst,
src,
dst_size   )     strncpy((char*)(dst), (const char*)(src), dst_size)
 

strncpy implementation with buffer overflow protection

#define Mstrsize  )     (Mstrlen(s)+1)
 

Get the number of chacters needed to store the literal.

This macro identifies the number of characters used for storing this string. If Mchar = char then then size = strlen(s)+1.

#define Mstrstr in,
for   )     strstr(in, for)
 

Search for part in string.

#define Mtolower  )     tolower(c)
 

#define Mtoupper  )     toupper(c)
 

#define MwcharFrom cnv,
dst,
dst_size,
src,
src_size   )     CharToWchar(cnv, dst, dst_size, src, src_size)
 

Convert from Mchar to wchar_t.

#define MwcharTo cnv,
dst,
dst_size,
src,
src_size   )     WcharToChar(cnv, dst, dst_size, src, src_size)
 

Convert from wchar_t to Mchar.

#define WcharToChar cnv,
dst,
dst_size,
src,
src_size   )     wcstombs(dst, src, dst_size)
 

Convert from UTF32 (wchar_t*) to char*.

#define WcharToIcu cnv,
dst,
dst_size,
src,
src_size   )     wcsncpy(dst, src, dst_size)
 

Copy from UTF16 (wchar_t*) to icu (UChar*).


Typedef Documentation

typedef struct st_string_forward_conversion string_forward_conversion_t
 

Structure for initialized converter data.


Function Documentation

void Acopy2M char *  dst,
const char *  src,
int  size
 

double Matof const char *  s  ) 
 

int Matoi const char *  s  ) 
 

int64_t Matoll const char *  s  ) 
 

void Mcopy2A char *  dst,
const char *  src,
int  size
 

char* MdupAsciiFrom const char *  s  ) 
 

char* MdupAsciiTo const char *  s  ) 
 

void MfreeConversion string_forward_conversion_t  ) 
 

Destroy a new conversion structure.

string_forward_conversion_t* MprepareConversion void   ) 
 

Prepare a new conversion structure.

int MUtf8From string_forward_conversion_t cnv,
char *  dst,
size_t  dst_size,
const char *  src,
size_t  src_size
 

int MUtf8To string_forward_conversion_t cnv,
char *  dst,
size_t  dst_size,
const char *  src,
size_t  src_size
 

int WcharSnprintf wchar_t *  dst,
int  s,
const char *  fmt,
  ...
 

snprintf() implementation for wchar_t bases fmt on char*.


Generated on Mon Feb 6 00:30:32 2006 for CDB by  doxygen 1.4.4