str.h

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

Generated on Thu Feb 19 11:11:50 2009 for bglibs by  doxygen 1.5.4