Codemesh Runtime v3 C++ API Reference  3.9.205
Static Public Member Functions | Static Public Attributes | List of all members
xmog_java_string Class Reference

A mixin or utility class for Java string features. More...

#include <xmog_java_string.h>

Collaboration diagram for xmog_java_string:
Collaboration graph
[legend]

Static Public Member Functions

static void init_encodings (xmog_localenv *env=NULL)
 Initializes the static instances. More...
 
static void set_default_encoding (const char *_enc, xmog_localenv *env=NULL)
 Sets the default encoding that is used on the current thread. More...
 
static void set_default_encoding (const XMOG_WCHAR *_enc, xmog_localenv *env=NULL)
 Sets the default encoding that is used on the current thread. More...
 
static void set_default_encoding (xmog_base *_enc, xmog_localenv *env=NULL)
 Sets the default encoding that is used on the current thread. More...
 
static jstring from_char (const char *_str, jint _len=-1, xmog_base *_enc=NULL, xmog_localenv *env=NULL, xmog_base *pStr=NULL, char **pCache=NULL)
 Returns a jstring for the given character string. More...
 
static void from_char (xmog_base *_this, xmog_flags _flags, const char *_str, jint _len=-1, xmog_base *_enc=NULL, xmog_localenv *env=NULL, xmog_base *pStr=NULL, char **pCache=NULL)
 Returns a jstring for the given character string. More...
 
static jstring from_charUtf8 (const char *_strUTF, xmog_localenv *env=NULL)
 Returns a jstring for the given UTF-8 character string. More...
 
static void from_charUtf8 (xmog_base *_this, xmog_flags _flags, const char *_strUTF, xmog_localenv *env=NULL)
 Returns a jstring for the given UTF-8 character string. More...
 
static char * to_char (jstring _str, xmog_localenv *env=NULL, xmog_base *pStr=NULL, char **pCache=NULL)
 Returns a char string for the given Java string. More...
 
static char * to_char (jstring _str, xmog_base *_enc, xmog_localenv *env=NULL, xmog_base *pStr=NULL, char **pCache=NULL)
 Returns a char string for the given Java string. More...
 
static char * to_charUtf8 (jstring _str, xmog_localenv *env=NULL, xmog_base *pStr=NULL, char **pCache=NULL)
 Returns a UTF-8 string for the given Java string. More...
 
static unsigned short * to_u16 (jstring _str, xmog_localenv *env=NULL)
 Returns a unsigned short string for the given Java string. More...
 
static void free (char *&str)
 Frees a previously allocated string. More...
 
static void free_u16 (unsigned short *&str)
 Frees a previously allocated string. More...
 

Static Public Attributes

static xmog_baseUS_ASCII
 The US-ASCII character set.
 
static xmog_baseISO_8859_1
 The ISO-8859-1 character set.
 
static xmog_baseUTF_8
 The UTF-8 character set.
 
static xmog_baseUTF_16BE
 The UTF-16BE character set.
 
static xmog_baseUTF_16LE
 The UTF-16LE character set.
 
static xmog_baseUTF_16
 The UTF-16 character set.
 

Detailed Description

A mixin or utility class for Java string features.

This class provides different variations of the same API to allow use from singlebyte and multibyte (UNICODE) clients. It also declares several static encoding instances that can be used to support the built-in encodings.

Member Function Documentation

◆ free()

static void xmog_java_string::free ( char *&  str)
static

Frees a previously allocated string.

This method relies on the fact that the string that is to be freed was previously allocated using the framework's memory allocator.

Warning
free Do not use this method on strings that were allocated using different methods.

◆ free_u16()

static void xmog_java_string::free_u16 ( unsigned short *&  str)
static

Frees a previously allocated string.

This method relies on the fact that the string that is to be freed was previously allocated using the framework's memory allocator.

Warning
free Do not use this method on strings that were allocated using different methods.

◆ from_char() [1/2]

static jstring xmog_java_string::from_char ( const char *  _str,
jint  _len = -1,
xmog_base _enc = NULL,
xmog_localenv env = NULL,
xmog_base pStr = NULL,
char **  pCache = NULL 
)
static

Returns a jstring for the given character string.

Parameters
_strthe native string to convert to a jstring.
_lenthe optional length to use. If different from -1, specifies the number of characters to use. If -1, assume a zero-terminated string and calculate its length.
_encthe encoding to use. May be NULL, in which case the default encoding is used.
envthe local calling context. May be NULL.
pStrthe optional pointer to the proxy instance. May be NULL.
pCachethe optional pointer to the caching pointer. May be NULL.
Returns
a local reference to the created string.

◆ from_char() [2/2]

static void xmog_java_string::from_char ( xmog_base _this,
xmog_flags  _flags,
const char *  _str,
jint  _len = -1,
xmog_base _enc = NULL,
xmog_localenv env = NULL,
xmog_base pStr = NULL,
char **  pCache = NULL 
)
static

Returns a jstring for the given character string.

