home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / javaString.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  3KB  |  117 lines

  1. /*
  2.  * @(#)javaString.h    1.15 97/01/25
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. /*
  24.  * Java string utilities
  25.  */
  26.  
  27. #ifndef _JAVASTRING_H_
  28. #define _JAVASTRING_H_
  29.  
  30. #include "oobj.h"
  31.  
  32. #include "java_lang_String.h"
  33.  
  34.  
  35. /*
  36.  * Print the String object with prints.
  37.  */
  38. void javaStringPrint(Hjava_lang_String *);
  39.  
  40. /*
  41.  * Return the length of the String object.
  42.  */
  43. int javaStringLength(Hjava_lang_String *);
  44.  
  45.  
  46. /*
  47.  * Create and return a new Java String object, initialized from the C string.
  48.  */
  49. Hjava_lang_String *makeJavaString(char *, int);
  50.  
  51. /*
  52.  * Create a new C string initialized from the specified Java string,
  53.  * and return a pointer to it.
  54.  * For makeCString, temporary storage is allocated and released automatically
  55.  * when all references to the returned value are eliminated. WARNING: You 
  56.  * must keep this pointer in a variable to prevent the storage from getting
  57.  * garbage collected.
  58.  * For allocCString, a "malloc" is used to get the storage; the caller is
  59.  * responsible for "free"ing the pointer that is returned.
  60.  * 
  61.  */
  62. char *makeCString(Hjava_lang_String *s);
  63. char *allocCString(Hjava_lang_String *s);
  64.  
  65. /*
  66.  * Get the characters of the String object into a unicode string buffer.
  67.  * No allocation occurs. Assumes that len is less than or equal to
  68.  * the length of the string, and that the buf is at least len+1 unicodes
  69.  * in size. The unicode buffer's address is returned.
  70.  */
  71. unicode *javaString2unicode(Hjava_lang_String *, unicode *, int);
  72.  
  73. /*
  74.  * Get the characters of the String object into a C string buffer.
  75.  * No allocation occurs. Assumes that len is the size of the buffer.
  76.  * The C string's address is returned.
  77.  */
  78. char *javaString2CString(Hjava_lang_String *, char *, int);
  79.  
  80. /*
  81.  * convert Java String to platform encoding string.
  82.  */
  83. char *makePlatformCString(Hjava_lang_String *);
  84.  
  85. /*
  86.  * convert platform encoding string to Java String.
  87.  */
  88. Hjava_lang_String *makeJavaStringFromPlatformCString(char *, int);
  89.  
  90. /*
  91.  * Returns the number of bytes needed to hold a Java string in UTF
  92.  * format, NOT including the terminating NULL.
  93.  *
  94.  * Returns -1 if something is wrong.
  95.  */
  96. int
  97. javaStringUTFLength(HString *s);
  98.  
  99. /*
  100.  * Fill buf with unicode representation of hstr, upto buflen chars.
  101.  * The UTF string will be NUL-terminated.
  102.  *
  103.  * If both buf and buflen are 0, malloc an appropriately sized
  104.  * buffer for the result.
  105.  *
  106.  * Return result buffer.
  107.  */
  108. char *javaString2UTF(HString *, char *, int);
  109.  
  110. /*
  111.  * Create a Java String whose characters are initialized from
  112.  * the supplied NUL-terminated UTF string.
  113.  */
  114. HString *makeJavaStringUTF(char *);
  115.  
  116. #endif /* !_JAVASTRING_H_ */
  117.