Changeset d672350 for libcfa/src/containers/string_res.hfa
- Timestamp:
- Mar 21, 2022, 1:44:06 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- a76202d
- Parents:
- ef3c383 (diff), dbe2533 (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/containers/string_res.hfa
ref3c383 rd672350 17 17 18 18 #include <fstream.hfa> 19 #include <string.h> // e.g. strlen 19 20 20 21 … … 27 28 HandleNode *flink; // forward link 28 29 HandleNode *blink; // backward link 30 VbyteHeap *ulink; // upward link 29 31 30 32 char *s; // pointer to byte string … … 32 34 }; // HandleNode 33 35 34 void ?{}( HandleNode & ); // constructor for header node 35 36 void ?{}( HandleNode &, VbyteHeap & ); // constructor for nodes in the handle list 37 void ^?{}( HandleNode & ); // destructor for handle nodes 38 39 extern VbyteHeap * DEBUG_string_heap; 36 VbyteHeap * DEBUG_string_heap(); 37 size_t DEBUG_string_bytes_in_heap( VbyteHeap * heap ); 40 38 size_t DEBUG_string_bytes_avail_until_gc( VbyteHeap * heap ); 41 39 const char * DEBUG_string_heap_start( VbyteHeap * heap ); 42 40 41 void TUNING_set_string_heap_liveness_threshold( double val ); 43 42 44 43 //######################### String ######################### … … 47 46 struct string_res { 48 47 HandleNode Handle; // chars, start, end, global neighbours 48 bool shareEditSet_owns_ulink; 49 49 string_res * shareEditSet_prev; 50 50 string_res * shareEditSet_next; … … 74 74 // Constructors, Assignment Operators, Destructor 75 75 void ?{}(string_res &s); // empty string 76 void ?{}(string_res &s, const char* initial); // copy from string literal (NULL-terminated)77 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 (s){ rhs, strlen(rhs) }; 79 } 78 80 79 81 void ?{}(string_res &s, const string_res & s2) = void; … … 86 88 } 87 89 88 void assign(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer 89 void ?=?(string_res &s, const char* other); // copy from string literal (NULL-terminated) 90 void ?=?(string_res &s, const string_res &other); 91 void ?=?(string_res &s, string_res &other); 92 void ?=?(string_res &s, char other); 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); 93 97 94 98 void ^?{}(string_res &s); … … 99 103 100 104 // Concatenation 105 void append(string_res &s, const char* buffer, size_t bsize); 101 106 void ?+=?(string_res &s, char other); // append a character 102 107 void ?+=?(string_res &s, const string_res &s2); // append-concatenate to first string 103 void ?+=?(string_res &s, const char* other); 104 void append(string_res &s, const char* buffer, size_t bsize); 108 static inline void ?+=?(string_res &s, const char* other) { 109 append( s, other, strlen(other) ); 110 } 105 111 106 112 // Character access 113 void assignAt(const string_res &s, size_t index, char val); 107 114 char ?[?](const string_res &s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's 108 115 //char codePointAt(const string_res &s, size_t index); // revisit under Unicode … … 121 128 int find(const string_res &s, const char* search); 122 129 int find(const string_res &s, const char* search, size_t searchsize); 130 131 int findFrom(const string_res &s, size_t fromPos, char search); 132 int findFrom(const string_res &s, size_t fromPos, const string_res &search); 133 int findFrom(const string_res &s, size_t fromPos, const char* search); 134 int findFrom(const string_res &s, size_t fromPos, const char* search, size_t searchsize); 123 135 124 136 bool includes(const string_res &s, const string_res &search);
Note:
See TracChangeset
for help on using the changeset viewer.