Parameters
_thisthe instance into which the jstring instance is set.
_flagsthe bitflags containing the reference type.
_strthe native string to convert to a jstring.
_lenthe optional length to use. If different from -1, specifies the number of characters to use. If -1, assume a zero-terminated string and calculate its length.
_encthe encoding to use. May be NULL, in which case the default encoding is used.
envthe local calling context. May be NULL.
pStrthe optional pointer to the proxy instance. May be NULL.
pCachethe optional pointer to the caching pointer. May be NULL.
Returns
a local reference to the created string.

◆ from_charUtf8() [1/2]

static jstring xmog_java_string::from_charUtf8 ( const char *  _strUTF,
xmog_localenv env = NULL 
)
static

Returns a jstring for the given UTF-8 character string.

Parameters
_strUTFthe UTF-8 string to convert to a jstring.
envthe local calling context. May be NULL.
Returns
a local reference to the created string.

◆ from_charUtf8() [2/2]

static void xmog_java_string::from_charUtf8 ( xmog_base _this,
xmog_flags  _flags,
const char *  _strUTF,
xmog_localenv env = NULL 
)
static

Returns a jstring for the given UTF-8 character string.

Parameters
_thisthe instance into which the jstring instance is set.
_flagsthe bitflags containing the reference type.
_strUTFthe UTF-8 string to convert to a jstring.
envthe local calling context. May be NULL.
Returns
a local reference to the created string.

◆ init_encodings()

static void xmog_java_string::init_encodings ( xmog_localenv env = NULL)
static

Initializes the static instances.

This method is called internally by the xmog_java_string class and by the xmog_jvm class when the JVM is loaded.

◆ set_default_encoding() [1/3]

static void xmog_java_string::set_default_encoding ( const char *  _enc,
xmog_localenv env = NULL 
)
static

Sets the default encoding that is used on the current thread.

An encoding is always thread-specific to support servers that have to run threads on behalf of more than one user.

Parameters
_encthe name of the default encoding to use on the current thread.
envthe local calling context. May be NULL.

◆ set_default_encoding() [2/3]

static void xmog_java_string::set_default_encoding ( const XMOG_WCHAR *  _enc,
xmog_localenv env = NULL 
)
static

Sets the default encoding that is used on the current thread.

An encoding is always thread-specific to support servers that have to run threads on behalf of more than one user.

Parameters
_encthe name of the default encoding to use on the current thread.
envthe local calling context. May be NULL.

◆ set_default_encoding() [3/3]

static void xmog_java_string::set_default_encoding ( xmog_base _enc,
xmog_localenv env = NULL 
)
static

Sets the default encoding that is used on the current thread.

An encoding is always thread-specific to support servers that have to run threads on behalf of more than one user.

Parameters
_encthe default encoding to use on the current thread.
envthe local calling context. May be NULL.

◆ to_char() [1/2]

static char* xmog_java_string::to_char ( jstring  _str,
xmog_base _enc,
xmog_localenv env = NULL,
xmog_base pStr = NULL,
char **  pCache = NULL 
)
static

Returns a char string for the given Java string.

Parameters
_strthe Java string handle.
_encthe encoding used for the character extraction. May be NULL.
envthe local calling context. May be NULL.
pStrthe optional pointer to the proxy instance. May be NULL.
pCachethe optional pointer to the caching pointer. May be NULL.
Returns
a char string that was allocated using xmog_util::setString(char*&,const char*). It should be deallocated using xmog_util::setString( char*& , NULL );

◆ to_char() [2/2]

static char* xmog_java_string::to_char ( jstring  _str,
xmog_localenv env = NULL,
xmog_base pStr = NULL,
char **  pCache = NULL 
)
static

Returns a char string for the given Java string.

Parameters
_strthe Java string handle.
envthe local calling context. May be NULL.
pStrthe optional pointer to the proxy instance. May be NULL.
pCachethe optional pointer to the caching pointer. May be NULL.
Returns
a char string that was allocated using xmog_util::setString(char*&,const char*). It should be deallocated using xmog_util::setString( char*& , NULL );

◆ to_charUtf8()

static char* xmog_java_string::to_charUtf8 ( jstring  _str,
xmog_localenv env = NULL,
xmog_base pStr = NULL,
char **  pCache = NULL 
)
static

Returns a UTF-8 string for the given Java string.

Parameters
_strthe Java string handle.
envthe local calling context. May be NULL.
pStrthe optional pointer to the proxy instance. May be NULL.
pCachethe optional pointer to the caching pointer. May be NULL.
Returns
a char string that was allocated using xmog_util::setString(char*&,const char*). It should be deallocated using xmog_util::setString( char*& , NULL );

◆ to_u16()

static unsigned short* xmog_java_string::to_u16 ( jstring  _str,
xmog_localenv env = NULL 
)
static

Returns a unsigned short string for the given Java string.

Parameters
_strthe Java string handle.
envthe local calling context. May be NULL.
Returns
a wchar_t string that was allocated using xmog_util::setString(wchar_t*&,const wchar_t*). It should be deallocated using xmog_util::setString( wchar_t*& , NULL );

The documentation for this class was generated from the following file:

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.