| Bsoft 2.0.5 Bernard's software package

Bstring.cpp
Go to the documentation of this file.
1
9 #include <stdio.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include "Bstring.h"
13 #include "utilities.h"
14
15 // Definition of the global variables
16 extern int verbose; // Level of output to the screen
17
22 Bstring::Bstring(const Bstring& s)
23 {
24 data = NULL;
25 long len = s.length();
26 if ( len ) {
27 data = new char[len + 1];
28 ::strncpy(data, s.data, len);
29 data[len] = 0;
30 }
31 next = NULL;
32 }
33
34 Bstring::Bstring(const string& s)
35 {
36 data = NULL;
37 long len = s.length();
38 if ( len ) {
39 data = new char[len + 1];
40 ::strncpy(data, s.data(), len);
41 data[len] = 0;
42 }
43 next = NULL;
44 }
45
46 Bstring::Bstring(const Bstring& s, long start, long len)
47 {
48 data = NULL;
49 if ( start < 0 ) start = 0;
50 long end = start + len - 1;
51 long inlen = s.length();
52 if ( end >= inlen ) end = inlen - 1;
53 if ( start > end ) start = end;
54 len = end - start + 1;
55 if ( len ) {
56 data = new char[len + 1];
57 ::strncpy(data, &s.data[start], len);
58 data[len] = 0;
59 }
60 next = NULL;
61 }
62
63 Bstring::Bstring(const char* c)
64 {
65 data = NULL;
66 if ( c ) {
67 long len = ::strlen(c);
68 if ( len ) {
69 data = new char[len + 1];
70 ::strncpy(data, c, len);
71 data[len] = 0;
72 }
73 }
74 next = NULL;
75 }
76
77 Bstring::Bstring(const char* c, long start, long len)
78 {
79 data = NULL;
80 if ( c ) {
81 if ( start < 0 ) start = 0;
82 long end = start + len - 1;
83 long inlen = ::strlen(c);
84 if ( end >= inlen ) end = inlen - 1;
85 if ( start > end ) start = end;
86 len = end - start + 1;
87 if ( len ) {
88 data = new char[len + 1];
89 ::strncpy(data, c+start, len);
90 data[len] = 0;
91 }
92 }
93 next = NULL;
94 }
95
96 Bstring::Bstring(const char c, long size)
97 {
98 data = NULL;
99 if ( size ) {
100 // cout << "fill size = " << size << endl;
101 data = new char[size + 1];
102 for ( long i=0; i<size; i++ ) data[i] = c;
103 data[size] = 0;
104 }
105 next = NULL;
106 }
107
108 Bstring& Bstring::operator=(const Bstring& s)
109 {
110 if ( this == &s ) return *this;
111 if ( data ) delete[] data; // Delete existing string
112 data = NULL;
113 long len = s.length();
114 if ( len ) {
115 data = new char[len + 1];
116 ::strncpy(data, s.data, len); // Copy new string
117 data[len] = 0;
118 }
119 return *this;
120 }
121
122 Bstring& Bstring::operator=(const string& s)
123 {
124 if ( data ) delete[] data; // Delete existing string
125 data = NULL;
126 long len = s.length();
127 if ( len ) {
128 data = new char[len + 1];
129 ::strncpy(data, s.c_str(), len); // Copy new string
130 data[len] = 0;
131 }
132 return *this;
133 }
134
135 Bstring& Bstring::operator=(const char* c)
136 {
137 if ( data ) delete[] data; // Delete existing string
138 data = NULL;
139 long len(0);
140 if ( c ) len = ::strlen(c);
141 if ( len ) {
142 data = new char[len + 1];
143 ::strncpy(data, c, len);
144 data[len] = 0;
145 }
146 return *this;
147 }
148
149 Bstring& Bstring::operator+=(const Bstring& s)
150 {
151 *this = *this + s;
152 return *this;
153 }
154
155 Bstring Bstring::operator+(const Bstring& s)
156 {
157 Bstring ns;
158 long l1 = length();
159 long l2 = s.length();
160 long len = l1 + l2 + 1;
161 ns.data = new char[len];
162 memset(ns.data, 0, len);
163 char* ptr = ns.data;
164 if ( data ) ptr = ::stpncpy(ns.data, data, l1);
165 if ( s.data ) ::strncpy(ptr, s.data, l2);
166 ns.data[l1+l2] = 0;
167 return ns;
168 }
169
170 Bstring Bstring::operator+(const Bstring& s) const
171 {
172 Bstring ns;
173 long l1 = length();
174 long l2 = s.length();
175 long len = l1 + l2 + 1;
176 ns.data = new char[len];
177 memset(ns.data, 0, len);
178 char* ptr = ns.data;
179 if ( data ) ptr = ::stpncpy(ns.data, data, l1);
180 if ( s.data ) ::strncpy(ptr, s.data, l2);
181 ns.data[l1+l2] = 0;
182 return ns;
183 }
184
185 Bstring& Bstring::operator+=(const char c)
186 {
187 *this = *this + c;
188 return *this;
189 }
190
191 Bstring Bstring::operator+(const char c)
192 {
193 Bstring ns;
194 long len = length();
195 long nlen = len + 2;
196 ns.data = new char[nlen];
197 memset(ns.data, 0, nlen);
198 if ( data ) ::strcpy(ns.data, data);
199 ns.data[len] = c;
200 return ns;
201 }
202
203 bool Bstring::operator==(const Bstring& s)
204 {
205 return ( compare(s) == 0 );
206 }
207
208 bool Bstring::operator!=(const Bstring& s)
209 {
210 return ( compare(s) != 0 );
211 }
212
213 bool Bstring::operator>(const Bstring& s)
214 {
215 return ( compare(s) > 0 );
216 }
217
218 bool Bstring::operator<(const Bstring& s)
219 {
220 return ( compare(s) < 0 );
221 }
222
223 bool Bstring::operator>=(const Bstring& s)
224 {
225 return ( compare(s) >= 0 );
226 }
227
228 bool Bstring::operator<=(const Bstring& s)
229 {
230 return ( compare(s) <= 0 );
231 }
232
233 Bstring Bstring::operator<<(int n)
234 {
235 Bstring ns(*this, n, length() - n);
236 ns += substr(0, n);
237 return ns;
238 }
239
240 Bstring Bstring::operator>>(int n)
241 {
242 Bstring ns(*this, length() - n, n);
243 ns += substr(0, length() - n);
244 return ns;
245 }
246
247 char& Bstring::operator[](long i)
248 {
249 if ( !data ) {
250 cerr << "Error in Bstring::operator[]: String length = 0!" << endl;
251 bexit(-1);
252 }
253 long len = length();
254 if ( i < 0 ) {
255 if ( len ) while ( i < 0 ) i += len;
256 else i = 0;
257 } else {
258 while ( i >= len ) i -= len;
259 }
260 return data[i];
261 }
262
263 long Bstring::length() const
264 {
265 if ( !data ) return 0;
266 return ::strlen(data);
267 }
268
269 long Bstring::count(const char c)
270 {
271 long n(0);
272 if ( data )
273 for ( char* s = data; *s; s++ ) if ( *s == c ) n++;
274 return n;
275 }
276
277 long Bstring::compare(const Bstring& s)
278 {
279 if ( !data && !s.data ) return 0;
280 if ( !data ) return -1;
281 if ( !s.data ) return 1;
282 return ::strcmp(data, s.data);
283 }
284
285 long Bstring::compare_value(const Bstring& s)
286 {
287 if ( !data || !s.data ) {
288 cerr << "Error in Bstring::compare_value! (data = " << &data << " s.data = " << &(s.data) << endl;
289 bexit(-1);
290 }
291 long ld = length() - s.length();
292 if ( ld ) return ld;
293 return ::strcmp(data, s.data);
294 }
295
296 void Bstring::fill(const char c)
297 {
298 if ( data )
299 for ( char* s = data; *s; s++ ) *s = c;
300 }
301
302 void Bstring::place(long i, const Bstring& s)
303 {
304 long len(s.length());
305 if ( data ) strncpy(&data[i], s.data, len);
306 }
307
308 Bstring Bstring::lower()
309 {
310 Bstring ns(*this);
311 char *s, *sn;
312 for ( s = data, sn = ns.data; s && *s; s++, sn++ ) *sn = tolower(*s);
313 return ns;
314 }
315
316 Bstring Bstring::upper()
317 {
318 Bstring ns(*this);
319 char *s, *sn;
320 for ( s = data, sn = ns.data; *s; s++, sn++ ) *sn = toupper(*s);
321 return ns;
322 }
323
324 Bstring Bstring::substr(long start, long len)
325 {
326 long copylen = length() - start;
327 if ( copylen > len ) copylen = len;
328 Bstring ns(*this, start, copylen);
329 return ns;
330 }
331
332 Bstring Bstring::no_space()
333 {
334 long i, j;
335 for ( i=j=0; data[i]; i++ ) if ( !isspace(data[i]) ) j++;
336 Bstring ns('\0', j);
337 for ( i=j=0; data[i]; i++ ) if ( !isspace(data[i]) ) ns.data[j++] = data[i];
338 return ns;
339 }
340
341 Bstring Bstring::no_lead_space()
342 {
343 long i, j;
344 for ( i=j=0; isspace(data[i]); i++ ) j++;
345 Bstring ns(*this, j, length());
346 return ns;
347 }
348
349 Bstring Bstring::alnum()
350 {
351 long i, j;
352 for ( i=j=0; data[i]; i++ ) if ( isalnum(data[i]) ) j++;
353 Bstring ns('\0', j);
354 for ( i=j=0; data[i]; i++ ) if ( isalnum(data[i]) ) ns.data[j++] = data[i];
355 return ns;
356 }
357
358 Bstring Bstring::left(long len)
359 {
360 long copylen = length();
361 if ( copylen > len ) copylen = len;
362 Bstring ns(' ', copylen);
363 strncpy(ns.data, data, copylen);
364 return ns;
365 }
366
367 Bstring Bstring::right(long len)
368 {
369 long copylen = length();
370 if ( copylen > len ) copylen = len;
371 long start = len - copylen;
372 Bstring ns(' ', len);
373 strncpy(ns.data + start, data, copylen);
374 return ns;
375 }
376
377 /* Return the string before the first character.
378 If the character is not in the string, return the whole string.
379 If the character is the first in the string, return an empty string.
380 */
381 Bstring Bstring::pre(char c)
382 {
383 Bstring ns;
384 long i, len = length();
385 for ( i=0; i<len && data[i] != c; i++ ) ;
386 if ( i > 0 ) ns = Bstring(*this, 0, i);
387 return ns;
388 }
389
390 /* Return the string after the first character.
391 If the character is not in the string, return an empty string.
392 If the character is the last in the string, return an empty string.
393 */
394 Bstring Bstring::post(char c)
395 {
396 Bstring ns;
397 long i, len = length(), j = len;
398 for ( i=0; i<len && data[i] != c; i++ ) ;
399 if ( i < len ) {
400 i++;
401 j = len - i;
402 ns = Bstring(*this, i, j);
403 }
404 // } else i = 0;
405 // if ( j > 0 ) ns = Bstring(*this, i, j);
406 return ns;
407 }
408
409 /* Return the string before the last character.
410 If the character is not in the string, return the whole string.
411 If the character is the first in the string, return an empty string.
412 */
413 Bstring Bstring::pre_rev(char c)
414 {
415 Bstring ns;
416 long i, j = -1;
417 char* s;
418 for ( i=0, s = data; *s; i++, s++ ) if ( *s == c ) j = i;
419 if ( j < 0 ) j = i;
420 if ( j > 0 ) ns = Bstring(*this, 0, j);
421 return ns;
422 }
423
424 /* Return the string after the last character.
425 If the character is not in the string, return an empty string.
426 If the character is the last in the string, return an empty string.
427 */
428 Bstring Bstring::post_rev(char c)
429 {
430 Bstring ns;
431 long i, j = -1;
432 char* s;
433 for ( i=0, s = data; *s; i++, s++ ) if ( *s == c ) j = i;
434 if ( j > -1 ) {
435 j++;
436 i -= j;
437 if ( i > 0 ) ns = Bstring(*this, j, i);
438 }
439 return ns;
440 }
441
442 Bstring Bstring::within(char c1, char c2)
443 {
444 Bstring ns;
445 long i, j;
446 char* s;
447 for ( i=0, s = data; *s && *s != c1; i++, s++ ) ;
448 i++;
449 if ( *s ) s++;
450 if ( *s ) {
451 for ( j=0; *s && *s != c2; j++, s++ ) ;
452 if ( *s && j > 0 ) ns = Bstring(*this, i, j);
453 }
454 return ns;
455 }
456
457 Bstring Bstring::replace(char cold, char cnew)
458 {
459 Bstring ns(*this);
460 for ( char* s = ns.data; *s; s++ )
461 if ( *s == cold ) *s = cnew;
462 return ns;
463 }
464
465 Bstring Bstring::remove(const char c)
466 {
467 long nc = count(c);
468 if ( nc < 1 ) return *this;
469 long n = length() - nc;
470 Bstring ns(' ', n);
471 char *s, *sn;
472 for ( s = data, sn = ns.data; *s; s++ )
473 if ( *s != c ) *(sn++) = *s;
474 return ns;
475 }
476
477 Bstring Bstring::swap(const long i, const long j)
478 {
479 Bstring ns(*this);
480 ns.data[i] = data[j];
481 ns.data[j] = data[i];
482 return ns;
483 }
484
485 Bstring Bstring::erase(const long i)
486 {
487 long j, n = length() - 1;
488 Bstring ns(' ', n);
489 char *s, *sn;
490 for ( j=0, s = data, sn = ns.data; *s; s++, j++ )
491 if ( j != i ) *(sn++) = *s;
492 return ns;
493 }
494
495 Bstring Bstring::truncate(const long n)
496 {
497 long nlen = length() - n;
498 Bstring ns(' ', nlen);
499 char *s, *sn;
500 long i;
501 for ( i=0, s = data, sn = ns.data; i<nlen; i++ )
502 *(sn++) = *(s++);
503 return ns;
504 }
505
506 /* Removes both the leading path and extension from a filename string.
507 */
508 Bstring Bstring::base()
509 {
510 Bstring ns(*this);
511 if ( ns.contains("/") ) ns = ns.post_rev('/');
512 return ns.pre_rev('.');
513 }
514
515 Bstring Bstring::extension()
516 {
517 Bstring ns = pre(',');
518 if ( ns.find("#", 0) > -1 )
519 ns = "raw";
520 else if ( ns.find(":", 0) > -1 )
521 ns = ns.post(':');
522 else
523 ns = ns.post_rev('.');
524 return ns.lower();
525 }
526
527 Bstring Bstring::canonical(int n)
528 {
529 int i;
530 Bstring s(*this);
531 Bstring cs(*this);
532 for ( i=0; i<s.length(); i+=n ) {
533 s = s << n;
534 if ( cs > s ) cs = s;
535 }
536 return cs;
537 }
538
539 long Bstring::integer()
540 {
541 if ( !data ) return 0;
542 return strtol(data, NULL, 10);
543 }
544
545 double Bstring::real()
546 {
547 if ( !data ) return 0;
548 return strtod(data, NULL);
549 }
550
551 /* The offset of a search character is returned if found, otherwise a negative value is returned */
552 long Bstring::index(const char c, long start)
553 {
554 long offset;
555 char* aptr = &data[start];
556 for ( offset = start; *aptr && *aptr != c; aptr++, offset++ ) ;
557 if ( *aptr != c ) offset = -1;
558 return offset;
559 }
560
561 /* The offset of a search string is returned if found, otherwise a negative value is returned */
562 long Bstring::find(const Bstring& s, long start)
563 {
564 long len = s.length();
565 long offset;
566 char* aptr = &data[start];
567 for ( offset = start; *aptr; aptr++, offset++ )
568 if ( ::strncmp(s.data, aptr, len) == 0 ) break;
569 if ( *aptr == 0 ) offset = -1;
570 return offset;
571 }
572
573 /* The offset of a search string is returned if found, otherwise a negative value is returned */
574 long Bstring::rfind(const Bstring& s, long start)
575 {
576 long i, len = s.length();
577 long offset = -1;
578 char* aptr = &data[start];
579 for ( i = start; *aptr; aptr++, i++ )
580 if ( ::strncmp(s.data, aptr, len) == 0 ) offset = i;
581 return offset;
582 }
583
584 bool Bstring::contains(const Bstring& s)
585 {
586 if ( !data ) return 0;
587 return strstr(data, s.data) != NULL;
588 }
589
590 Bstring Bstring::insert(long pos, const Bstring& s)
591 {
592 Bstring ns = substr(0, pos);
593 Bstring ne = substr(pos, length() - pos);
594 return ns + s + ne;
595 }
596
597 Bstring* Bstring::split()
598 {
599 if ( !data ) return NULL;
600 long len = length();
601 if ( len < 1 ) return NULL;
602 long i;
603 Bstring tstr;
604 Bstring* list = NULL;
605 Bstring* astring = NULL;
606 char* sptr = data;
607 char* aptr = data;
608 for ( i=0; i<=len; i++, aptr++ ) {
609 if ( isspace(*sptr) ) sptr++;
610 else if ( *aptr==0 || isspace(*aptr) ) {
611 tstr = substr(sptr - data, aptr - sptr);
612 if ( tstr.length() ) {
613 astring = string_add(&astring, tstr);
614 if ( !list ) list = astring;
615 sptr = aptr;
616 }
617 }
618 }
619 return list;
620 }
621
622 Bstring* Bstring::split(const Bstring& delim)
623 {
624 long dlen = delim.length();
625 if ( dlen < 1 ) return split();
626 long len = length();
627 if ( len < 1 ) return NULL;
628 long i;
629 Bstring tstr;
630 Bstring* list = NULL;
631 Bstring* astring = NULL;
632 char* sptr = data;
633 char* aptr = data;
634 for ( i=0; i<=len; i++, aptr++ ) {
635 if ( *aptr==0 || ::strncmp(aptr, delim.data, dlen) == 0 ) {
636 tstr = substr(sptr - data, aptr - sptr);
637 if ( tstr.length() ) {
638 astring = string_add(&astring, tstr);
639 if ( !list ) list = astring;
640 sptr = aptr + dlen;
641 aptr += dlen - 1;
642 i += dlen - 1;
643 }
644 }
645 }
646 return list;
647 }
648
649 vector<long> Bstring::split_into_integers(const Bstring& delim)
650 {
651 vector<long> array;
652
653 Bstring* list = split(delim);
654 if ( !list ) return array;
655
656 Bstring* astring = NULL;
657 for ( astring=list; astring; astring=astring->next )
658 array.push_back(astring->integer());
659
660 string_kill(list);
661
662 return array;
663 }
664
665 vector<double> Bstring::split_into_doubles(const Bstring& delim)
666 {
667 vector<double> array;
668
669 Bstring* list = split(delim);
670 if ( !list ) return array;
671
672 Bstring* astring = NULL;
673 for ( astring=list; astring; astring=astring->next )
674 array.push_back(astring->real());
675
676 string_kill(list);
677
678 return array;
679 }
680
681 Bstring operator+(const char* c, const Bstring& s)
682 {
683 Bstring ns(c);
684 return ns += s;
685 }
686
687 istream& operator>>(istream& input, Bstring& s) {
688 string str;
689 input >> str;
690 s = str;
691 return input;
692 }
693
694 ostream& operator<<(ostream& output, Bstring& s) {
695 if ( s.length() ) output << left << s.c_str();
696 return output;
697 }
698
705 Bstring* string_add(Bstring** list, const char* string)
706 {
707 Bstring this_string(string);
708 return string_add(list, this_string);
709 }
710
711 Bstring* string_add(Bstring** list, Bstring& string)
712 {
713 Bstring* this_string = *list;
714
715 if ( string.empty() ) return this_string;
716
717 Bstring* new_string = new Bstring;
718
719 *new_string = string;
720
721 if ( !this_string )
722 *list = new_string;
723 else {
724 while ( this_string->next ) this_string = this_string->next;
725 this_string->next = new_string;
726 }
727
728 if ( verbose & VERB_DEBUG )
729 cout << "DEBUG string_add: " << *new_string << " (" << new_string->length() << ")" << endl;
730
731 return new_string;
732 }
733
739 Bstring string_catenate(Bstring* list)
740 {
741 long i, len(0);
742 Bstring* str;
743
744 for ( str = list; str; str = str->next )
745 len += str->length();
746
747 Bstring cat = Bstring(' ', len);
748
749 for ( i=0, str = list; str && i<len; i+=str->length(), str = str->next )
750 cat.place(i, *str);
751
752 return cat;
753 }
754
760 int string_kill(Bstring* list)
761 {
762 if ( !list ) return 0;
763
764 Bstring *s, *s2;
765
766 for ( s = list; s; ) {
767 s2 = s->next;
768 // *s = 0;
769 delete s;
770 s = s2;
771 }
772
773 return 0;
774 }
775
787 Bstring parameter_file_path(Bstring filename)
788 {
789 Bstring path;
790
791 if ( access(filename.c_str(), R_OK) == 0 )
792 return filename;
793
794 if ( getenv("BPARAM") ) {
795 path = getenv("BPARAM");
796 if ( path[-1] != ']' && path[-1] != '/')
797 path += "/";
798 } else
799 path = "/usr/local/bsoft/parameters/";
800 path += filename;
801
802 if ( verbose & VERB_DEBUG )
803 cout << "DEBUG parameter_file_path: " << path << endl;
804
805 return path;
806 }
807
814 int QsortSmallToLargeString(const void *x, const void *y)
815 {
816 Bstring* s1 = (Bstring*) x;
817 Bstring* s2 = (Bstring*) y;
818 if( *s1 < *s2 ) return -1;
819 else return 1;
820 }
821
828 int QsortLargeToSmallString(const void *x, const void *y)
829 {
830 Bstring* s1 = (Bstring*) x;
831 Bstring* s2 = (Bstring*) y;
832 if( *s1 > *s2 ) return -1;
833 else return 1;
834 }
835
842 int QsortSmallToLargeStringValue(const void *x, const void *y)
843 {
844 Bstring* s1 = (Bstring*) x;
845 Bstring* s2 = (Bstring*) y;
846 if( s1->compare_value(*s2) < 0 ) return -1;
847 else return 1;
848 }
849
856 int QsortLargeToSmallStringValue(const void *x, const void *y)
857 {
858 Bstring* s1 = (Bstring*) x;
859 Bstring* s2 = (Bstring*) y;
860 if( s1->compare_value(*s2) > 0 ) return -1;
861 else return 1;
862 }
863
875 int string_sort(Bstring* slist, int descending, int value)
876 {
877 int i, n(0);
878 Bstring* s;
879
880 for ( s = slist; s; s = s->next ) n++;
881
882 Bstring* ssort = new Bstring[n];
883
884 for ( i=0, s = slist; s; s = s->next, i++ ) ssort[i] = *s;
885
886 if ( value ) {
887 if ( descending ) qsort((void *) ssort, n, sizeof(Bstring), QsortLargeToSmallStringValue);
888 else qsort((void *) ssort, n, sizeof(Bstring), QsortSmallToLargeStringValue);
889 } else {
890 if ( descending ) qsort((void *) ssort, n, sizeof(Bstring), QsortLargeToSmallString);
891 else qsort((void *) ssort, n, sizeof(Bstring), QsortSmallToLargeString);
892 }
893
894 for ( i=0, s = slist; s; s = s->next, i++ ) *s = ssort[i];
895
896 delete[] ssort;
897
898 return 0;
899 }
string_sort
int string_sort(Bstring *slist, int descending, int value)
Sorts a list of strings in ascending (descending) lexical or value order.
Definition: Bstring.cpp:875
Bstring::real
double real()
Definition: Bstring.cpp:545
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:394
Bstring::alnum
Bstring alnum()
Definition: Bstring.cpp:349
Bstring::operator+
Bstring operator+(const Bstring &s)
Definition: Bstring.cpp:155
Bstring::substr
Bstring substr(long start, long len)
Definition: Bstring.cpp:324
verbose
int verbose
operator>>
istream & operator>>(istream &input, Bstring &s)
Definition: Bstring.cpp:687
utilities.h
Header file for general utilities.
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
Bstring::find
long find(const Bstring &s)
Definition: Bstring.h:103
Bstring::left
Bstring left(long len)
Definition: Bstring.cpp:358
QsortLargeToSmallString
int QsortLargeToSmallString(const void *x, const void *y)
Utility function for sorting string lexically in qsort.
Definition: Bstring.cpp:828
Bstring::rfind
long rfind(const Bstring &s)
Definition: Bstring.h:105
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bstring::truncate
Bstring truncate(const long n)
Definition: Bstring.cpp:495
Bstring::remove
Bstring remove(const char c)
Definition: Bstring.cpp:465
QsortSmallToLargeStringValue
int QsortSmallToLargeStringValue(const void *x, const void *y)
Utility function for sorting string values in qsort.
Definition: Bstring.cpp:842
string_catenate
Bstring string_catenate(Bstring *list)
Catenates a string linked list into one string.
Definition: Bstring.cpp:739
Bstring::operator+=
Bstring & operator+=(const Bstring &s)
Definition: Bstring.cpp:149
Bstring::replace
Bstring replace(char cold, char cnew)
Definition: Bstring.cpp:457
QsortSmallToLargeString
int QsortSmallToLargeString(const void *x, const void *y)
Utility function for sorting string lexically in qsort.
Definition: Bstring.cpp:814
operator<<
ostream & operator<<(ostream &output, Bstring &s)
Definition: Bstring.cpp:694
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
Bstring::no_space
Bstring no_space()
Definition: Bstring.cpp:332
QsortLargeToSmallStringValue
int QsortLargeToSmallStringValue(const void *x, const void *y)
Utility function for sorting string values in qsort.
Definition: Bstring.cpp:856
Bstring::next
Bstring * next
Definition: Bstring.h:31
Bstring::pre
Bstring pre(char c)
Definition: Bstring.cpp:381
Bstring::operator<<
Bstring operator<<(int n)
Definition: Bstring.cpp:233
Bstring::erase
Bstring erase(const long i)
Definition: Bstring.cpp:485
Bstring::extension
Bstring extension()
Definition: Bstring.cpp:515
Bstring::swap
Bstring swap(const long i, const long j)
Definition: Bstring.cpp:477
Bstring::operator>
bool operator>(const Bstring &s)
Definition: Bstring.cpp:213
Bstring::operator!=
bool operator!=(const Bstring &s)
Definition: Bstring.cpp:208
Bstring::insert
Bstring insert(long pos, const Bstring &s)
Definition: Bstring.cpp:590
Bstring::upper
Bstring upper()
Definition: Bstring.cpp:316
Bstring::operator=
Bstring & operator=(const Bstring &s)
Definition: Bstring.cpp:108
Bstring::fill
void fill(const char c)
Definition: Bstring.cpp:296
Bstring::canonical
Bstring canonical(int n)
Definition: Bstring.cpp:527
Bstring::compare
long compare(const Bstring &s)
Definition: Bstring.cpp:277
Bstring::split_into_doubles
vector< double > split_into_doubles(const Bstring &delim)
Definition: Bstring.cpp:665
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bstring::compare_value
long compare_value(const Bstring &s)
Definition: Bstring.cpp:285
Bstring::operator>=
bool operator>=(const Bstring &s)
Definition: Bstring.cpp:223
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bstring::no_lead_space
Bstring no_lead_space()
Definition: Bstring.cpp:341
Bstring::Bstring
Bstring()
Definition: Bstring.h:35
Bstring::base
Bstring base()
Definition: Bstring.cpp:508
Bstring::operator<=
bool operator<=(const Bstring &s)
Definition: Bstring.cpp:228
operator+
Bstring operator+(const char *c, const Bstring &s)
Definition: Bstring.cpp:681
Bstring
Definition: Bstring.h:29
Bstring::operator<
bool operator<(const Bstring &s)
Definition: Bstring.cpp:218
Bstring::operator==
bool operator==(const Bstring &s)
Definition: Bstring.cpp:203
Bstring::count
long count(const char c)
Definition: Bstring.cpp:269
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
Bstring::operator>>
Bstring operator>>(int n)
Definition: Bstring.cpp:240
Bstring::lower
Bstring lower()
Definition: Bstring.cpp:308
Bstring.h
Header file for the string class.
Bstring::split_into_integers
vector< long > split_into_integers(const Bstring &delim)
Definition: Bstring.cpp:649
Bstring::integer
long integer()
Definition: Bstring.cpp:539
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760
Bstring::within
Bstring within(char c1, char c2)
Definition: Bstring.cpp:442
parameter_file_path
Bstring parameter_file_path(Bstring filename)
Finds the parameter file path.
Definition: Bstring.cpp:787
Bstring::place
void place(long i, const Bstring &s)
Definition: Bstring.cpp:302
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
Bstring::index
long index(const char c)
Definition: Bstring.h:101
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
Bstring::operator[]
char & operator[](long i)
Definition: Bstring.cpp:247
Bstring::split
Bstring * split()
Definition: Bstring.cpp:597
Bstring::right
Bstring right(long len)
Definition: Bstring.cpp:367