Changeset f988834 for libcfa/src/collections/string_res.hfa
- Timestamp:
- Jan 19, 2024, 2:44:41 AM (8 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_res.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 : Sat Aug 12 15:45:47 202313 // Update Count : 2 12 // Last Modified On : Thu Jan 4 11:28:06 2024 13 // Update Count : 27 14 14 // 15 15 … … 70 70 71 71 // Getters 72 size_t size(const string_res & s);72 size_t size(const string_res & s); 73 73 74 74 // Constructors, Assignment Operators, Destructor 75 void ?{}(string_res & s); // empty string76 void ?{}(string_res & s, const char* buffer, size_t bsize); // copy specific length from buffer77 static inline void ?{}(string_res & s, const char* rhs) { // copy from string literal (NULL-terminated)75 void ?{}(string_res & s); // empty string 76 void ?{}(string_res & s, const char * buffer, size_t bsize); // copy specific length from buffer 77 static inline void ?{}(string_res & s, const char * rhs) { // copy from string literal (NULL-terminated) 78 78 (s){ rhs, strlen(rhs) }; 79 79 } 80 81 void ?{}(string_res &s, const string_res & s2) = void; 82 void ?{}(string_res &s, string_res & s2) = void; 80 static inline void ?{}(string_res & s, char c ) { 81 ?{}( s, &c, 1); 82 } 83 84 // Deleting the copy constructors makes the compiler reject an attempt to call/return by value 85 void ?{}(string_res & s, const string_res & s2) = void; 86 void ?{}(string_res & s, string_res & s2) = void; 83 87 84 88 enum StrResInitMode { COPY_VALUE, SHARE_EDITS }; 85 void ?{}(string_res & s, const string_res & src, StrResInitMode, size_t start, size_t end);86 static inline void ?{}(string_res & s, const string_res & src, StrResInitMode mode ) {89 void ?{}(string_res & s, const string_res & src, StrResInitMode, size_t start, size_t len ); 90 static inline void ?{}(string_res & s, const string_res & src, StrResInitMode mode ) { 87 91 ?{}( s, src, mode, 0, size(src)); 88 92 } 89 90 string_res & assign(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer 91 static inline string_res & ?=?(string_res &s, const char* other) { // copy from string literal (NULL-terminated) 92 return assign(s, other, strlen(other)); 93 } 94 string_res & ?=?(string_res &s, const string_res &other); 95 string_res & ?=?(string_res &s, string_res &other); 96 string_res & ?=?(string_res &s, char other); 97 98 void ^?{}(string_res &s); 93 static inline void ?{}(string_res & s, const string_res & src, StrResInitMode mode, size_t maxlen ) { 94 ?{}( s, src, mode, 0, (size(src) > maxlen)?maxlen:size(src) ); 95 } 96 97 string_res & assign(string_res & s, const string_res & src, size_t maxlen); // copy specific length from other string 98 string_res & assign(string_res & s, const char * buffer, size_t bsize); // copy specific length from buffer 99 static inline string_res & ?=?(string_res & s, const char * c) { // copy from string literal (NULL-terminated) 100 return assign(s, c, strlen(c)); 101 } 102 string_res & ?=?(string_res & s, const string_res & c); 103 string_res & ?=?(string_res & s, string_res & c); 104 string_res & ?=?(string_res & s, char c); 105 106 void ^?{}(string_res & s); 99 107 100 108 // IO Operator 101 ofstream & ?|?(ofstream & out, const string_res &s);102 void ?|?(ofstream & out, const string_res &s);103 ifstream & ?|?(ifstream & in, string_res &s);104 void ?|?( ifstream & in, string_res & this );109 ofstream & ?|?(ofstream & out, const string_res & s); 110 void ?|?(ofstream & out, const string_res & s); 111 ifstream & ?|?(ifstream & in, string_res & s); 112 void ?|?( ifstream & in, string_res & s ); 105 113 106 114 struct _Istream_Rstr { … … 113 121 _Istream_Rstr wdi( unsigned int rwd, string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, rwd, {.flags.rwd : true}} }; } 114 122 _Istream_Rstr getline( string_res & s, const char delimiter = '\n' ) { 115 return (_Istream_Rstr)@{ &s, {{.delimiter : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} };123 return (_Istream_Rstr)@{ &s, {{.delimiters : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} }; 116 124 } 117 125 _Istream_Rstr & getline( _Istream_Rstr & fmt, const char delimiter = '\n' ) { 118 fmt.delimiter [0] = delimiter; fmt.delimiter[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt;126 fmt.delimiters[0] = delimiter; fmt.delimiters[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt; 119 127 } 120 128 _Istream_Rstr incl( const char scanset[], string_res & s ) { return (_Istream_Rstr)@{ &s, {{scanset}, -1, {.flags.inex : false}} }; } … … 129 137 130 138 // Concatenation 131 void append(string_res &s, const char* buffer, size_t bsize); 132 void ?+=?(string_res &s, char other); // append a character 133 void ?+=?(string_res &s, const string_res &s2); // append-concatenate to first string 134 static inline void ?+=?(string_res &s, const char* other) { 135 append( s, other, strlen(other) ); 136 } 139 void ?+=?(string_res & s, const string_res & s2); 140 void ?+=?(string_res & s, char c); 141 void append(string_res & s, const string_res & s2, size_t maxlen); 142 void ?+=?(string_res & s, const char * c); 143 void append(string_res & s, const char * buffer, size_t bsize); 144 145 static inline string_res & strcat(string_res & s, const string_res & s2) { s += s2; return s; } 146 static inline string_res & strcat(string_res & s, const char * c) { s += c; return s; } 147 static inline string_res & strncat(string_res & s, const string_res & s2, size_t maxlen) { append(s, s2, maxlen); return s; } 148 static inline string_res & strncat(string_res & s, const char * buffer, size_t bsize) { append(s, buffer, bsize); return s; } 149 150 // Repetition 151 void ?*=?(string_res & s, size_t factor); 137 152 138 153 // Character access 139 void assignAt(const string_res & s, size_t index, char val);140 char ?[?](const string_res & s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's141 //char codePointAt(const string_res & s, size_t index); // revisit under Unicode154 void assignAt(const string_res & s, size_t index, char val); 155 char ?[?](const string_res & s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's 156 //char codePointAt(const string_res & s, size_t index); // revisit under Unicode 142 157 143 158 // Comparisons 144 int cmp (const string_res &, const string_res &);159 int strcmp (const string_res &, const string_res &); 145 160 bool ?==?(const string_res &, const string_res &); 146 161 bool ?!=?(const string_res &, const string_res &); … … 150 165 bool ?<? (const string_res &, const string_res &); 151 166 152 int cmp (const string_res &, const char*);153 bool ?==?(const string_res &, const char *);154 bool ?!=?(const string_res &, const char *);155 bool ?>? (const string_res &, const char *);156 bool ?>=?(const string_res &, const char *);157 bool ?<=?(const string_res &, const char *);158 bool ?<? (const string_res &, const char *);159 160 int cmp (const char*, const string_res &);161 bool ?==?(const char *, const string_res &);162 bool ?!=?(const char *, const string_res &);163 bool ?>? (const char *, const string_res &);164 bool ?>=?(const char *, const string_res &);165 bool ?<=?(const char *, const string_res &);166 bool ?<? (const char *, const string_res &);167 int strcmp(const string_res &, const char *); 168 bool ?==?(const string_res &, const char *); 169 bool ?!=?(const string_res &, const char *); 170 bool ?>? (const string_res &, const char *); 171 bool ?>=?(const string_res &, const char *); 172 bool ?<=?(const string_res &, const char *); 173 bool ?<? (const string_res &, const char *); 174 175 int strcmp(const char *, const string_res &); 176 bool ?==?(const char *, const string_res &); 177 bool ?!=?(const char *, const string_res &); 178 bool ?>? (const char *, const string_res &); 179 bool ?>=?(const char *, const string_res &); 180 bool ?<=?(const char *, const string_res &); 181 bool ?<? (const char *, const string_res &); 167 182 168 183 // String search 169 bool contains(const string_res & s, char ch); // single character170 171 int find(const string_res & s, char search);172 int find(const string_res & s, const string_res &search);173 int find(const string_res & s, const char* search);174 int find(const string_res & s, const char* search, size_t searchsize);175 176 int findFrom(const string_res & s, size_t fromPos, char search);177 int findFrom(const string_res & s, size_t fromPos, const string_res &search);178 int findFrom(const string_res & s, size_t fromPos, const char* search);179 int findFrom(const string_res & s, size_t fromPos, const char* search, size_t searchsize);180 181 bool includes(const string_res & s, const string_res &search);182 bool includes(const string_res & s, const char* search);183 bool includes(const string_res & s, const char* search, size_t searchsize);184 185 bool startsWith(const string_res & s, const string_res &prefix);186 bool startsWith(const string_res & s, const char* prefix);187 bool startsWith(const string_res & s, const char* prefix, size_t prefixsize);188 189 bool endsWith(const string_res & s, const string_res &suffix);190 bool endsWith(const string_res & s, const char* suffix);191 bool endsWith(const string_res & s, const char* suffix, size_t suffixsize);192 193 int include(const string_res & s, const charclass_res &mask);194 int exclude(const string_res & s, const charclass_res &mask);184 bool contains(const string_res & s, char ch); // single character 185 186 int find(const string_res & s, char search); 187 int find(const string_res & s, const string_res & search); 188 int find(const string_res & s, const char * search); 189 int find(const string_res & s, const char * search, size_t searchsize); 190 191 int findFrom(const string_res & s, size_t fromPos, char search); 192 int findFrom(const string_res & s, size_t fromPos, const string_res & search); 193 int findFrom(const string_res & s, size_t fromPos, const char * search); 194 int findFrom(const string_res & s, size_t fromPos, const char * search, size_t searchsize); 195 196 bool includes(const string_res & s, const string_res & search); 197 bool includes(const string_res & s, const char * search); 198 bool includes(const string_res & s, const char * search, size_t searchsize); 199 200 bool startsWith(const string_res & s, const string_res & prefix); 201 bool startsWith(const string_res & s, const char * prefix); 202 bool startsWith(const string_res & s, const char * prefix, size_t prefixsize); 203 204 bool endsWith(const string_res & s, const string_res & suffix); 205 bool endsWith(const string_res & s, const char * suffix); 206 bool endsWith(const string_res & s, const char * suffix, size_t suffixsize); 207 208 int include(const string_res & s, const charclass_res & mask); 209 int exclude(const string_res & s, const charclass_res & mask); 195 210 196 211 // Modifiers 197 void padStart(string_res & s, size_t n);198 void padStart(string_res & s, size_t n, char padding);199 void padEnd(string_res & s, size_t n);212 void padStart(string_res & s, size_t n); 213 void padStart(string_res & s, size_t n, char padding); 214 void padEnd(string_res & s, size_t n); 200 215 void padEnd(string_res &s, size_t n, char padding); 201 216
Note: See TracChangeset
for help on using the changeset viewer.