Changeset 6264087 for libcfa


Ignore:
Timestamp:
Aug 14, 2023, 9:29:40 PM (15 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
329487c
Parents:
b5e725a
Message:

formatting

Location:
libcfa/src/containers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/string.cfa

    rb5e725a r6264087  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 12 15:24:18 2023
    13 // Update Count     : 6
     12// Last Modified On : Sun Aug 13 22:50:08 2023
     13// Update Count     : 7
    1414//
    1515
     
    5555}
    5656
    57 void ?{}( string & this, const char* buffer, size_t bsize) {
     57void ?{}( string & this, const char * buffer, size_t bsize) {
    5858    (this.inner) { malloc() };
    5959    ?{}( *this.inner, buffer, bsize );
     
    110110}
    111111
    112 ifstream & ?|?(ifstream &in, string &this) {
     112ifstream & ?|?(ifstream & in, string & this) {
    113113    return in | (*this.inner); // read to internal string_res
    114114}
    115115
     116void ?|?( ifstream & in, string & this ) {
     117    (ifstream &)(in | this); ends( in );
     118}
    116119
    117120////////////////////////////////////////////////////////
     
    131134// Comparison
    132135
    133 bool ?==?(const string &s, const string &other) {
     136bool ?==?(const string & s, const string & other) {
    134137    return *s.inner == *other.inner;
    135138}
    136139
    137 bool ?!=?(const string &s, const string &other) {
     140bool ?!=?(const string & s, const string & other) {
    138141    return *s.inner != *other.inner;
    139142}
    140143
    141 bool ?==?(const string &s, const char* other) {
     144bool ?==?(const string & s, const char * other) {
    142145    return *s.inner == other;
    143146}
    144147
    145 bool ?!=?(const string &s, const char* other) {
     148bool ?!=?(const string & s, const char * other) {
    146149    return *s.inner != other;
    147150}
     
    150153// Getter
    151154
    152 size_t size(const string &s) {
     155size_t size(const string & s) {
    153156    return size( * s.inner );
    154157}
     
    157160// Concatenation
    158161
    159 void ?+=?(string &s, char other) {
     162void ?+=?(string & s, char other) {
    160163    (*s.inner) += other;
    161164}
    162165
    163 void ?+=?(string &s, const string &s2) {
     166void ?+=?(string & s, const string & s2) {
    164167    (*s.inner) += (*s2.inner);
    165168}
    166169
    167 void ?+=?(string &s, const char* other) {
     170void ?+=?(string & s, const char * other) {
    168171    (*s.inner) += other;
    169172}
    170173
    171 string ?+?(const string &s, char other) {
     174string ?+?(const string & s, char other) {
    172175    string ret = s;
    173176    ret += other;
     
    175178}
    176179
    177 string ?+?(const string &s, const string &s2) {
     180string ?+?(const string & s, const string & s2) {
    178181    string ret = s;
    179182    ret += s2;
     
    181184}
    182185
    183 string ?+?(const char* s1, const char* s2) {
     186string ?+?(const char * s1, const char * s2) {
    184187    string ret = s1;
    185188    ret += s2;
     
    187190}
    188191
    189 string ?+?(const string &s, const char* other) {
     192string ?+?(const string & s, const char * other) {
    190193    string ret = s;
    191194    ret += other;
     
    196199// Repetition
    197200
    198 string ?*?(const string &s, size_t factor) {
     201string ?*?(const string & s, size_t factor) {
    199202    string ret = "";
    200203    for (factor) ret += s;
     
    216219// Character access
    217220
    218 char ?[?](const string &s, size_t index) {
     221char ?[?](const string & s, size_t index) {
    219222    return (*s.inner)[index];
    220223}
    221224
    222 string ?[?](string &s, size_t index) {
     225string ?[?](string & s, size_t index) {
    223226    string ret = { *s.inner, index, index + 1 };
    224227    return ret`shareEdits;
     
    228231// Search
    229232
    230 bool contains(const string &s, char ch) {
     233bool contains(const string & s, char ch) {
    231234    return contains( *s.inner, ch );
    232235}
    233236
    234 int find(const string &s, char search) {
     237int find(const string & s, char search) {
    235238    return find( *s.inner, search );
    236239}
    237240
    238 int find(const string &s, const string &search) {
     241int find(const string & s, const string & search) {
    239242    return find( *s.inner, *search.inner );
    240243}
    241244
    242 int find(const string &s, const char* search) {
     245int find(const string & s, const char * search) {
    243246    return find( *s.inner, search);
    244247}
    245248
    246 int find(const string &s, const char* search, size_t searchsize) {
     249int find(const string & s, const char * search, size_t searchsize) {
    247250    return find( *s.inner, search, searchsize);
    248251}
    249252
    250 int findFrom(const string &s, size_t fromPos, char search) {
     253int findFrom(const string & s, size_t fromPos, char search) {
    251254    return findFrom( *s.inner, fromPos, search );
    252255}
    253256
    254 int findFrom(const string &s, size_t fromPos, const string &search) {
     257int findFrom(const string & s, size_t fromPos, const string & search) {
    255258    return findFrom( *s.inner, fromPos, *search.inner );
    256259}
    257260
    258 int findFrom(const string &s, size_t fromPos, const char* search) {
     261int findFrom(const string & s, size_t fromPos, const char * search) {
    259262    return findFrom( *s.inner, fromPos, search );
    260263}
    261264
    262 int findFrom(const string &s, size_t fromPos, const char* search, size_t searchsize) {
     265int findFrom(const string & s, size_t fromPos, const char * search, size_t searchsize) {
    263266    return findFrom( *s.inner, fromPos, search, searchsize );
    264267}
    265268
    266 bool includes(const string &s, const string &search) {
     269bool includes(const string & s, const string & search) {
    267270    return includes( *s.inner, *search.inner );
    268271}
    269272
    270 bool includes(const string &s, const char* search) {
     273bool includes(const string & s, const char * search) {
    271274    return includes( *s.inner, search );
    272275}
    273276
    274 bool includes(const string &s, const char* search, size_t searchsize) {
     277bool includes(const string & s, const char * search, size_t searchsize) {
    275278    return includes( *s.inner, search, searchsize );
    276279}
    277280
    278 bool startsWith(const string &s, const string &prefix) {
     281bool startsWith(const string & s, const string & prefix) {
    279282    return startsWith( *s.inner, *prefix.inner );
    280283}
    281284
    282 bool startsWith(const string &s, const char* prefix) {
     285bool startsWith(const string & s, const char * prefix) {
    283286    return startsWith( *s.inner, prefix );
    284287}
    285288
    286 bool startsWith(const string &s, const char* prefix, size_t prefixsize) {
     289bool startsWith(const string & s, const char * prefix, size_t prefixsize) {
    287290    return startsWith( *s.inner, prefix, prefixsize );
    288291}
    289292
    290 bool endsWith(const string &s, const string &suffix) {
     293bool endsWith(const string & s, const string & suffix) {
    291294    return endsWith( *s.inner, *suffix.inner );
    292295}
    293296
    294 bool endsWith(const string &s, const char* suffix) {
     297bool endsWith(const string & s, const char * suffix) {
    295298    return endsWith( *s.inner, suffix );
    296299}
    297300
    298 bool endsWith(const string &s, const char* suffix, size_t suffixsize) {
     301bool endsWith(const string & s, const char * suffix, size_t suffixsize) {
    299302    return endsWith( *s.inner, suffix, suffixsize );
    300303}
     
    326329
    327330
    328 int exclude(const string &s, const charclass &mask) {
     331int exclude(const string & s, const charclass & mask) {
    329332    return exclude( *s.inner, *mask.inner );
    330333}
    331334/*
    332 StrSlice exclude(string &s, const charclass &mask) {
     335StrSlice exclude(string & s, const charclass & mask) {
    333336}
    334337*/
    335338
    336 int include(const string &s, const charclass &mask) {
     339int include(const string & s, const charclass & mask) {
    337340    return include( *s.inner, *mask.inner );
    338341}
    339342
    340343/*
    341 StrSlice include(string &s, const charclass &mask) {
     344StrSlice include(string & s, const charclass & mask) {
    342345}
    343346*/
  • libcfa/src/containers/string.hfa

    rb5e725a r6264087  
    99// Author           : Michael L. Brooks
    1010// Created On       : Fri Sep 03 11:00:00 2021
    11 // Last Modified By : Michael L. Brooks
    12 // Last Modified On : Fri Sep 03 11:00:00 2021
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Aug 13 22:46:46 2023
     13// Update Count     : 4
    1414//
    1515
     
    2828
    2929// Getters
    30 size_t size(const string &s);
     30size_t size(const string & s);
    3131
    3232// 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
     33void ?{}(string & this); // empty string
     34void ?{}(string & s, const char * initial); // copy from string literal (NULL-terminated)
     35void ?{}(string & s, const char * buffer, size_t bsize); // copy specific length from buffer
    3636
    37 void ?{}(string &s, const string & s2);
    38 void ?{}(string &s, string & s2);
     37void ?{}(string & s, const string & s2);
     38void ?{}(string & s, string & s2);
    3939
    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
     40void ?=?(string & s, const char * other); // copy assignment from literal
     41void ?=?(string & s, const string & other);
     42void ?=?(string & s, char other);
     43string & ?=?(string & s, string & other);  // surprising ret seems to help avoid calls to autogen
    4444//string ?=?( string &, string ) = void;
    45 void ^?{}(string &s);
     45void ^?{}(string & s);
    4646
    4747// Alternate construction: request shared edits
     
    5353
    5454// IO Operator
    55 ofstream & ?|?(ofstream &out, const string &s);
    56 void ?|?(ofstream &out, const string &s);
    57 ifstream & ?|?(ifstream &in, string &s);
     55ofstream & ?|?(ofstream & out, const string & s);
     56void ?|?(ofstream & out, const string & s);
     57ifstream & ?|?(ifstream & in, string & s);
     58void ?|?( ifstream & in, string & this );
    5859
    5960// Concatenation
    60 void ?+=?(string &s, char other); // append a character
    61 void ?+=?(string &s, const string &s2); // append-concatenate to first string
    62 void ?+=?(string &s, const char* other); // append-concatenate to first string
    63 string ?+?(const string &s, char other); // add a character to a copy of the string
    64 string ?+?(const string &s, const string &s2); // copy and concatenate both strings
    65 string ?+?(const char* s1, const char* s2); // concatenate both strings
    66 string ?+?(const string &s, const char* other); // copy and concatenate with NULL-terminated string
     61void ?+=?(string & s, char other); // append a character
     62void ?+=?(string & s, const string & s2); // append-concatenate to first string
     63void ?+=?(string & s, const char * other); // append-concatenate to first string
     64string ?+?(const string & s, char other); // add a character to a copy of the string
     65string ?+?(const string & s, const string & s2); // copy and concatenate both strings
     66string ?+?(const char * s1, const char * s2); // concatenate both strings
     67string ?+?(const string & s, const char * other); // copy and concatenate with NULL-terminated string
    6768
    6869// Repetition
    69 string ?*?(const string &s, size_t factor);
     70string ?*?(const string & s, size_t factor);
    7071string ?*?(char c, size_t size);
    7172string ?*?(const char *s, size_t size);
    7273
    7374// Character access
    74 char ?[?](const string &s, size_t index);
    75 string ?[?](string &s, size_t index);  // mutable length-1 slice of original
    76 //char codePointAt(const string &s, size_t index);  // to revisit under Unicode
     75char ?[?](const string & s, size_t index);
     76string ?[?](string & s, size_t index);  // mutable length-1 slice of original
     77//char codePointAt(const string & s, size_t index);  // to revisit under Unicode
    7778
    7879// Comparisons
    79 bool ?==?(const string &s, const string &other);
    80 bool ?!=?(const string &s, const string &other);
    81 bool ?==?(const string &s, const char* other);
    82 bool ?!=?(const string &s, const char* other);
     80bool ?==?(const string & s, const string & other);
     81bool ?!=?(const string & s, const string & other);
     82bool ?==?(const string & s, const char * other);
     83bool ?!=?(const string & s, const char * other);
    8384
    8485// Slicing
     
    8788
    8889// String search
    89 bool contains(const string &s, char ch); // single character
     90bool contains(const string & s, char ch); // single character
    9091
    91 int find(const string &s, char search);
    92 int find(const string &s, const string &search);
    93 int find(const string &s, const char* search);
    94 int find(const string &s, const char* search, size_t searchsize);
     92int find(const string & s, char search);
     93int find(const string & s, const string & search);
     94int find(const string & s, const char * search);
     95int find(const string & s, const char * search, size_t searchsize);
    9596
    96 int findFrom(const string &s, size_t fromPos, char search);
    97 int findFrom(const string &s, size_t fromPos, const string &search);
    98 int findFrom(const string &s, size_t fromPos, const char* search);
    99 int findFrom(const string &s, size_t fromPos, const char* search, size_t searchsize);
     97int findFrom(const string & s, size_t fromPos, char search);
     98int findFrom(const string & s, size_t fromPos, const string & search);
     99int findFrom(const string & s, size_t fromPos, const char * search);
     100int findFrom(const string & s, size_t fromPos, const char * search, size_t searchsize);
    100101
    101 bool includes(const string &s, const string &search);
    102 bool includes(const string &s, const char* search);
    103 bool includes(const string &s, const char* search, size_t searchsize);
     102bool includes(const string & s, const string & search);
     103bool includes(const string & s, const char * search);
     104bool includes(const string & s, const char * search, size_t searchsize);
    104105
    105 bool startsWith(const string &s, const string &prefix);
    106 bool startsWith(const string &s, const char* prefix);
    107 bool startsWith(const string &s, const char* prefix, size_t prefixsize);
     106bool startsWith(const string & s, const string & prefix);
     107bool startsWith(const string & s, const char * prefix);
     108bool startsWith(const string & s, const char * prefix, size_t prefixsize);
    108109
    109 bool endsWith(const string &s, const string &suffix);
    110 bool endsWith(const string &s, const char* suffix);
    111 bool endsWith(const string &s, const char* suffix, size_t suffixsize);
     110bool endsWith(const string & s, const string & suffix);
     111bool endsWith(const string & s, const char * suffix);
     112bool endsWith(const string & s, const char * suffix, size_t suffixsize);
    112113
    113114// Modifiers
    114 void padStart(string &s, size_t n);
    115 void padStart(string &s, size_t n, char padding);
    116 void padEnd(string &s, size_t n);
    117 void padEnd(string &s, size_t n, char padding);
     115void padStart(string & s, size_t n);
     116void padStart(string & s, size_t n, char padding);
     117void padEnd(string & s, size_t n);
     118void padEnd(string & s, size_t n, char padding);
    118119
    119120
     
    132133void ^?{}( charclass & );
    133134
    134 int include(const string &s, const charclass &mask);
     135int include(const string & s, const charclass & mask);
    135136
    136 int exclude(const string &s, const charclass &mask);
     137int exclude(const string & s, const charclass & mask);
    137138
    138139/*
    139140What to do with?
    140 StrRet include(string &s, const charclass &mask);
    141 StrRet exclude(string &s, const charclass &mask);
     141StrRet include(string & s, const charclass & mask);
     142StrRet exclude(string & s, const charclass & mask);
    142143*/
    143 
    144 
Note: See TracChangeset for help on using the changeset viewer.