Ignore:
Timestamp:
Feb 2, 2015, 2:11:18 PM (11 years ago)
Author:
pr
Message:

Add find_first_of(char...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cppbase/bs_string.cpp

    r254 r421  
    88
    99/*
    10  *      This file Copyright (C) 1999-2001 Ulrich M”ller.
     10 *      This file Copyright (C) 1999-2015 Ulrich M”ller.
    1111 *      This program is free software; you can redistribute it and/or modify
    1212 *      it under the terms of the GNU General Public License as published by
     
    579579    }
    580580
     581    return (npos);
     582}
     583
     584/*
     585 *@@ find_first_of:
     586 *      finds the first character in the member
     587 *      string which is the same as "c".
     588 *
     589 *      The search is started at ulPos, which
     590 *      defaults to 0.
     591 *
     592 *      Returns BSString::npos if not found.
     593 *
     594 *@@added V1.0.21 (2015-01-29) [pr]
     595 */
     596
     597size_type BSString::find_first_of(char c,             // in: character to find
     598                                  size_type ulPos)    // in: start of search (defaults to 0)
     599                    const
     600{
     601    STRINGLOCK;
     602    size_type Size = size();
     603
     604    if (    (ulPos < Size)
     605         && (c)
     606       )
     607    {
     608        char *p;
     609        size_type ul;
     610        for (p = _pBuf->_str.psz + ulPos, ul = ulPos;
     611             ul < Size;
     612             ++p, ++ul)
     613        {
     614            if (*p != c)
     615                return (ul);
     616        }
     617    }
     618
     619    // not found:
    581620    return (npos);
    582621}
Note: See TracChangeset for help on using the changeset viewer.