Ignore:
File:
1 edited

Legend:

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

    r6cc87c0 r1733184  
    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 );
     
    4745struct string_res {
    4846    HandleNode Handle; // chars, start, end, global neighbours
     47    bool shareEditSet_owns_ulink;
    4948    string_res * shareEditSet_prev;
    5049    string_res * shareEditSet_next;
     
    7473// Constructors, Assignment Operators, Destructor
    7574void ?{}(string_res &s); // empty string
    76 void ?{}(string_res &s, const char* initial); // copy from string literal (NULL-terminated)
    7775void ?{}(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
     76static inline void ?{}(string_res &s, const char* rhs) { // copy from string literal (NULL-terminated)
     77    (s){ rhs, strlen(rhs) };
     78}
    7879
    7980void ?{}(string_res &s, const string_res & s2) = void;
     
    8687}
    8788
    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);
     89string_res & assign(string_res &s, const char* buffer, size_t bsize); // copy specific length from buffer
     90static inline string_res & ?=?(string_res &s, const char* other) {  // copy from string literal (NULL-terminated)
     91    return assign(s, other, strlen(other));
     92}
     93string_res & ?=?(string_res &s, const string_res &other);
     94string_res & ?=?(string_res &s, string_res &other);
     95string_res & ?=?(string_res &s, char other);
    9396
    9497void ^?{}(string_res &s);
     
    99102
    100103// Concatenation
     104void append(string_res &s, const char* buffer, size_t bsize);
    101105void ?+=?(string_res &s, char other); // append a character
    102106void ?+=?(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);
     107static inline void ?+=?(string_res &s, const char* other) {
     108    append( s, other, strlen(other) );
     109}
    105110
    106111// Character access
     112void assignAt(const string_res &s, size_t index, char val);
    107113char ?[?](const string_res &s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's
    108114//char codePointAt(const string_res &s, size_t index); // revisit under Unicode
Note: See TracChangeset for help on using the changeset viewer.