Changeset f988834 for libcfa/src/collections/string.hfa
- Timestamp:
- Jan 19, 2024, 2:44:41 AM (10 months ago)
- Branches:
- master
- Children:
- ac939461
- Parents:
- 59c8dff (diff), e8b3717 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.hfa
r59c8dff rf988834 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Sep 2 11:26:28 202313 // Update Count : 5512 // Last Modified On : Sun Jan 14 12:03:46 2024 13 // Update Count : 81 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 string 34 void ?{}(string & s, const char * initial); // copy from string literal (NULL-terminated) 35 void ?{}(string & s, const char * buffer, size_t bsize); // copy specific length from buffer 36 34 void ?{}(string & s); // empty string 37 35 void ?{}(string & s, const string & s2); 36 void ?{}(string & s, const string & s2, size_t maxlen); 38 37 void ?{}(string & s, string & s2); 39 38 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 39 void ?{}(string & s, char); 40 void ?{}(string & s, const char * c); // copy from string literal (NULL-terminated) 41 void ?{}(string & s, const char * c, size_t size); // copy specific length from buffer 42 43 void ?=?(string & s, const char * c); // copy assignment from literal 44 void ?=?(string & s, const string & c); 45 void ?=?(string & s, char c); 46 string & ?=?(string & s, string & c); // surprising ret seems to help avoid calls to autogen 47 void assign(string & s, const string & c, size_t n); 48 void assign(string & s, const char * c, size_t n); 44 49 //string ?=?( string &, string ) = void; 50 51 static inline string & strcpy(string & s, const char * c) { s = c; return s; } 52 static inline string & strncpy(string & s, const char * c, size_t n) { assign( s, c, n); return s; } 53 static inline string & strcpy(string & s, const string & c) { s = c; return s; } 54 static inline string & strncpy(string & s, const string & c, size_t n) { assign(s, c, n); return s; } 55 45 56 void ^?{}(string & s); 46 57 … … 49 60 string * s; 50 61 }; 51 string_WithSharedEdits ?`shareEdits( string & this );52 void ?{}( string & this, string_WithSharedEdits src );62 string_WithSharedEdits ?`shareEdits( string & s ); 63 void ?{}( string & s, string_WithSharedEdits src ); 53 64 54 65 // IO Operator … … 56 67 void ?|?(ofstream & out, const string & s); 57 68 ifstream & ?|?(ifstream & in, string & s); 58 void ?|?( ifstream & in, string & this );69 void ?|?( ifstream & in, string & s ); 59 70 60 71 static inline { … … 81 92 _Istream_Sstr wdi( unsigned int rwd, string & s ) { return (_Istream_Sstr)@{ s, {{0p}, rwd, {.flags.rwd : true}} }; } 82 93 _Istream_Sstr getline( string & s, const char delimiter = '\n' ) { 83 return (_Istream_Sstr)@{ s, {{.delimiter : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} };94 return (_Istream_Sstr)@{ s, {{.delimiters : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} }; 84 95 } 85 96 _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;97 fmt.delimiters[0] = delimiter; fmt.delimiters[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt; 87 98 } 88 99 _Istream_Sstr incl( const char scanset[], string & s ) { return (_Istream_Sstr)@{ s, {{scanset}, -1, {.flags.inex : false}} }; } … … 97 108 98 109 // Concatenation 99 void ?+=?(string & s, char other); // append a character110 void ?+=?(string & s, char c); // append a character 100 111 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 112 void append(string & s, const string & s2, size_t maxlen); // append-concatenate to first string, up to maxlen 113 void ?+=?(string & s, const char * s2); // append-concatenate NULL-terminated string to first string 114 void append(string & s, const char * buffer, size_t bsize); // append-concatenate given range to first string 115 116 string ?+?(const string & s, char c); // add a character to a copy of the string 103 117 string ?+?(const string & s, const string & s2); // copy and concatenate both strings 104 string ?+?(const char * s1, const char * s2); // concatenate both strings 105 string ?+?(const string & s, const char * other); // copy and concatenate with NULL-terminated string 118 string ?+?(const char * s1, const char * s2); // copy and concatenate both strings 119 string ?+?(const string & s, const char * c); // copy and concatenate with NULL-terminated string 120 121 static inline string & strcat(string & s, const string & s2) { s += s2; return s; } 122 static inline string & strcat(string & s, const char * c) { s += c; return s; } 123 static inline string & strncat(string & s, const string & s2, size_t maxlen) { append(s, s2, maxlen); return s; } 124 static inline string & strncat(string & s, const char * buffer, size_t bsize) { append(s, buffer, bsize); return s; } 106 125 107 126 // Repetition 108 127 string ?*?(const string & s, size_t factor); 109 string ?*?(char c, size_t size); 110 string ?*?(const char *s, size_t size); 128 void ?*=?(string & s, size_t factor); 129 string ?*?(char c, size_t factor); 130 string ?*?(const char *s, size_t factor); 111 131 112 132 // Character access … … 116 136 117 137 // Comparisons 118 int cmp (const string &, const string &);138 int strcmp (const string &, const string &); 119 139 bool ?==?(const string &, const string &); 120 140 bool ?!=?(const string &, const string &); … … 124 144 bool ?<? (const string &, const string &); 125 145 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 &);146 int strcmp (const string &, const char *); 147 bool ?==?(const string &, const char *); 148 bool ?!=?(const string &, const char *); 149 bool ?>? (const string &, const char *); 150 bool ?>=?(const string &, const char *); 151 bool ?<=?(const string &, const char *); 152 bool ?<? (const string &, const char *); 153 154 int strcmp (const char *, const string &); 155 bool ?==?(const char *, const string &); 156 bool ?!=?(const char *, const string &); 157 bool ?>? (const char *, const string &); 158 bool ?>=?(const char *, const string &); 159 bool ?<=?(const char *, const string &); 160 bool ?<? (const char *, const string &); 141 161 142 162 143 163 // Slicing 144 string ?()( string & this, size_t start, size_t end); // TODO const?145 string ?()( string & this, size_t start);164 string ?()( string & s, size_t start, size_t len ); // TODO const? 165 string ?()( string & s, size_t start); 146 166 147 167 // String search … … 177 197 178 198 179 180 199 struct charclass { 181 200 charclass_res * inner;
Note: See TracChangeset
for help on using the changeset viewer.