1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc. 24f645668Schristos Contributed by Oracle. 34f645668Schristos 44f645668Schristos This file is part of GNU Binutils. 54f645668Schristos 64f645668Schristos This program is free software; you can redistribute it and/or modify 74f645668Schristos it under the terms of the GNU General Public License as published by 84f645668Schristos the Free Software Foundation; either version 3, or (at your option) 94f645668Schristos any later version. 104f645668Schristos 114f645668Schristos This program is distributed in the hope that it will be useful, 124f645668Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 134f645668Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144f645668Schristos GNU General Public License for more details. 154f645668Schristos 164f645668Schristos You should have received a copy of the GNU General Public License 174f645668Schristos along with this program; if not, write to the Free Software 184f645668Schristos Foundation, 51 Franklin Street - Fifth Floor, Boston, 194f645668Schristos MA 02110-1301, USA. */ 204f645668Schristos 214f645668Schristos /* 224f645668Schristos * java/lang/StringBuilder 234f645668Schristos * 244f645668Schristos * Based on JavaTM 2 Platform Standard Ed. 5.0 254f645668Schristos */ 264f645668Schristos 274f645668Schristos #ifndef _StringBuilder_h 284f645668Schristos #define _StringBuilder_h 294f645668Schristos 304f645668Schristos class StringBuilder 314f645668Schristos { 324f645668Schristos public: 334f645668Schristos StringBuilder (); 344f645668Schristos StringBuilder (int capacity); 354f645668Schristos virtual ~StringBuilder (); 364f645668Schristos 374f645668Schristos int length()384f645668Schristos length () 394f645668Schristos { 404f645668Schristos return count; 414f645668Schristos } 424f645668Schristos 434f645668Schristos int capacity()444f645668Schristos capacity () 454f645668Schristos { 464f645668Schristos return maxCapacity; 474f645668Schristos } 484f645668Schristos 494f645668Schristos bool endsWith (const char str[]); 504f645668Schristos void ensureCapacity (int minimumCapacity); 514f645668Schristos void expandCapacity (int minimumCapacity); 524f645668Schristos void trimToSize (); 534f645668Schristos void trim (); 544f645668Schristos void setLength (int newLength); 554f645668Schristos char charAt (int index); 564f645668Schristos void getChars (int srcBegin, int srcEnd, char dst[], int dstBegin); 574f645668Schristos void setCharAt (int index, char ch); 584f645668Schristos StringBuilder *append (StringBuilder *sb); 594f645668Schristos StringBuilder *append (const char str[]); 604f645668Schristos StringBuilder *append (const char str[], int offset, int len); 614f645668Schristos StringBuilder *append (bool b); 624f645668Schristos StringBuilder *append (char c); 634f645668Schristos StringBuilder *append (int i); 644f645668Schristos StringBuilder *append (unsigned int i); 654f645668Schristos StringBuilder *append (long lng); 664f645668Schristos StringBuilder *append (unsigned long i); 674f645668Schristos StringBuilder *append (long long lng); 684f645668Schristos StringBuilder *append (unsigned long long lng); 694f645668Schristos StringBuilder *append (float f); 704f645668Schristos StringBuilder *append (double d); 714f645668Schristos StringBuilder *_delete (int start, int end); 724f645668Schristos StringBuilder *deleteCharAt (int index); 734f645668Schristos StringBuilder *insert (int index, const char str[], int offset, int len); 744f645668Schristos StringBuilder *insert (int offset, const char str[]); 754f645668Schristos StringBuilder *insert (int offset, bool b); 764f645668Schristos StringBuilder *insert (int offset, char c); 774f645668Schristos StringBuilder *insert (int offset, int i); 784f645668Schristos StringBuilder *insert (int offset, long l); 794f645668Schristos StringBuilder *insert (int offset, float f); 804f645668Schristos StringBuilder *insert (int offset, double d); 814f645668Schristos StringBuilder *reverse (); 824f645668Schristos char *toString (); 834f645668Schristos void toFile (FILE *fp); 844f645668Schristos void toFileLn (FILE *fp); 85*cb63e24eSchristos void write (int fd); 864f645668Schristos 874f645668Schristos // Not in Java 884f645668Schristos StringBuilder *appendf (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); 894f645668Schristos StringBuilder *sprintf (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); 904f645668Schristos 914f645668Schristos int indexOf (const char str[]); 924f645668Schristos int indexOf (const char str[], int fromIndex); 934f645668Schristos int lastIndexOf (const char str[]); 944f645668Schristos int lastIndexOf (const char str[], int fromIndex); 954f645668Schristos 964f645668Schristos private: 974f645668Schristos char *value; 984f645668Schristos int count; 994f645668Schristos int maxCapacity; 1004f645668Schristos }; 1014f645668Schristos 1024f645668Schristos #endif /* _StringBuilder_h */ 103