Changeset 681e12f for libcfa/src/collections/string.hfa
- Timestamp:
- Jan 4, 2024, 11:58:49 AM (8 months ago)
- Branches:
- master
- Children:
- be10079
- Parents:
- 8b4faf6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.hfa
r8b4faf6 r681e12f 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 2 11:26:28 202313 // Update Count : 5512 // Last Modified On : Thu Jan 4 11:27:35 2024 13 // Update Count : 75 14 14 // 15 15 … … 29 29 // Getters 30 30 size_t size(const string & s); 31 static inline size_t strlen(const string & s) { return size( s ); } 31 32 32 33 // RAII, assignment 33 void ?{}(string & this); // empty string34 void ?{}(string & s); // empty string 34 35 void ?{}(string & s, const char * initial); // copy from string literal (NULL-terminated) 35 36 void ?{}(string & s, const char * buffer, size_t bsize); // copy specific length from buffer … … 38 39 void ?{}(string & s, string & s2); 39 40 40 void ?=?(string & s, const char * other); // copy assignment from literal 41 void ?=?(string & s, const string & other); 42 void ?=?(string & s, char other); 43 string & ?=?(string & s, string & other); // surprising ret seems to help avoid calls to autogen 41 void ?=?(string & s, const char * c); // copy assignment from literal 42 static inline string & strcpy(string & s, const char * c) { s = c; return s; } 43 void ?=?(string & s, const string & c); 44 static inline string & strcpy(string & s, const string c) { s = c; return s; } 45 void ?=?(string & s, char c); 46 string & ?=?(string & s, string & c); // surprising ret seems to help avoid calls to autogen 44 47 //string ?=?( string &, string ) = void; 45 48 void ^?{}(string & s); … … 49 52 string * s; 50 53 }; 51 string_WithSharedEdits ?`shareEdits( string & this );52 void ?{}( string & this, string_WithSharedEdits src );54 string_WithSharedEdits ?`shareEdits( string & s ); 55 void ?{}( string & s, string_WithSharedEdits src ); 53 56 54 57 // IO Operator … … 56 59 void ?|?(ofstream & out, const string & s); 57 60 ifstream & ?|?(ifstream & in, string & s); 58 void ?|?( ifstream & in, string & this );61 void ?|?( ifstream & in, string & s ); 59 62 60 63 static inline { … … 81 84 _Istream_Sstr wdi( unsigned int rwd, string & s ) { return (_Istream_Sstr)@{ s, {{0p}, rwd, {.flags.rwd : true}} }; } 82 85 _Istream_Sstr getline( string & s, const char delimiter = '\n' ) { 83 return (_Istream_Sstr)@{ s, {{.delimiter : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} };86 return (_Istream_Sstr)@{ s, {{.delimiters : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} }; 84 87 } 85 88 _Istream_Sstr & getline( _Istream_Sstr & fmt, const char delimiter = '\n' ) { 86 fmt.delimiter [0] = delimiter; fmt.delimiter[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt;89 fmt.delimiters[0] = delimiter; fmt.delimiters[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt; 87 90 } 88 91 _Istream_Sstr incl( const char scanset[], string & s ) { return (_Istream_Sstr)@{ s, {{scanset}, -1, {.flags.inex : false}} }; } … … 97 100 98 101 // Concatenation 99 void ?+=?(string & s, char other); // append a character102 void ?+=?(string & s, char c); // append a character 100 103 void ?+=?(string & s, const string & s2); // append-concatenate to first string 101 void ?+=?(string & s, const char * other); // append-concatenate to first string 102 string ?+?(const string & s, char other); // add a character to a copy of the string 104 static inline string & strcat(string & s, const string & s2) { s += s2; return s; } 105 void ?+=?(string & s, const char * s2); // append-concatenate to first string 106 static inline string & strcat(string & s, const char * c) { s += c; return s; } 107 string ?+?(const string & s, char c); // add a character to a copy of the string 103 108 string ?+?(const string & s, const string & s2); // copy and concatenate both strings 104 109 string ?+?(const char * s1, const char * s2); // concatenate both strings 105 string ?+?(const string & s, const char * other); // copy and concatenate with NULL-terminated string110 string ?+?(const string & s, const char * c); // copy and concatenate with NULL-terminated string 106 111 107 112 // Repetition … … 116 121 117 122 // Comparisons 118 int cmp (const string &, const string &);123 int strcmp (const string &, const string &); 119 124 bool ?==?(const string &, const string &); 120 125 bool ?!=?(const string &, const string &); … … 124 129 bool ?<? (const string &, const string &); 125 130 126 int cmp (const string &, const char*);127 bool ?==?(const string &, const char *);128 bool ?!=?(const string &, const char *);129 bool ?>? (const string &, const char *);130 bool ?>=?(const string &, const char *);131 bool ?<=?(const string &, const char *);132 bool ?<? (const string &, const char *);133 134 int cmp (const char*, const string &);135 bool ?==?(const char *, const string &);136 bool ?!=?(const char *, const string &);137 bool ?>? (const char *, const string &);138 bool ?>=?(const char *, const string &);139 bool ?<=?(const char *, const string &);140 bool ?<? (const char *, const string &);131 int strcmp (const string &, const char *); 132 bool ?==?(const string &, const char *); 133 bool ?!=?(const string &, const char *); 134 bool ?>? (const string &, const char *); 135 bool ?>=?(const string &, const char *); 136 bool ?<=?(const string &, const char *); 137 bool ?<? (const string &, const char *); 138 139 int strcmp (const char *, const string &); 140 bool ?==?(const char *, const string &); 141 bool ?!=?(const char *, const string &); 142 bool ?>? (const char *, const string &); 143 bool ?>=?(const char *, const string &); 144 bool ?<=?(const char *, const string &); 145 bool ?<? (const char *, const string &); 141 146 142 147 143 148 // Slicing 144 string ?()( string & this, size_t start, size_t end ); // TODO const?145 string ?()( string & this, size_t start);149 string ?()( string & s, size_t start, size_t end ); // TODO const? 150 string ?()( string & s, size_t start); 146 151 147 152 // String search … … 177 182 178 183 179 180 184 struct charclass { 181 185 charclass_res * inner;
Note: See TracChangeset
for help on using the changeset viewer.