C Standard Library Extensions  1.0.5
cxstring.h
00001 /* $Id: cxstring.h,v 1.7 2009/12/07 15:48:15 llundin Exp $
00002  *
00003  * This file is part of the ESO C Extension Library
00004  * Copyright (C) 2001-2006 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 /*
00022  * $Author: llundin $
00023  * $Date: 2009/12/07 15:48:15 $
00024  * $Revision: 1.7 $
00025  * $Name: cpl-5_3_0-BRANCH $
00026  */
00027 
00028 #ifndef CX_STRING_H_
00029 #define CX_STRING_H_ 1
00030 
00031 #include <stdarg.h>
00032 #include <string.h>
00033 #include <ctype.h>
00034 
00035 #include <cxtypes.h>
00036 #include <cxmemory.h>
00037 #include <cxmessages.h>
00038 #include <cxutils.h>
00039 
00040 
00041 CX_BEGIN_DECLS
00042 
00043 struct _cx_string_ {
00044 
00045     /* <private> */
00046 
00047     cxchar  *data;
00048     cxsize sz;
00049 
00050 };
00051 
00052 
00060 typedef struct _cx_string_ cx_string;
00061 
00062 
00063 /*
00064  * Create, copy and destroy operations
00065  */
00066 
00067 cx_string *cx_string_new(void);
00068 cx_string *cx_string_copy(const cx_string *);
00069 cx_string *cx_string_create(const cxchar *);
00070 void cx_string_delete(cx_string *);
00071 
00072 /*
00073  * Non modifying operations
00074  */
00075 
00076 cxsize cx_string_size(const cx_string *);
00077 cxbool cx_string_empty(const cx_string *);
00078 
00079 /*
00080  * Data access
00081  */
00082 
00083 const cxchar *cx_string_get(const cx_string *);
00084 
00085 /*
00086  * Assignment operations
00087  */
00088 
00089 void cx_string_set(cx_string *, const cxchar *);
00090 
00091 /*
00092  * Modifying operations
00093  */
00094 
00095 cx_string *cx_string_upper(cx_string *);
00096 cx_string *cx_string_lower(cx_string *);
00097 cx_string *cx_string_trim(cx_string *);
00098 cx_string *cx_string_rtrim(cx_string *);
00099 cx_string *cx_string_strip(cx_string *);
00100 
00101 /*
00102  * Inserting and removing elements
00103  */
00104 
00105 cx_string *cx_string_prepend(cx_string *, const cxchar *);
00106 cx_string *cx_string_append(cx_string *, const cxchar *);
00107 cx_string *cx_string_insert(cx_string *, cxssize, const cxchar *);
00108 cx_string *cx_string_erase(cx_string *, cxssize, cxssize);
00109 cx_string *cx_string_truncate(cx_string *, cxsize);
00110 
00111 /*
00112  *  Comparison functions
00113  */
00114 
00115 cxbool cx_string_equal (const cx_string *, const cx_string *);
00116 cxint cx_string_compare(const cx_string *, const cx_string *);
00117 cxint cx_string_casecmp(const cx_string *, const cx_string *);
00118 cxint cx_string_ncasecmp(const cx_string *, const cx_string *, cxsize);
00119 
00120 /*
00121  * I/O functions
00122  */
00123 
00124 cxint cx_string_sprintf(cx_string *, const cxchar *, ...)
00125 #ifdef __GNUC__
00126     __attribute__((format (printf, 2, 3)))
00127 #endif
00128     ;
00129 cxint cx_string_vsprintf(cx_string *, const cxchar *, va_list)
00130 #ifdef __GNUC__
00131     __attribute__((format (printf, 2, 0)))
00132 #endif
00133     ;
00134 
00135 /*
00136  * Debugging utilities
00137  */
00138 
00139 void cx_string_print(const cx_string *);
00140 
00141 CX_END_DECLS
00142 
00143 #endif /* CX_STRING_H */