PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
String.h
1 // ArduinoJson - arduinojson.org
2 // Copyright Benoit Blanchon 2014-2020
3 // MIT License
4 
5 #pragma once
6 
7 #include <string>
8 
9 // Reproduces Arduino's String class
10 class String {
11  public:
12  String() {}
13  explicit String(const char* s) : _str(s) {}
14 
15  String& operator+=(const char* rhs) {
16  _str += rhs;
17  return *this;
18  }
19 
20  size_t length() const {
21  return _str.size();
22  }
23 
24  const char* c_str() const {
25  return _str.c_str();
26  }
27 
28  bool operator==(const char* s) const {
29  return _str == s;
30  }
31 
32  friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) {
33  lhs << rhs._str;
34  return lhs;
35  }
36 
37  private:
38  std::string _str;
39 };
40 
41 class StringSumHelper;
42 
43 inline bool operator==(const std::string& lhs, const ::String& rhs) {
44  return lhs == rhs.c_str();
45 }
string
void string(char *str)
Display a character string on the oLED display.
Definition: oled_string.c:7
String
Definition: String.h:10