Ignore:
Timestamp:
Mar 21, 2022, 1:44:06 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/string_res.hfa

    ref3c383 rd672350  
    1717
    1818#include <fstream.hfa>
     19#include <string.h>    // e.g. strlen
    1920
    2021   
     
    2728    HandleNode *flink;                                  // forward link
    2829    HandleNode *blink;                                  // backward link
     30    VbyteHeap *ulink;                   // upward link
    2931
    3032    char *s;                                            // pointer to byte string
     
    3234}; // HandleNode
    3335
    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;
     36VbyteHeap * DEBUG_string_heap();
     37size_t DEBUG_string_bytes_in_heap( VbyteHeap * heap );
    4038size_t DEBUG_string_bytes_avail_until_gc( VbyteHeap * heap );
    4139const char * DEBUG_string_heap_start( VbyteHeap * heap );
    4240
     41void TUNING_set_string_heap_liveness_threshold( double val );
    4342
    4443//######################### String #########################
     
    4746struct string_res {
    4847    HandleNode Handle; // chars, start, end, global neighbours
     48    bool shareEditSet_owns_ulink;
    4949    string_res * shareEditSet_prev;
    5050    string_res * shareEditSet_next;
     
    7474// Constructors, Assignment Operators, Destructor
    7575void ?{}(string_res &s); // empty string
    76 void ?{}(string_res &s, const char* initial); // copy from string literal (NULL-terminated)
    7776void ?{}(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
     77static inline void ?{}(string_res &s, const char* rhs) { // copy from string literal (NULL-terminated)
     78    (s){ rhs, strlen(rhs) };
     79}
    7880
    7981void ?{}(string_res &s, const string_res & s2) = void;
     
    8688}
    8789
    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);
     90string_res & assign(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
     91static inline string_res & ?=?(string_res &s, const char* other) {  // copy from string literal (NULL-terminated)
     92    return assign(s, other, strlen(other));
     93}
     94string_res & ?=?(string_res &s, const string_res &other);
     95string_res & ?=?(string_res &s, string_res &other);
     96string_res & ?=?(string_res &s, char other);
    9397
    9498void ^?{}(string_res &s);
     
    99103
    100104// Concatenation
     105void append(string_res &s, const char* buffer, size_t bsize);
    101106void ?+=?(string_res &s, char other); // append a character
    102107void ?+=?(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);
     108static inline void ?+=?(string_res &s, const char* other) {
     109    append( s, other, strlen(other) );
     110}
    105111
    106112// Character access
     113void assignAt(const string_res &s, size_t index, char val);
    107114char ?[?](const string_res &s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's
    108115//char codePointAt(const string_res &s, size_t index); // revisit under Unicode
     
    121128int find(const string_res &s, const char* search);
    122129int find(const string_res &s, const char* search, size_t searchsize);
     130
     131int findFrom(const string_res &s, size_t fromPos, char search);
     132int findFrom(const string_res &s, size_t fromPos, const string_res &search);
     133int findFrom(const string_res &s, size_t fromPos, const char* search);
     134int findFrom(const string_res &s, size_t fromPos, const char* search, size_t searchsize);
    123135
    124136bool includes(const string_res &s, const string_res &search);
Note: See TracChangeset for help on using the changeset viewer.