Ignore:
Timestamp:
07/03/20 00:37:13 (4 years ago)
Author:
Maciej Komosinski
Message:

Increased SString and std::string compatibility: introduced length(), size(), and capacity(), and removed legacy methods that have std::string equivalents

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/sstring.h

    r955 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    8585        void operator delete(void* mem) { free(mem); }
    8686
    87         int len() const { return buf->used; } ///< get string length
     87        int size() const { return buf->used; } ///< get string length
     88        int length() const { return buf->used; } ///< get string length
    8889        void shrink(); ///< free unnecessary buffer
    89         void reserve(int needed) { ensureSize(needed); } ///< like in std::string
     90        void reserve(int needed) { detachCopy(needed); } ///< like in std::string
    9091
    9192        /// after this call, you can modify sstring directly.
     
    129130        /// t.endAppend(bytecount);</CODE>
    130131        void endAppend(int appendlength = -1);
    131         /// argument is the amount of memory, that will be probably used
    132         /// by this string instance. string can use this value
    133         /// to optimize memory allocation (bigger chunks will be allocated).
    134         void memoryHint(int howbig);
    135         int directMaxLen() { return buf->size; } ///< when called after directWrite: max number of characters allowed (can be more than requested)
     132        int capacity() { return buf->size; } ///< std::string.capacity()
    136133
    137134        /// find a character in SString.
Note: See TracChangeset for help on using the changeset viewer.