-
-
Notifications
You must be signed in to change notification settings - Fork 7k
String class (WString.cpp/.h) new functions #4890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
void trim(void); void trim(char remove); void trimStart(void); void trimStart(char remove); void trimEnd(void); void trimEnd(char remove); void padLeft(unsigned int newlength); void padLeft(unsigned int newlength, char add); void padRight(unsigned int newlength); void padRight(unsigned int newlength, char add); void cropLeft(unsigned int count); void cropRight(unsigned int count); void keepLeft(unsigned int count); void keepRight(unsigned int count); also: // modification // notice: void function (...) operates on the object and returns void // String functionC (...) operates on a copy of the object and returns the copy (C=Copy) // String* functionS (...) operates on the object and returns a pointer to the object (S=Self) void replace (char find, char replace); String replaceC(char find, char replace); String* replaceS(char find, char replace); void replace (const
When the String instance is created and/or increased, a new variable "reserverPercentage" defines how much reserve to keep when resizing.
The constructors of the String class are modified to take an additional parameter 'bufferSize' which defines the minimum capacity when the memory of the buffer array is allocated.
The constructors of the String class are modified to take an additional parameter 'bufferSize' which defines the minimum capacity when the memory of the buffer array is allocated. Whitespace tabs converted to spaces.
Instead of adding the -S versions, wouldn't it be better to just replace the functions returning |
@cousteaulecommandant, can't the proposed |
Yes, but I think |
I agree with #4890 (comment) , and this discussion should be migrated to https://github.com/arduino/ArduinoCore-api since it allows very interesting stuff. We are not going to add |
See
https://groups.google.com/a/arduino.cc/forum/#!topic/developers/ryrMAJiqwf0
summary:
adds a reserve on the realloc so that further small String concats don't have to realloc every time.
sets a default value for reservePercentage, that is used when creating new Strings.
These 3 functions operate in init() and reserve().
Added String manipulation functions:
// modification
// notice: void function (...) operates on the object and returns void
// String functionC (...) operates on a copy of the object and returns the copy (C=Copy)
// String* functionS (...) operates on the object and returns a pointer to the object (S=Self)
existing before #### void replace (char find, char replace);
String replaceC(char find, char replace);
String* replaceS(char find, char replace);
existing before #### void replace (const String& find, const String& replace);
String replaceC(const String& find, const String& replace);
String* replaceS(const String& find, const String& replace);
existing before #### void remove (unsigned int index);
String removeC(unsigned int index);
String* removeS(unsigned int index);
existing before #### void remove (unsigned int index, unsigned int count);
String removeC(unsigned int index, unsigned int count);
String* removeS(unsigned int index, unsigned int count);
existing before #### void toLowerCase (void);
String toLowerCaseC(void);
String* toLowerCaseS(void);
existing before #### void toUpperCase (void);
String toUpperCaseC(void);
String* toUpperCaseS(void);
existing before #### void trim (void);
String trimC(void);
String* trimS(void);
void trim (char remove);
String trimC(char remove);
String* trimS(char remove);
void trimStart (void);
String trimStartC(void);
String* trimStartS(void);
void trimStart (char remove);
String trimStartC(char remove);
String* trimStartS(char remove);
void trimEnd (void);
String trimEndC(void);
String* trimEndS(void);
void trimEnd (char remove);
String trimEndC(char remove);
String* trimEndS(char remove);
void padLeft (unsigned int newlength);
String padLeftC(unsigned int newlength);
String* padLeftS(unsigned int newlength);
void padLeft (unsigned int newlength, char add);
String padLeftC(unsigned int newlength, char add);
String* padLeftS(unsigned int newlength, char add);
void padRight (unsigned int newlength);
String padRightC(unsigned int newlength);
String* padRightS(unsigned int newlength);
void padRight (unsigned int newlength, char add);
String padRightC(unsigned int newlength, char add);
String* padRightS(unsigned int newlength, char add);
void cropLeft (unsigned int count);
String cropLeftC(unsigned int count);
String* cropLeftS(unsigned int count);
void cropRight (unsigned int count);
String cropRightC(unsigned int count);
String* cropRightS(unsigned int count);
void keepLeft (unsigned int count);
String keepLeftC(unsigned int count);
String* keepLeftS(unsigned int count);
void keepRight (unsigned int count);
String keepRightC(unsigned int count);
String* keepRightS(unsigned int count);
detailed descriptions at
#4870