Hitachi

uCosminexus Application Server Expansion Guide


9.3.2 Handling characters and strings in OTM

The following table lists the data types with which character strings can be handled in OTM.

Table 9‒5: Data types supported by OTM

No.

Definition in the remote interface

Data type used on the client

1

string

::TSC::TSCWStringValue

2

char

::TSC::TSCWChar

Organization of this subsection

(1) ::TSC::TSCWStringValue

In IDL, ::TSC::TSCWStringValue is defined as follows:

module TSC {
  typedef sequence<octet> TSCWString;
  struct TSCWStringValue {
    TSCWString value;
  };
};

The following sections show the functions provided to use data of the ::TSC::TSCWStringValue type as actual strings of the wchar_t* type.

(a) For the C++ interface

  • Include file

    #include "Converter_TSC_c.hh" (stub header)

  • Provided functions

    void TSCsetWString( ::TSC::TSCWString&, const ::CORBA::WChar* )

    Description:

    This function sets a wide string for ::TSC::TSCWString.

    I/O variables:

    ::TSC::TSCWString& :out: Variable of the ::TSC::TSCWString type to be set

    const ::CORBA::WChar*:in: Wide string to be set

    ::CORBA::WChar* TSCgetWString( ::TSC::TSCWString )

    Description:

    This function retrieves the wide string that is set in ::TSC::TSCWString.

    I/O variables:

    ::TSC::TSCWString :in: Object that holds the wide string

    Return value:

    Wide string retrieved from ::TSC::TSCWString

    Note:

    If you use this interface with OTM V3, use delete[] to release the return value.

  • Sample code

    CORBA::WChar* wstr_data = new CORBA::WChar[5];
    wstr_data[0] = L [Figure] ;
    wstr_data[1] = L [Figure] ;
    wstr_data[2] = L [Figure] ;
    wstr_data[3] = L [Figure] ;
    wstr_data[4] = 0;
    ::TSC::TSCWStringValue tsc_wstr_value_data;
     
    // Set a wide string
    TSCsetWString( tsc_wstr_value_data.value, wstr_data );
    // Release the area that is no longer used
    delete[] wstr_data;
     
    // Retrieve the wide string
    wstr_data = TSCgetWString( tsc_wstr_data.value );
    // Release the area from which the string was retrieved
    delete[] wstr_data;

(b) For the Java interface

No functions are provided for the Java interface.

  • Sample code

    String wstr_data = new String("[Figure]");
    System.out.println(wstr_data);
    TSC.TSCWStringValue tsc_wstr_value_data = new TSC.TSCWStringValue();
     
    // Set a wide string
    tsc_wstr_value_data.value = wstr_data.getBytes("UTF-16");
     
    // Retrieve the wide string
    wstr_data = new String( tsc_wstr_value_data.value );

(2) ::TSC::TSCWChar

In IDL, ::TSC::TSCWChar is defined as follows:

module TSC {
  typedef octet TSCWChar[3];
};

The following sections show the functions provided to use data of the ::TSC::TSCWChar type as actual strings of the wchar_t* type.

(a) For the C++ interface

  • Include file

    #include "Converter_TSC_c.hh" (stub header)

  • Provided functions

    void TSCsetWChar( ::TSC::TSCWChar , ::CORBA::WChar )

    Description:

    This function sets a wide string for ::TSC::TSCWChar.

    I/O variables:

    ::TSC::TSCWChar :out: Area to be set

    const ::CORBA::WChar :in: Wide string to be set

    Return value:

    None

    ::CORBA::WChar TSCgetWChar( ::TSC::TSCWChar )

    Description:

    This function retrieves the wide string that is set in ::TSC::TSCWChar.

    I/O variables:

    const ::TSC::TSCWChar :in:Object that holds a wide string

    Return value:

    Wide string retrieved from ::TSC::TSCWChar

  • Sample code

    ::TSC::TSCWChar tsc_wchar_data;
    // Set a wide string
    TSCsetWChar( tsc_wchar_data, L'[Figure]' );
     
    // Retrieve the wide string
    CORBA::WChar wchar_data = TSCgetWChar( tsc_wchar_data );

(b) For the Java interface

No functions are provided for the Java interface.

  • Sample code

    TSC.TSCWCharHolder tsc_wchar_data = new TSC.TSCWCharHolder();
    tsc_wchar_data.value = new byte[3];
    char wch_data = '[Figure]';
     
    // Set a wide string
    tsc_wchar_data.value[0] = (byte)2;
    tsc_wchar_data.value[1] = (byte)((wch_data >> 8) & 0xff);
    tsc_wchar_data.value[2] = (byte)( wch_data & 0xff);
     
    // Retrieve the wide string
    wch_data = (char)(((char)tsc_wchar_data.value[1] & 0xff) << 8 |
    ((char)tsc_wchar_data.value[2] & 0xff));