home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / javastring.h < prev    next >
C/C++ Source or Header  |  1996-05-03  |  2KB  |  78 lines

  1. /*
  2.  * @(#)javaString.h    1.11 95/11/29  
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. /*
  21.  * Java string utilities
  22.  */
  23.  
  24. #ifndef _JAVASTRING_H_
  25. #define _JAVASTRING_H_
  26.  
  27. #include "oobj.h"
  28.  
  29. #include "java_lang_String.h"
  30.  
  31.  
  32. /*
  33.  * Print the String object with prints.
  34.  */
  35. void javaStringPrint(Hjava_lang_String *);
  36.  
  37. /*
  38.  * Return the length of the String object.
  39.  */
  40. int javaStringLength(Hjava_lang_String *);
  41.  
  42.  
  43. /*
  44.  * Create and return a new Java String object, initialized from the C string.
  45.  */
  46. Hjava_lang_String *makeJavaString(char *, int);
  47.  
  48. /*
  49.  * Create a new C string initialized from the specified Java string,
  50.  * and return a pointer to it.
  51.  * For makeCString, temporary storage is allocated and released automatically
  52.  * when all references to the returned value are eliminated. WARNING: You 
  53.  * must keep this pointer in a variable to prevent the storage from getting
  54.  * garbage collected.
  55.  * For allocCString, a "malloc" is used to get the storage; the caller is
  56.  * responsible for "free"ing the pointer that is returned.
  57.  * 
  58.  */
  59. char *makeCString(Hjava_lang_String *s);
  60. char *allocCString(Hjava_lang_String *s);
  61.  
  62. /*
  63.  * Get the characters of the String object into a unicode string buffer.
  64.  * No allocation occurs. Assumes that len is less than or equal to
  65.  * the length of the string, and that the buf is at least len+1 unicodes
  66.  * in size. The unicode buffer's address is returned.
  67.  */
  68. unicode *javaString2unicode(Hjava_lang_String *, unicode *, int);
  69.  
  70. /*
  71.  * Get the characters of the String object into a C string buffer.
  72.  * No allocation occurs. Assumes that len is the size of the buffer.
  73.  * The C string's address is returned.
  74.  */
  75. char *javaString2CString(Hjava_lang_String *, char *, int);
  76.  
  77. #endif /* !_JAVASTRING_H_ */
  78.