- Timestamp:
- 12/03/14 18:52:05 (10 years ago)
- Location:
- cpp
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/Convert.cpp
r247 r257 90 90 #if defined LINUX // || android? 91 91 return *::localtime_r(&timep,&ret); 92 #elif defined _WIN32 && !defined __BORLANDC__ // and not bada?92 #elif defined _WIN32 && !defined __BORLANDC__ 93 93 ::localtime_s(&ret, &timep); 94 94 return ret; … … 115 115 #if defined LINUX // || android? 116 116 ret=::asctime_r(&tm,buf); 117 #elif defined _WIN32 && !defined __BORLANDC__ // and not bada?117 #elif defined _WIN32 && !defined __BORLANDC__ 118 118 asctime_s(buf, sizeof(buf), &tm); 119 119 ret = buf; -
cpp/common/stl-util.cpp
r247 r257 11 11 #include <assert.h> 12 12 #ifdef USE_VIRTFILE 13 13 #include <frams/virtfile/virtfile.h> 14 14 #endif 15 15 #ifdef __BORLANDC__ 16 16 #define va_copy(to,from) to=from //borland does not have va_copy() at all; va_list is just a pointer in borland 17 17 #endif 18 18 … … 27 27 //almost like SString::sprintf, but there is no common code to share because SString can use its directWrite to avoid double allocating/copying 28 28 #ifdef USE_VSCPRINTF 29 va_copy(ap_copy, ap);29 va_copy(ap_copy, ap); 30 30 size = _vscprintf(format, ap_copy) + 1; //+1 for terminating null character 31 31 va_end(ap_copy); … … 36 36 buf = (char*)malloc(size); 37 37 assert(buf != NULL); 38 va_copy(ap_copy, ap);38 va_copy(ap_copy, ap); 39 39 int n = vsnprintf(buf, size, format, ap_copy); 40 40 va_end(ap_copy); … … 55 55 } 56 56 57 char* strmove(char *a, char *b) //strcpy that works well for overlapping strings ("Source and destination overlap") 58 { 59 if (a == NULL || b == NULL) 60 return NULL; 61 memmove(a, b, strlen(b) + 1); 62 return a; 63 } 64 57 65 string ssprintf(const char* format, ...) 58 66 { … … 66 74 bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file) 67 75 { 68 bool ok=false;76 bool ok = false; 69 77 #ifdef USE_VIRTFILE 70 78 if (!isAbsolutePath(filename)) 71 79 { 72 80 VirtFILE *f=Vfopen(filename,FOPEN_READ_BINARY); 73 81 if (f) 74 82 { 75 83 int size=f->getSize(); 76 84 data.resize(size); … … 78 86 ok = przeczytane == 1; 79 87 delete f; 80 }81 88 } 89 } 82 90 else 83 91 #endif 84 92 { 85 MFILE *f = mfopen(filename, FOPEN_READ_BINARY);86 if (f)87 {88 int size=getFileSize(f);89 data.resize(size);90 int przeczytane = mfread(&data[0], size, 1, f);91 mfclose(f);92 ok = przeczytane == 1;93 }93 MFILE *f = mfopen(filename, FOPEN_READ_BINARY); 94 if (f) 95 { 96 int size = getFileSize(f); 97 data.resize(size); 98 int przeczytane = mfread(&data[0], size, 1, f); 99 mfclose(f); 100 ok = przeczytane == 1; 101 } 94 102 } 95 103 if (warn_on_missing_file && !ok) -
cpp/common/stl-util.h
r246 r257 11 11 template<typename T, std::size_t N> void push_back(vector<T>& v, T(&d)[N]) 12 12 { 13 for(unsigned int i=0;i<N;i++)14 v.push_back(d[i]);13 for (unsigned int i = 0; i < N; i++) 14 v.push_back(d[i]); 15 15 } 16 16 17 17 template<typename T> void erase(vector<T>& v, const T& e) 18 18 { 19 typename vector<T>::iterator it=std::find(v.begin(),v.end(),e);20 if (it!=v.end())21 v.erase(it);19 typename vector<T>::iterator it = std::find(v.begin(), v.end(), e); 20 if (it != v.end()) 21 v.erase(it); 22 22 } 23 23 24 24 template<typename T> void deleteVectorElements(vector<T*>& v) 25 25 { 26 for(typename vector<T*>::iterator it=v.begin();it!=v.end();it++)27 delete *it;28 v.clear();26 for (typename vector<T*>::iterator it = v.begin(); it != v.end(); it++) 27 delete *it; 28 v.clear(); 29 29 } 30 30 31 31 template<typename T> int findIndex(vector<T>& v, const T& e) 32 32 { 33 typename vector<T>::iterator it=find(v.begin(),v.end(),e);34 if (it!=v.end())35 return &*it-&v.front();36 return -1;33 typename vector<T>::iterator it = find(v.begin(), v.end(), e); 34 if (it != v.end()) 35 return &*it - &v.front(); 36 return -1; 37 37 } 38 39 40 char* strmove(char *a, char *b); //strcpy that works well for overlapping strings ("Source and destination overlap") 38 41 39 42 string ssprintf(const char* format, ...); … … 45 48 46 49 47 bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file =true);48 bool readCompleteFile(const char* filename, string& out, bool warn_on_missing_file =true);49 bool writeCompleteFile(const char* filename, const std::string& text, bool warn_on_fail=true);50 bool writeCompleteFile(const char* filename, vector<char>& data, bool warn_on_fail =true);50 bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file = true); 51 bool readCompleteFile(const char* filename, string& out, bool warn_on_missing_file = true); 52 bool writeCompleteFile(const char* filename, const std::string& text, bool warn_on_fail = true); 53 bool writeCompleteFile(const char* filename, vector<char>& data, bool warn_on_fail = true); 51 54 52 55 template<class T> class DeletingVector // deletes the elements (pointers) in destructor 53 56 { 54 55 std::vector<T*> vector;56 ~DeletingVector()57 public: 58 std::vector<T*> vector; 59 ~DeletingVector() 57 60 { 58 for(int i=vector.size()-1;i>=0;i--)59 delete vector[i];61 for (int i = vector.size() - 1; i >= 0; i--) 62 delete vector[i]; 60 63 } 61 T* operator[](int i) {return vector[i];}62 int size() {return vector.size();}63 void push_back(T* x) {vector.push_back(x);}64 T* operator[](int i) { return vector[i]; } 65 int size() { return vector.size(); } 66 void push_back(T* x) { vector.push_back(x); } 64 67 }; 65 68 -
cpp/frams/genetics/genman.cpp
r247 r257 300 300 { 301 301 char format = g1.getFormat(); 302 if (format != g2.getFormat()) return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver() does not know how to handleparents with differing genetic formats (%c and %c)", format, g2.getFormat()));302 if (format != g2.getFormat()) return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver(): does not work for parents with differing genetic formats (%c and %c)", format, g2.getFormat())); 303 303 GenoOperators *gf = getOper_f(format); 304 304 if (gf == NULL) 305 return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver(): don't know how to handlegenetic format %c", format));305 return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver(): no operators found for genetic format %c", format)); 306 306 Geno g1v = g1, g2v = g2; 307 307 -
cpp/frams/util/extvalue.cpp
r247 r257 51 51 if (destroy) delete dbobject; 52 52 } 53 } 54 55 bool ExtObject::operator==(const ExtObject& src) const 56 { 57 if (object!=src.object) return false; 58 const char* n1=interfaceName(); 59 const char* n2=src.interfaceName(); 60 return (n1==n2) || (strcmp(n1,n2)==0); 53 61 } 54 62 -
cpp/frams/util/extvalue.h
r247 r257 65 65 bool makeUnique();//< @return false if nothing has changed 66 66 67 int operator==(const ExtObject& src) const {if (object!=src.object) return 0; return (object==0)?(!strcmp(param->getName(),src.param->getName())):1;} 67 bool operator==(const ExtObject& src) const; 68 68 69 69 SString toString() const; -
cpp/frams/util/sstringutils.cpp
r210 r257 8 8 #include <common/nonstd.h> 9 9 10 int loadSString(const char* filename, SString& s,const char* framsgmodule,const char* error)11 { 12 VirtFILE *f;13 int ret=0;14 if (f=Vfopen(filename,FOPEN_READ_BINARY))15 { 16 loadSString(f,s);17 ret=1;18 fclose(f);19 } 20 else if (framsgmodule)21 FMprintf(framsgmodule,"loadSString",FMLV_WARN,error?error:"can't open file \"%s\"",filename);22 return ret;23 } 24 25 void loadSString(VirtFILE *f, SString& s)26 { 27 char buf[1024];28 int len;29 while(!f->Veof())30 { 31 len=fread(buf,1,sizeof(buf),f);32 s.append(buf,len);33 } 34 removeCR(s);10 int loadSString(const char* filename, SString& s, const char* framsgmodule, const char* error) 11 { 12 VirtFILE *f; 13 int ret = 0; 14 if (f = Vfopen(filename, FOPEN_READ_BINARY)) 15 { 16 loadSString(f, s); 17 ret = 1; 18 fclose(f); 19 } 20 else if (framsgmodule) 21 FMprintf(framsgmodule, "loadSString", FMLV_WARN, error ? error : "can't open file \"%s\"", filename); 22 return ret; 23 } 24 25 void loadSString(VirtFILE *f, SString& s) 26 { 27 char buf[1024]; 28 int len; 29 while (!f->Veof()) 30 { 31 len = fread(buf, 1, sizeof(buf), f); 32 s.append(buf, len); 33 } 34 removeCR(s); 35 35 } 36 36 37 37 //load single line, discarding any \r or \n found at the end, return false if nothing could be loaded (error or eof) 38 bool loadSStringLine(VirtFILE* f, SString& s)39 { 40 char buf[100];41 bool eolfound=false;42 bool ret=false;43 s=SString::empty();44 while(!eolfound)45 { 46 char *r=fgets(buf,sizeof(buf),f);47 if (r==NULL) break;48 ret=true;49 int d=strlen(r);50 if (d>0)51 { 52 if (r[d-1]=='\n') {d--; eolfound=true;}53 if (d>0) if (r[d-1]=='\r') d--;54 s+=SString(r,d);55 } 56 } 57 return ret;38 bool loadSStringLine(VirtFILE* f, SString& s) 39 { 40 char buf[100]; 41 bool eolfound = false; 42 bool ret = false; 43 s = SString::empty(); 44 while (!eolfound) 45 { 46 char *r = fgets(buf, sizeof(buf), f); 47 if (r == NULL) break; 48 ret = true; 49 int d = strlen(r); 50 if (d > 0) 51 { 52 if (r[d - 1] == '\n') { d--; eolfound = true; } 53 if (d > 0) if (r[d - 1] == '\r') d--; 54 s += SString(r, d); 55 } 56 } 57 return ret; 58 58 } 59 59 … … 63 63 int quoteTilde(SString &target) 64 64 { 65 const char* x=target;66 SString tmp;67 char *f;68 while(1)69 { 70 f=strchr((char*)x,'~');71 if (f)72 { 73 tmp.append(x,f-x);74 tmp+="\\~";75 x=f+1;76 } 77 else78 { 79 if (tmp.len()==0) return 0; // nothing was changed!80 tmp+=x;81 target=tmp;82 return 1;65 const char* x = target; 66 SString tmp; 67 char *f; 68 while (1) 69 { 70 f = strchr((char*)x, '~'); 71 if (f) 72 { 73 tmp.append(x, f - x); 74 tmp += "\\~"; 75 x = f + 1; 76 } 77 else 78 { 79 if (tmp.len() == 0) return 0; // nothing was changed! 80 tmp += x; 81 target = tmp; 82 return 1; 83 83 } 84 84 } … … 88 88 int unquoteTilde(SString &target) 89 89 { 90 const char* x=target;91 SString tmp;92 char *f;93 while(1)94 { 95 f=strchr((char*)x,'\\');96 if (f)97 { 98 tmp.append(x,f-x);99 if (f[1]=='~')90 const char* x = target; 91 SString tmp; 92 char *f; 93 while (1) 94 { 95 f = strchr((char*)x, '\\'); 96 if (f) 97 { 98 tmp.append(x, f - x); 99 if (f[1] == '~') 100 100 { 101 tmp+='~';102 x=f+2;101 tmp += '~'; 102 x = f + 2; 103 103 } 104 else104 else 105 105 { 106 tmp+="\\";107 x=f+1;106 tmp += "\\"; 107 x = f + 1; 108 108 } 109 109 } 110 else 111 { 112 if (tmp.len() == 0) return 0; // nothing was changed! 113 tmp += x; 114 target = tmp; 115 return 1; 116 } 117 } 118 } 119 120 ///////////////// 121 122 bool strContainsOneOf(const char* str, const char* chars) 123 { 124 while (*str) 125 { 126 if (strchr(chars, *str)) return 1; 127 str++; 128 } 129 return 0; 130 } 131 132 ////////////// 133 134 bool sstringQuote(SString& target) 135 { 136 const char* x = target; 137 bool changed = 0; 138 SString tmp; 139 tmp.memoryHint(target.len()); 140 while (*x) 141 { 142 switch (*x) 143 { 144 case '\n': tmp += "\\n"; changed = 1; break; 145 case '\r': tmp += "\\r"; changed = 1; break; 146 case '\t': tmp += "\\t"; changed = 1; break; 147 case '\"': tmp += "\\\""; changed = 1; break; 148 case '\\': tmp += "\\\\"; changed = 1; break; 149 default: tmp += *x; 150 } 151 x++; 152 } 153 if (changed) target = tmp; 154 return changed; 155 } 156 157 const char* skipQuoteString(const char* txt, const char* limit) 158 { 159 while (*txt) 160 { 161 if (*txt == '\"') return txt; 162 if (*txt == '\\') txt++; 163 txt++; 164 if (txt == limit) break; 165 } 166 return txt; 167 } 168 169 int sstringUnquote(SString &target) 170 { 171 const char* x = target; 172 SString tmp; 173 char *f; 174 while (1) 175 { 176 f = strchr((char*)x, '\\'); 177 if (f) 178 { 179 tmp.append(x, f - x); 180 switch (f[1]) 181 { 182 case 'n': tmp += '\n'; break; 183 case 'r': tmp += '\r'; break; 184 case 't': tmp += '\t'; break; 185 case '\"': tmp += '\"'; break; 186 default: tmp += f[1]; 187 } 188 x = f + 2; 189 } 190 else 191 { 192 if (tmp.len() == 0) return 0; // nothing was changed! 193 tmp += x; 194 target = tmp; 195 return 1; 196 } 197 } 198 } 199 200 int strFindField(const SString& txt, const SString& name, int &end) 201 { 202 const char* t = txt, *n; 203 int pos = 0; 204 while (1) 205 { 206 n = strchr(t + pos, ','); 207 if ((!strncmp(t + pos, name, name.len())) && (t[pos + name.len()] == '=')) 208 { 209 if (n) end = n - t; else end = txt.len(); 210 return pos; 211 } 212 if (n) pos = n - t + 1; else break; 213 } 214 return -1; 215 } 216 217 SString strGetField(const SString& txt, const SString& name) 218 { 219 int p, e; 220 p = strFindField(txt, name, e); 221 if (p < 0) return SString(); 222 p += name.len() + 1; 223 return SString(txt.substr(p, e - p)); 224 } 225 226 void strSetField(SString& txt, const SString& name, const SString& value) 227 { 228 int p, e; 229 p = strFindField(txt, name, e); 230 if (p < 0) 231 { 232 if (!value.len()) return; 233 char *t = txt.directAppend(1 + name.len() + value.len()); 234 char *b = t; 235 if (txt.len()) *(t++) = ','; 236 strcpy(t, name); t += name.len(); 237 *(t++) = '='; 238 strcpy(t, value); t += value.len(); 239 txt.endAppend(t - b); 240 } 110 241 else 111 { 112 if (tmp.len()==0) return 0; // nothing was changed! 113 tmp+=x; 114 target=tmp; 115 return 1; 116 } 117 } 118 } 119 120 ///////////////// 121 122 bool strContainsOneOf(const char* str,const char* chars) 123 { 124 while(*str) 125 { 126 if (strchr(chars,*str)) return 1; 127 str++; 128 } 129 return 0; 130 } 131 132 ////////////// 133 134 bool sstringQuote(SString& target) 135 { 136 const char* x=target; 137 bool changed=0; 138 SString tmp; 139 tmp.memoryHint(target.len()); 140 while(*x) 141 { 142 switch(*x) 143 { 144 case '\n': tmp+="\\n"; changed=1; break; 145 case '\r': tmp+="\\r"; changed=1; break; 146 case '\t': tmp+="\\t"; changed=1; break; 147 case '\"': tmp+="\\\""; changed=1; break; 148 case '\\': tmp+="\\\\"; changed=1; break; 149 default: tmp+=*x; 150 } 151 x++; 152 } 153 if (changed) target=tmp; 154 return changed; 155 } 156 157 const char* skipQuoteString(const char* txt, const char* limit) 158 { 159 while(*txt) 160 { 161 if (*txt=='\"') return txt; 162 if (*txt=='\\') txt++; 163 txt++; 164 if (txt==limit) break; 165 } 166 return txt; 167 } 168 169 int sstringUnquote(SString &target) 170 { 171 const char* x=target; 172 SString tmp; 173 char *f; 174 while(1) 175 { 176 f=strchr((char*)x,'\\'); 177 if (f) 178 { 179 tmp.append(x,f-x); 180 switch(f[1]) 181 { 182 case 'n': tmp+='\n'; break; 183 case 'r': tmp+='\r'; break; 184 case 't': tmp+='\t'; break; 185 case '\"': tmp+='\"'; break; 186 default: tmp+=f[1]; 187 } 188 x=f+2; 189 } 242 { 243 if (!value.len()) 244 { 245 if (p > 0) p--; else if (e < txt.len()) e++; 246 char *t = txt.directWrite(0); 247 memmove(t + p, t + e, txt.len() - e); 248 txt.endWrite(txt.len() + value.len() - (e - p)); 249 } 250 else 251 { 252 p += name.len() + 1; 253 char *t = txt.directWrite(txt.len() + value.len() - (e - p)); 254 memmove(t + p + value.len(), t + e, txt.len() - e); 255 memmove(t + p, value, value.len()); 256 txt.endWrite(txt.len() + value.len() - (e - p)); 257 } 258 } 259 } 260 261 SString trim(SString& s) 262 { 263 const unsigned char*b = (const unsigned char*)(const char*)s; 264 const unsigned char*e = b + s.len(); 265 while ((b < e) && (*b <= ' ')) b++; 266 while ((b < e) && (e[-1] <= ' ')) e--; 267 if ((e - b) == s.len()) return s; 268 SString newstring; 269 char* t = newstring.directWrite(e - b); 270 memmove(t, b, e - b); 271 newstring.endWrite(e - b); 272 return newstring; 273 } 274 275 bool removeCR(SString& s) 276 { 277 const char* p = (const char*)s; 278 const char* cr = strchr(p, '\r'); 279 if (!cr) return false; 280 char* begin = s.directWrite(); 281 char* src = begin + (cr - p), *dst = src; 282 while (*src) 283 if (*src == '\r') 284 src++; 285 else 286 *(dst++) = *(src++); 287 s.endWrite(dst - begin); 288 return true; 289 } 290 291 bool matchWildcard(const SString& word, const SString& pattern) 292 { 293 if (pattern.len() == 0) 294 return word.len() == 0; 295 int aster = pattern.indexOf('*'); 296 if (aster >= 0) 297 { 298 SString before = pattern.substr(0, aster); 299 SString after = pattern.substr(aster + 1); 300 int pos = 0; 301 if (!word.len()) return false; 302 if (before.len()) if (!word.startsWith(before)) return false; 303 if (after.len()) 304 if ((word.len() < after.len()) 305 || (strcmp((const char*)after, ((const char*)word) + word.len() - after.len()))) 306 return false; 307 return true; 308 } 190 309 else 191 { 192 if (tmp.len()==0) return 0; // nothing was changed! 193 tmp+=x; 194 target=tmp; 195 return 1; 196 } 197 } 198 } 199 200 int strFindField(const SString& txt,const SString& name,int &end) 201 { 202 const char* t=txt,*n; 203 int pos=0; 204 while(1) 205 { 206 n=strchr(t+pos,','); 207 if ((!strncmp(t+pos,name,name.len()))&&(t[pos+name.len()]=='=')) 208 { 209 if (n) end=n-t; else end=txt.len(); 210 return pos; 211 } 212 if (n) pos=n-t+1; else break; 213 } 214 return -1; 215 } 216 217 SString strGetField(const SString& txt,const SString& name) 218 { 219 int p,e; 220 p=strFindField(txt,name,e); 221 if (p<0) return SString(); 222 p+=name.len()+1; 223 return SString(txt.substr(p,e-p)); 224 } 225 226 void strSetField(SString& txt,const SString& name,const SString& value) 227 { 228 int p,e; 229 p=strFindField(txt,name,e); 230 if (p<0) 231 { 232 if (!value.len()) return; 233 char *t=txt.directAppend(1+name.len()+value.len()); 234 char *b=t; 235 if (txt.len()) *(t++)=','; 236 strcpy(t,name); t+=name.len(); 237 *(t++)='='; 238 strcpy(t,value); t+=value.len(); 239 txt.endAppend(t-b); 240 } 241 else 242 { 243 if (!value.len()) 244 { 245 if (p>0) p--; else if (e<txt.len()) e++; 246 char *t=txt.directWrite(0); 247 memmove(t+p,t+e,txt.len()-e); 248 txt.endWrite(txt.len()+value.len()-(e-p)); 249 } 250 else 251 { 252 p+=name.len()+1; 253 char *t=txt.directWrite(txt.len()+value.len()-(e-p)); 254 memmove(t+p+value.len(),t+e,txt.len()-e); 255 memmove(t+p,value,value.len()); 256 txt.endWrite(txt.len()+value.len()-(e-p)); 257 } 258 } 259 } 260 261 SString trim(SString& s) 262 { 263 const unsigned char*b=(const unsigned char*)(const char*)s; 264 const unsigned char*e=b+s.len(); 265 while((b<e)&&(*b<=' ')) b++; 266 while((b<e)&&(e[-1]<=' ')) e--; 267 if ((e-b)==s.len()) return s; 268 SString newstring; 269 char* t=newstring.directWrite(e-b); 270 memmove(t,b,e-b); 271 newstring.endWrite(e-b); 272 return newstring; 273 } 274 275 bool removeCR(SString& s) 276 { 277 const char* p=(const char*)s; 278 const char* cr=strchr(p,'\r'); 279 if (!cr) return false; 280 char* begin=s.directWrite(); 281 char* src=begin+(cr-p),*dst=src; 282 while(*src) 283 if (*src=='\r') 284 src++; 285 else 286 *(dst++)=*(src++); 287 s.endWrite(dst-begin); 288 return true; 289 } 290 291 bool matchWildcard(const SString& word,const SString& pattern) 292 { 293 if (pattern.len()==0) 294 return word.len()==0; 295 int aster=pattern.indexOf('*'); 296 if (aster>=0) 297 { 298 SString before=pattern.substr(0,aster); 299 SString after=pattern.substr(aster+1); 300 int pos=0; 301 if (!word.len()) return false; 302 if (before.len()) if (!word.startsWith(before)) return false; 303 if (after.len()) 304 if ((word.len()<after.len()) 305 ||(strcmp((const char*)after,((const char*)word)+word.len()-after.len()))) 306 return false; 307 return true; 308 } 309 else 310 return word==pattern; 311 } 312 313 bool matchWildcardList(const SString& word,const SString& patterns) 314 { 315 if (patterns.len()==0) 316 return word.len()==0; 317 int pos=0; 318 SString pattern; 319 while(patterns.getNextToken(pos,pattern,',')) 320 if (matchWildcard(word,pattern)) 321 return true; 322 return false; 323 } 324 310 return word == pattern; 311 } 312 313 bool matchWildcardList(const SString& word, const SString& patterns) 314 { 315 if (patterns.len() == 0) 316 return word.len() == 0; 317 int pos = 0; 318 SString pattern; 319 while (patterns.getNextToken(pos, pattern, ',')) 320 if (matchWildcard(word, pattern)) 321 return true; 322 return false; 323 } 324 -
cpp/frams/util/sstringutils.h
r210 r257 10 10 11 11 /// return: 1=ok 0=error 12 int loadSString(const char* filename, SString& s,const char* framsgmodule=0,const char* error=0);13 void loadSString(VirtFILE *f, SString& s);14 bool loadSStringLine(VirtFILE* f, SString &s);12 int loadSString(const char* filename, SString& s, const char* framsgmodule = 0, const char* error = 0); 13 void loadSString(VirtFILE *f, SString& s); 14 bool loadSStringLine(VirtFILE* f, SString &s); 15 15 16 16 int quoteTilde(SString &target); 17 17 int unquoteTilde(SString &target); 18 18 19 bool strContainsOneOf(const char* str, const char* chars);19 bool strContainsOneOf(const char* str, const char* chars); 20 20 bool sstringQuote(SString& target); 21 21 const char* skipQuoteString(const char* txt, const char* limit); 22 22 int sstringUnquote(SString &target); 23 23 24 int strFindField(const SString& txt, const SString& name,int &end);25 SString strGetField(const SString& txt, const SString& name);26 void strSetField(SString& txt, const SString& name,const SString& value);24 int strFindField(const SString& txt, const SString& name, int &end); 25 SString strGetField(const SString& txt, const SString& name); 26 void strSetField(SString& txt, const SString& name, const SString& value); 27 27 28 28 SString trim(SString& s); ///< remove leading/trailing whitespace 29 29 bool removeCR(SString& s); ///< remove '\r' return true if changed 30 bool matchWildcard(const SString& word, const SString& pattern);///< '*' in pattern matches any substring31 bool matchWildcardList(const SString& word, const SString& patterns);///< patterns is a list of patterns (separated by ',')30 bool matchWildcard(const SString& word, const SString& pattern);///< '*' in pattern matches any substring 31 bool matchWildcardList(const SString& word, const SString& patterns);///< patterns is a list of patterns (separated by ',') 32 32 33 33 #endif 34
Note: See TracChangeset
for help on using the changeset viewer.