epoc32/include/stdapis/glib-2.0/glib/gstring.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /* GLIB - Library of useful routines for C programming
     2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
     3  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
     4  *
     5  * This library is free software; you can redistribute it and/or
     6  * modify it under the terms of the GNU Lesser General Public
     7  * License as published by the Free Software Foundation; either
     8  * version 2 of the License, or (at your option) any later version.
     9  *
    10  * This library is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
    13  * Lesser General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU Lesser General Public
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    21 /*
    22  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
    23  * file for a list of people on the GLib Team.  See the ChangeLog
    24  * files for a list of changes.  These files are distributed with
    25  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
    26  */
    27 
    28 #ifndef __G_STRING_H__
    29 #define __G_STRING_H__
    30 
    31 #include <_ansi.h>
    32 #include <glib/gtypes.h>
    33 #include <glib/gunicode.h>
    34 #include <glib/gutils.h>  /* for G_CAN_INLINE */
    35 
    36 G_BEGIN_DECLS
    37 
    38 typedef struct _GString		GString;
    39 typedef struct _GStringChunk	GStringChunk;
    40 
    41 struct _GString
    42 {
    43   gchar  *str;
    44   gsize len;    
    45   gsize allocated_len;
    46 };
    47 
    48 /* String Chunks
    49  */
    50 IMPORT_C GStringChunk* g_string_chunk_new	   (gsize size);  
    51 IMPORT_C void	      g_string_chunk_free	   (GStringChunk *chunk);
    52 IMPORT_C gchar*	      g_string_chunk_insert	   (GStringChunk *chunk,
    53 					    const gchar	 *string);
    54 IMPORT_C gchar*	      g_string_chunk_insert_len	   (GStringChunk *chunk,
    55 					    const gchar	 *string,
    56 					    gssize        len);
    57 IMPORT_C gchar*	      g_string_chunk_insert_const  (GStringChunk *chunk,
    58 					    const gchar	 *string);
    59 
    60 
    61 /* Strings
    62  */
    63 IMPORT_C GString*     g_string_new	        (const gchar	 *init);
    64 IMPORT_C GString*     g_string_new_len           (const gchar     *init,
    65                                          gssize           len);   
    66 IMPORT_C GString*     g_string_sized_new         (gsize            dfl_size);  
    67 IMPORT_C gchar*	     g_string_free	        (GString	 *string,
    68 					 gboolean	  free_segment);
    69 IMPORT_C gboolean     g_string_equal             (const GString	 *v,
    70 					 const GString 	 *v2);
    71 IMPORT_C guint        g_string_hash              (const GString   *str);
    72 IMPORT_C GString*     g_string_assign            (GString	 *string,
    73 					 const gchar	 *rval);
    74 IMPORT_C GString*     g_string_truncate          (GString	 *string,
    75 					 gsize		  len);    
    76 IMPORT_C GString*     g_string_set_size          (GString         *string,
    77 					 gsize            len);
    78 IMPORT_C GString*     g_string_insert_len        (GString         *string,
    79                                          gssize           pos,   
    80                                          const gchar     *val,
    81                                          gssize           len);  
    82 IMPORT_C GString*     g_string_append            (GString	 *string,
    83 			                 const gchar	 *val);
    84 IMPORT_C GString*     g_string_append_len        (GString	 *string,
    85 			                 const gchar	 *val,
    86                                          gssize           len);  
    87 IMPORT_C GString*     g_string_append_c          (GString	 *string,
    88 					 gchar		  c);
    89 IMPORT_C GString*     g_string_append_unichar    (GString	 *string,
    90 					 gunichar	  wc);
    91 IMPORT_C GString*     g_string_prepend           (GString	 *string,
    92 					 const gchar	 *val);
    93 IMPORT_C GString*     g_string_prepend_c         (GString	 *string,
    94 					 gchar		  c);
    95 IMPORT_C GString*     g_string_prepend_unichar   (GString	 *string,
    96 					 gunichar	  wc);
    97 IMPORT_C GString*     g_string_prepend_len       (GString	 *string,
    98 			                 const gchar	 *val,
    99                                          gssize           len);  
   100 IMPORT_C GString*     g_string_insert            (GString	 *string,
   101 					 gssize		  pos,    
   102 					 const gchar	 *val);
   103 IMPORT_C GString*     g_string_insert_c          (GString	 *string,
   104 					 gssize		  pos,    
   105 					 gchar		  c);
   106 IMPORT_C GString*     g_string_insert_unichar    (GString	 *string,
   107 					 gssize		  pos,    
   108 					 gunichar	  wc);
   109 IMPORT_C GString*     g_string_erase	        (GString	 *string,
   110 					 gssize		  pos,
   111 					 gssize		  len);
   112 IMPORT_C GString*     g_string_ascii_down        (GString	 *string);
   113 IMPORT_C GString*     g_string_ascii_up          (GString	 *string);
   114 IMPORT_C void         g_string_printf            (GString	 *string,
   115 					 const gchar	 *format,
   116 					 ...) G_GNUC_PRINTF (2, 3);
   117 IMPORT_C void         g_string_append_printf     (GString	 *string,
   118 					 const gchar	 *format,
   119 					 ...) G_GNUC_PRINTF (2, 3);
   120 
   121 /* -- optimize g_strig_append_c --- */
   122 #ifdef G_CAN_INLINE
   123 static inline GString*
   124 g_string_append_c_inline (GString *gstring,
   125                           gchar    c)
   126 {
   127   if (gstring->len + 1 < gstring->allocated_len)
   128     {
   129       gstring->str[gstring->len++] = c;
   130       gstring->str[gstring->len] = 0;
   131     }
   132   else
   133     g_string_insert_c (gstring, -1, c);
   134   return gstring;
   135 }
   136 #define g_string_append_c(gstr,c)       g_string_append_c_inline (gstr, c)
   137 #endif /* G_CAN_INLINE */
   138 
   139 
   140 #ifndef G_DISABLE_DEPRECATED
   141 
   142 /* The following two functions are deprecated and will be removed in
   143  * the next major release. They use the locale-specific tolower and
   144  * toupper, which is almost never the right thing.
   145  */
   146 
   147 IMPORT_C GString*     g_string_down              (GString	 *string);
   148 IMPORT_C GString*     g_string_up                (GString	 *string);
   149 
   150 /* These aliases are included for compatibility. */
   151 #define	g_string_sprintf	g_string_printf
   152 #define	g_string_sprintfa	g_string_append_printf
   153 
   154 #endif /* G_DISABLE_DEPRECATED */
   155 
   156 G_END_DECLS
   157 
   158 #endif /* __G_STRING_H__ */
   159