Ignore:
Timestamp:
Jan 19, 2024, 2:44:41 AM (10 months ago)
Author:
JiadaL <j82liang@…>
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.
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string.hfa

    r59c8dff rf988834  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep  2 11:26:28 2023
    13 // Update Count     : 55
     12// Last Modified On : Sun Jan 14 12:03:46 2024
     13// Update Count     : 81
    1414//
    1515
     
    2929// Getters
    3030size_t size(const string & s);
     31static inline size_t strlen(const string & s) { return size( s ); }
    3132
    3233// 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 
     34void ?{}(string & s); // empty string
    3735void ?{}(string & s, const string & s2);
     36void ?{}(string & s, const string & s2, size_t maxlen);
    3837void ?{}(string & s, string & s2);
    3938
    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
     39void ?{}(string & s, char);
     40void ?{}(string & s, const char * c); // copy from string literal (NULL-terminated)
     41void ?{}(string & s, const char * c, size_t size); // copy specific length from buffer
     42
     43void ?=?(string & s, const char * c); // copy assignment from literal
     44void ?=?(string & s, const string & c);
     45void ?=?(string & s, char c);
     46string & ?=?(string & s, string & c);  // surprising ret seems to help avoid calls to autogen
     47void assign(string & s, const string & c, size_t n);
     48void assign(string & s, const char * c, size_t n);
    4449//string ?=?( string &, string ) = void;
     50
     51static inline string & strcpy(string & s, const char * c) { s = c; return s; }
     52static inline string & strncpy(string & s, const char * c, size_t n) { assign( s, c, n); return s; }
     53static inline string & strcpy(string & s, const string & c) { s = c; return s; }
     54static inline string & strncpy(string & s, const string & c, size_t n) { assign(s, c, n); return s; }
     55
    4556void ^?{}(string & s);
    4657
     
    4960    string * s;
    5061};
    51 string_WithSharedEdits ?`shareEdits( string & this );
    52 void ?{}( string & this, string_WithSharedEdits src );
     62string_WithSharedEdits ?`shareEdits( string & s );
     63void ?{}( string & s, string_WithSharedEdits src );
    5364
    5465// IO Operator
     
    5667void ?|?(ofstream & out, const string & s);
    5768ifstream & ?|?(ifstream & in, string & s);
    58 void ?|?( ifstream & in, string & this );
     69void ?|?( ifstream & in, string & s );
    5970
    6071static inline {
     
    8192        _Istream_Sstr wdi( unsigned int rwd, string & s ) { return (_Istream_Sstr)@{ s, {{0p}, rwd, {.flags.rwd : true}} }; }
    8293        _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}} };
    8495        }
    8596        _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;
    8798        }
    8899        _Istream_Sstr incl( const char scanset[], string & s ) { return (_Istream_Sstr)@{ s, {{scanset}, -1, {.flags.inex : false}} }; }
     
    97108
    98109// Concatenation
    99 void ?+=?(string & s, char other); // append a character
     110void ?+=?(string & s, char c); // append a character
    100111void ?+=?(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
     112void append(string & s, const string & s2, size_t maxlen);  // append-concatenate to first string, up to maxlen
     113void ?+=?(string & s, const char * s2); // append-concatenate NULL-terminated string to first string
     114void append(string & s, const char * buffer, size_t bsize);  // append-concatenate given range to first string
     115
     116string ?+?(const string & s, char c); // add a character to a copy of the string
    103117string ?+?(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
     118string ?+?(const char * s1, const char * s2); // copy and concatenate both strings
     119string ?+?(const string & s, const char * c); // copy and concatenate with NULL-terminated string
     120
     121static inline string & strcat(string & s, const string & s2) { s += s2; return s; }
     122static inline string & strcat(string & s, const char * c) { s += c; return s; }
     123static inline string & strncat(string & s, const string & s2, size_t maxlen) { append(s, s2, maxlen); return s; }
     124static inline string & strncat(string & s, const char * buffer, size_t bsize) { append(s, buffer, bsize); return s; }
    106125
    107126// Repetition
    108127string ?*?(const string & s, size_t factor);
    109 string ?*?(char c, size_t size);
    110 string ?*?(const char *s, size_t size);
     128void ?*=?(string & s, size_t factor);
     129string ?*?(char c, size_t factor);
     130string ?*?(const char *s, size_t factor);
    111131
    112132// Character access
     
    116136
    117137// Comparisons
    118 int  cmp (const string &, const string &);
     138int  strcmp (const string &, const string &);
    119139bool ?==?(const string &, const string &);
    120140bool ?!=?(const string &, const string &);
     
    124144bool ?<? (const string &, const string &);
    125145
    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 &);
     146int  strcmp (const string &, const char *);
     147bool ?==?(const string &, const char *);
     148bool ?!=?(const string &, const char *);
     149bool ?>? (const string &, const char *);
     150bool ?>=?(const string &, const char *);
     151bool ?<=?(const string &, const char *);
     152bool ?<? (const string &, const char *);
     153
     154int  strcmp (const char *, const string &);
     155bool ?==?(const char *, const string &);
     156bool ?!=?(const char *, const string &);
     157bool ?>? (const char *, const string &);
     158bool ?>=?(const char *, const string &);
     159bool ?<=?(const char *, const string &);
     160bool ?<? (const char *, const string &);
    141161
    142162
    143163// Slicing
    144 string ?()( string & this, size_t start, size_t end );  // TODO const?
    145 string ?()( string & this, size_t start);
     164string ?()( string & s, size_t start, size_t len );  // TODO const?
     165string ?()( string & s, size_t start);
    146166
    147167// String search
     
    177197
    178198
    179 
    180199struct charclass {
    181200    charclass_res * inner;
Note: See TracChangeset for help on using the changeset viewer.