/*
SafeSting length(), trim()
by Matthew Ford
Copyright(c)2020 Forward Computing and Control Pty. Ltd.
This example code is in the public domain.
www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html
*/
#include "SafeString.h"
void setup() {
// Open serial communications and wait a few seconds
Serial.begin(115200);
Serial.println();
Serial.println(F("SafeString length(), trim() functions"));
Serial.println(F("SafeString::setOutput(Serial); // verbose == true"));
// see the SafeString_ConstructorAndDebugging example for debugging settings
SafeString::setOutput(Serial); // enable full debugging error msgs
Serial.println();
// here's a String with empty spaces at the end (called white space):
createSafeString(stringOne, 32, " Hello! ");
createSafeString(stringTwo, 32);
stringOne.debug();
Serial.print("#");
Serial.print(stringOne);
Serial.println("#");
Serial.print(F("stringOne.length() = "));
Serial.println(stringOne.length());
Serial.println();
stringTwo = stringOne;
stringTwo.trim();
stringTwo.debug(F("stringTwo.trim(); => "));
Serial.println("stringTwo.trim() done");
Serial.print("#");
Serial.print(stringTwo);
Serial.println("#");
Serial.print(F("stringTwo.length() = "));
Serial.println(stringTwo.length());
Serial.println();
Serial.println(F(" c_str() gives to access to the underly char array as a const char* so you cannot change the contents"));
Serial.println();
Serial.print(F("stringTwo.c_str() = #"));
Serial.print(stringTwo.c_str());
Serial.println("#");
Serial.println();
Serial.println();
}
void loop() {
}