Ignore:
File:
1 edited

Legend:

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

    r9018dcf red5023d1  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr  9 22:27:40 2025
    13 // Update Count     : 368
     12// Last Modified On : Sat Apr  5 15:18:30 2025
     13// Update Count     : 318
    1414//
    1515
     
    295295bool ?<? ( const char * s1, const string & s2 ) { return s1 <  *s2.inner; }
    296296
     297
     298////////////////////////////////////////////////////////
     299// Getter
     300
     301size_t len( const string & s ) {
     302        return len( *s.inner );
     303}
     304
    297305////////////////////////////////////////////////////////
    298306// Concatenation
     
    416424}
    417425
    418 size_t find( const string & s, size_t start, size_t len, const string & key, size_t kstart, size_t klen ) {
     426int find( const string & s, size_t start, size_t len, const string & key, size_t kstart, size_t klen ) {
    419427        if ( start < 0 ) { start += len( s ); }
    420428        if ( len < 0 ) { len = -len; start -= len; }
     
    426434        if ( kstart >= len( key ) ) return 0;
    427435        if ( kstart + klen > len( key ) ) klen = len( key ) - kstart;
    428 
     436       
    429437        return findFrom( *s.inner, start, *key.inner );
    430438}
    431439
    432 size_t find( const string & s, char key ) {
     440int find( const string & s, char key ) {
    433441        return find( *s.inner, key );
    434442}
    435443
    436 size_t find( const string & s, const string & key ) {
     444int find( const string & s, const string & key ) {
    437445        return find( *s.inner, *key.inner );
    438446}
    439447
    440 size_t find( const string & s, const char * key ) {
     448int find( const string & s, const char * key ) {
    441449        return find( *s.inner, key );
    442450}
    443451
    444 size_t find( const string & s, const char * key, size_t keysize ) {
     452int find( const string & s, const char * key, size_t keysize ) {
    445453        return find( *s.inner, key, keysize );
    446454}
    447455
    448 size_t find( const string & s, size_t start, char key ) {
     456int find( const string & s, size_t start, char key ) {
    449457        return findFrom( *s.inner, start, key );
    450458}
    451459
    452 size_t find( const string & s, size_t start, const char * key ) {
     460int find( const string & s, size_t start, const char * key ) {
    453461        return findFrom( *s.inner, start, key );
    454462}
    455463
    456 size_t find( const string & s, size_t start, const char * key, size_t keysize ) {
     464int find( const string & s, size_t start, const char * key, size_t keysize ) {
    457465        return findFrom( *s.inner, start, key, keysize );
    458466}
     
    519527}
    520528
    521 size_t exclude( const string & s, const charclass & mask ) {
     529
     530int exclude( const string & s, const charclass & mask ) {
    522531        return exclude( *s.inner, *mask.inner );
    523532}
    524 
    525 size_t include( const string & s, const charclass & mask ) {
     533/*
     534StrSlice exclude( string & s, const charclass & mask ) {
     535}
     536*/
     537
     538int include( const string & s, const charclass & mask ) {
    526539        return include( *s.inner, *mask.inner );
    527540}
    528541
    529 size_t test( const string & s, int (*f)( int ) ) {
    530         size_t l = len( s );
    531         for ( i; l ) {
    532                 if ( ! f( s[i] ) ) return i;
    533         } // for
    534         return l;
    535 }
    536 
    537 string replace( string & s, const string & from, const string & to ) {
    538         ssize_t pos;
    539     string r;
    540 
    541     pos = find( s, from );
    542     if ( pos < len( s ) ) {
    543                 r = s( 0, pos ) + to + replace( s( pos + (ssize_t)len( from ) ), from, to );
    544                 string front = s( 0, pos );
    545                 string back = s( pos + (ssize_t)len( from ) );
    546                 r = front + to + replace( back, from, to );
    547     } else {
    548                 r = s;
    549     } // if
    550     return r;
    551 }
    552 
    553 string translate( const string & s, int (*f)( int ) ) {
    554         string r = s;
    555         size_t l = len( r );
    556         for ( i; l ) {
    557                 r[i] = (char)f( r[i] );
    558         } // for
    559         return r;
    560 }
     542/*
     543StrSlice include( string & s, const charclass & mask ) {
     544}
     545*/
Note: See TracChangeset for help on using the changeset viewer.