library StackString anybody have a compiling example?

Hello,

I tried to use the StackString-Library arduino-libraries / StackString · GitLab

I installed the library with the built-in library-manager and it is listed under sketch include library.

As long as I just add the include-command

#include <StackString.hpp>

to my testcode the code compiles

As soon as I try to create a first string like in the example

StackString<100> myString = StackString<100>("Hello, World!");

The compiler complaints
"'StackString' does not name a type; did you mean 'StackString_h'?"

Does anybody have a compiling code-example or any idea what causes the compiler-error?

best regards

Stefan

(deleted)

Hi spycatcher2k,

I raised an issue on gitlab and the author did already reply to it.
the original source had not Demo *.ino-file at all.

in the meantime I was able to get it to compile and I created a Demo-example that shows the use of each command

#include <StackString.hpp> 
using namespace Stack;  // it is very important to have this line of code. Otherwise the code won't compile

StackString<50> myString = StackString<50>("Hello, World!");

void setup() 
{ 
  Serial.begin(115200); 
  Serial.println();
  Serial.println();
  Serial.println(myString.c_str());

  myString.prepend("Everybody say: ");
  Serial.println(myString.c_str());

  myString.append(" How are you doing?");
  Serial.println(myString.c_str());
  Serial.println();

  StackString<100> myString1 = StackString<100>("http://arjenstens.com");
  Serial.println(                                 "012345678901234567890");
  Serial.println(                                 "|           |   |    ");
  Serial.println( myString1.c_str()  );
  Serial.print("first occurence of letter 's' is position ");
  Serial.println( myString1.find("s")  );   
  Serial.print("second occurence of letter 's' is position ");
  Serial.println( myString1.find("s", 2) ); 
  Serial.println();

                                             //0123456789012345
  StackString<64>  MyIniStr = StackString<64>("123456789=abcde");
  StackString<64>  MyIniIdentifier = StackString<64>("");
  StackString<64>  MyIniValueStr   = StackString<64>("");

  Serial.println("0123456789012345");
  Serial.println("|        |    |");
  Serial.println("123456789=abcde");
  int PosOfEqualSign = MyIniStr.find("=");
  Serial.print("PosOfEqualSign:");
  Serial.println(PosOfEqualSign);

  int Len            = MyIniStr.length();
  Serial.print("Len:");
  Serial.println(Len);

  
  MyIniIdentifier = MyIniStr.substring(0,PosOfEqualSign);
  //MyIniIdentifier = MyIniStr.substring(0,9);
  Serial.print("MyIniIdentifier =#");
  Serial.print(MyIniIdentifier.c_str());
  Serial.println("#");

  MyIniValueStr   = MyIniStr.substring(PosOfEqualSign + 1, (Len - PosOfEqualSign - 1));
  Serial.print("MyIniValueStr =#");
  Serial.print(MyIniValueStr.c_str());
  Serial.println("#");
  Serial.println();

  StackString<10> myNumberAsString = StackString<10>("1133");
  int MyNumberAsInteger = myNumberAsString.toInt() * 2;
  Serial.print("myNumberAsString =#");
  Serial.print(myNumberAsString.c_str());
  Serial.println("#");

  Serial.print("MyNumberAsInteger = myNumberAsString.toInt() * 2=");
  Serial.println(MyNumberAsInteger);
  Serial.println();

  Serial.println( myString1.c_str()  );
  Serial.print("does the string above start with 'https'? ");
  if (!myString1.startsWith ("https"))
    { 
    Serial.println("no !");
    Serial.println();
    }

  Serial.print("does the string above start with 'http'? ");
  if (myString1.startsWith ("http"))
    { 
    Serial.println("YES !");
    Serial.println();
    }
}

void loop() 
{ // put your main code here, to run repeatedly:

}

The output in the COM-Window should look like this

Hello, World!
Everybody say: Hello, World!
Everybody say: Hello, World! How are you doing?

012345678901234567890
|           |   |    
http://arjenstens.com
first occurence of letter 's' is position 12
second occurence of letter 's' is position 16

0123456789012345
|        |    |
123456789=abcde
PosOfEqualSign:9
Len:15
MyIniIdentifier =#123456789#
MyIniValueStr =#abcde#

myNumberAsString =#1133#
MyNumberAsInteger = myNumberAsString.toInt() * 2=2266

http://arjenstens.com
does the string above start with 'https'? no !

does the string above start with 'http'? YES !

best regards

Stefan