Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields  

str.h

00001 #ifndef STR__H__
00002 #define STR__H__
00003 
00022 #define STR_BLOCKSIZE 16
00023 
00027 struct str
00028 {
00033   char* s;
00037   unsigned len;
00039   unsigned size;
00040 };
00041 typedef struct str str;
00042 
00047 struct str_sortentry
00048 {
00049   const char* str;
00050   unsigned long len;
00051 };
00052 typedef struct str_sortentry str_sortentry;
00053 
00056 int str_init(str* s);
00057 int str_alloc(str* s, unsigned size, int copy);
00059 #define str_ready(S,SZ) str_alloc(S,SZ,0)
00060 
00061 #define str_realloc(S,SZ) str_alloc(S,SZ,1)
00062 void str_free(str* s);
00063 int str_truncate(str* s, unsigned len);
00064 /* @} */
00065 
00068 int str_copy(str* s, const str* in);
00069 int str_copys(str* s, const char* in);
00070 int str_copyb(str* s, const char* in, unsigned len);
00071 int str_copy2s(str* s, const char* a, const char* b);
00072 int str_copy3s(str* s, const char* a, const char* b, const char* c);
00073 int str_copy4s(str* s, const char* a, const char* b, const char* c, const char* d);
00074 int str_copy5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
00075 int str_copy6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
00076 /* @} */
00077 
00080 int str_cat(str* s, const str* in);
00081 int str_cats(str* s, const char* in);
00082 int str_catc(str* s, char in);
00083 int str_catb(str* s, const char* in, unsigned len);
00084 #define str_cati(S,I) str_catiw((S),(I),0,0)
00085 int str_catiw(str* s, long in, unsigned width, char pad);
00086 #define str_catu(S,I) str_catuw((S),(I),0,0)
00087 int str_catuw(str* s, unsigned long in, unsigned width, char pad);
00088 #define str_catx(S,I) str_catxw((S),(I),0,0)
00089 int str_catxw(str* s, unsigned long in, unsigned width, char pad);
00090 #define str_catill(S,I) str_catiw((S),(I),0,0)
00091 int str_catiwll(str* s, long long in, unsigned width, char pad);
00092 #define str_catull(S,I) str_catuw((S),(I),0,0)
00093 int str_catuwll(str* s, unsigned long long in, unsigned width, char pad);
00094 int str_cat2s(str* s, const char* a, const char* b);
00095 int str_cat3s(str* s, const char* a, const char* b, const char* c);
00096 int str_cat4s(str* s, const char* a, const char* b, const char* c, const char* d);
00097 int str_cat5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
00098 int str_cat6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
00099 
00100 int str_join(str* s, char sep, const str* t);
00101 int str_joins(str* s, char sep, const char* in);
00102 int str_joinb(str* s, char sep, const char* in, unsigned len);
00103 /* @} */
00104 
00106 /* @{ */
00107 void str_lower(str* s);
00108 void str_upper(str* s);
00109 void str_subst(str* s, char from, char to);
00110 void str_lstrip(str* s);
00111 void str_rstrip(str* s);
00112 #define str_strip(S) (str_rstrip(S), str_lstrip(S))
00113 void str_lcut(str* s, unsigned count);
00114 void str_rcut(str* s, unsigned count);
00115 int str_sort(str* s, char sep, long count,
00116              int (*fn)(const str_sortentry* a, const str_sortentry* b));
00117 /* @} */
00118 
00121 int str_cmp(const str* a, unsigned aoffset, const str* b, unsigned boffset);
00122 int str_cmps(const str* a, unsigned offset, const char* b);
00123 int str_cmpb(const str* a, unsigned offset, const char* b, unsigned len);
00124 
00125 int str_diff(const str* a, const str* b);
00126 int str_diffs(const str* a, const char* b);
00127 int str_diffb(const str* a, const char* b, unsigned len);
00128 /* @} */
00129 
00132 void str_buildmap(int map[256], const char* list);
00133 unsigned str_count(const str* s, char ch);
00134 unsigned str_countof(const str* s, const char* list);
00135 #define str_findfirst(S,C) str_findnext(S,C,0)
00136 #define str_findfirstof(S,L) str_findnextof(S,L,0)
00137 #define str_findfirstnot(S,L) str_findnextnot(S,L,0)
00138 #define str_findlast(S,C) str_findprev(S,C,-1)
00139 #define str_findlastof(S,L) str_findprevof(S,L,-1)
00140 #define str_findlastnot(S,L) str_findprevof(S,L,-1)
00141 int str_findnext(const str* s, char ch, unsigned pos);
00142 int str_findnextof(const str* s, const char* list, unsigned pos);
00143 int str_findnextnot(const str* s, const char* list, unsigned pos);
00144 int str_findprev(const str* s, char ch, unsigned pos);
00145 int str_findprevof(const str* s, const char* list, unsigned pos);
00146 int str_findprevnot(const str* s, const char* list, unsigned pos);
00147 /* @} */
00148 
00151 int str_match(const str* s, const char* pattern);
00152 /* @} */
00153 
00154 /* @} */
00155 
00156 #endif

Generated on Wed Mar 5 17:22:08 2003 for bglibs by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002