str.h

00001 /* $Id: str.h 616 2005-08-19 20:11:01Z bruce $ */
00002 #ifndef STR__H__
00003 #define STR__H__
00004 
00005 #include <stdarg.h>
00006 
00025 #define STR_BLOCKSIZE 16
00026 
00030 struct str
00031 {
00036   char* s;
00040   unsigned len;
00042   unsigned size;
00043 };
00045 typedef struct str str;
00046 
00051 struct str_sortentry
00052 {
00054   const char* str;
00056   unsigned long len;
00057 };
00059 typedef struct str_sortentry str_sortentry;
00060 
00063 extern const char str_lcase_digits[36];
00064 extern const char str_ucase_digits[36];
00069 int str_init(str* s);
00070 int str_alloc(str* s, unsigned size, int copy);
00072 #define str_ready(S,SZ) str_alloc(S,SZ,0)
00073 
00074 #define str_realloc(S,SZ) str_alloc(S,SZ,1)
00075 void str_free(str* s);
00076 int str_truncate(str* s, unsigned len);
00081 int str_copy(str* s, const str* in);
00082 int str_copys(str* s, const char* in);
00083 int str_copyb(str* s, const char* in, unsigned len);
00084 int str_copyf(str* s, const char* format, ...);
00085 int str_copyfv(str* s, const char* format, va_list ap);
00086 int str_copyns(str* s, unsigned int count, ...);
00087 int str_copy2s(str* s, const char* a, const char* b);
00088 int str_copy3s(str* s, const char* a, const char* b, const char* c);
00089 int str_copy4s(str* s, const char* a, const char* b, const char* c, const char* d);
00090 int str_copy5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
00091 int str_copy6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
00096 int str_cat(str* s, const str* in);
00097 int str_cats(str* s, const char* in);
00098 int str_catc(str* s, char in);
00099 int str_catb(str* s, const char* in, unsigned len);
00100 int str_catf(str* s, const char* format, ...);
00101 int str_catfv(str* s, const char* format, va_list ap);
00102 int str_cati(str* s, long in);
00103 int str_catiw(str* s, long in, unsigned width, char pad);
00104 int str_catu(str* s, unsigned long in);
00105 int str_catuw(str* s, unsigned long in, unsigned width, char pad);
00106 int str_catx(str* s, unsigned long in);
00107 int str_catxw(str* s, unsigned long in, unsigned width, char pad);
00108 int str_catill(str* s, long long in);
00109 int str_catiwll(str* s, long long in, unsigned width, char pad);
00110 int str_catull(str* s, unsigned long long in);
00111 int str_catuwll(str* s, unsigned long long in, unsigned width, char pad);
00112 int str_catxll(str* s, unsigned long long in);
00113 int str_catxwll(str* s, unsigned long long in, unsigned width, char pad);
00114 int str_catsnumw(str* s, long in, unsigned width, char pad,
00115                  unsigned base, const char* digits);
00116 int str_catunumw(str* s, unsigned long in, unsigned width, char pad,
00117                  unsigned base, const char* digits);
00118 int str_catsllnumw(str* s, long long in, unsigned width, char pad,
00119                    unsigned base, const char* digits);
00120 int str_catullnumw(str* s, unsigned long long in, unsigned width, char pad,
00121                    unsigned base, const char* digits);
00122 int str_catns(str* s, unsigned int count, ...);
00123 int str_cat2s(str* s, const char* a, const char* b);
00124 int str_cat3s(str* s, const char* a, const char* b, const char* c);
00125 int str_cat4s(str* s, const char* a, const char* b, const char* c, const char* d);
00126 int str_cat5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
00127 int str_cat6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
00128 
00129 int str_join(str* s, char sep, const str* t);
00130 int str_joins(str* s, char sep, const char* in);
00131 int str_joinb(str* s, char sep, const char* in, unsigned len);
00135 /* @{ */
00136 void str_lower(str* s);
00137 void str_upper(str* s);
00138 long str_subst(str* s, char from, char to);
00139 void str_lstrip(str* s);
00140 void str_rstrip(str* s);
00141 #define str_strip(S) (str_rstrip(S), str_lstrip(S))
00142 void str_lcut(str* s, unsigned count);
00143 void str_rcut(str* s, unsigned count);
00144 int str_sort(str* s, char sep, long count,
00145              int (*fn)(const str_sortentry* a, const str_sortentry* b));
00146 int str_splice(str* s, unsigned start, unsigned len, const str* r);
00147 int str_splices(str* s, unsigned start, unsigned len, const char* r);
00148 int str_spliceb(str* s, unsigned start, unsigned len,
00149                 const char* r, unsigned rlen);
00150 long str_xlate(str* s, const char* from, const char* to, unsigned nchars);
00155 int str_cmp(const str* a, unsigned aoffset, const str* b, unsigned boffset);
00156 int str_cmps(const str* a, unsigned offset, const char* b);
00157 int str_cmpb(const str* a, unsigned offset, const char* b, unsigned len);
00158 
00159 int str_diff(const str* a, const str* b);
00160 int str_diffs(const str* a, const char* b);
00161 int str_diffb(const str* a, const char* b, unsigned len);
00162 
00163 int str_start(const str* a, const str* b);
00164 int str_starts(const str* a, const char* b);
00165 int str_startb(const str* a, const char* b, unsigned len);
00166 
00167 int str_case_start(const str* a, const str* b);
00168 int str_case_starts(const str* a, const char* b);
00169 int str_case_startb(const str* a, const char* b, unsigned len);
00174 void str_buildmap(int map[256], const char* list);
00175 unsigned str_count(const str* s, char ch);
00176 unsigned str_countof(const str* s, const char* list);
00177 #define str_findfirst(S,C) str_findnext(S,C,0)
00178 #define str_findfirstof(S,L) str_findnextof(S,L,0)
00179 #define str_findfirstnot(S,L) str_findnextnot(S,L,0)
00180 #define str_findlast(S,C) str_findprev(S,C,-1)
00181 #define str_findlastof(S,L) str_findprevof(S,L,-1)
00182 #define str_findlastnot(S,L) str_findprevof(S,L,-1)
00183 int str_findnext(const str* s, char ch, unsigned pos);
00184 int str_findnextof(const str* s, const char* list, unsigned pos);
00185 int str_findnextnot(const str* s, const char* list, unsigned pos);
00186 int str_findprev(const str* s, char ch, unsigned pos);
00187 int str_findprevof(const str* s, const char* list, unsigned pos);
00188 int str_findprevnot(const str* s, const char* list, unsigned pos);
00193 int str_match(const str* s, const str* pattern);
00194 int str_matchb(const str* s, const char* pptr, unsigned plen);
00195 int str_matchs(const str* s, const char* pattern);
00196 int str_case_match(const str* s, const str* pattern);
00197 int str_case_matchb(const str* s, const char* pptr, unsigned plen);
00198 int str_case_matchs(const str* s, const char* pattern);
00199 int str_glob(const str* s, const str* pattern);
00200 int str_globb(const str* s, const char* pptr, unsigned plen);
00201 int str_globs(const str* s, const char* pattern);
00202 int str_case_glob(const str* s, const str* pattern);
00203 int str_case_globb(const str* s, const char* pptr, unsigned plen);
00204 int str_case_globs(const str* s, const char* pattern);
00209 #endif

Generated on Mon Oct 30 15:11:13 2006 for bglibs by  doxygen 1.4.7