| 32 | |
| 33 | |
| 34 | class sstream { |
| 35 | public: |
| 36 | sstream() FL_NOEXCEPT = default; |
| 37 | sstream(const string &str) FL_NOEXCEPT : mStr(str) {} |
| 38 | |
| 39 | void setTreatCharAsInt(bool treatCharAsInt) FL_NOEXCEPT { |
| 40 | mTreatCharAsInt = treatCharAsInt; |
| 41 | } |
| 42 | |
| 43 | string str() const FL_NOEXCEPT { return mStr; } |
| 44 | const char *c_str() const FL_NOEXCEPT { return mStr.c_str(); } |
| 45 | |
| 46 | sstream &operator<<(const CRGB &rgb) FL_NOEXCEPT { |
| 47 | mStr.append(rgb); |
| 48 | return *this; |
| 49 | } |
| 50 | sstream &operator<<(const sstream &strStream) FL_NOEXCEPT { |
| 51 | mStr.append(strStream.str()); |
| 52 | return *this; |
| 53 | } |
| 54 | |
| 55 | sstream &operator<<(const Tile2x2_u8 &subpixel) FL_NOEXCEPT; |
| 56 | sstream &operator<<(const Tile2x2_u8_wrap &tile) FL_NOEXCEPT; // New overload for wrapped tiles |
| 57 | |
| 58 | // Bins support - implemented in strstream.cpp.hpp |
| 59 | sstream &operator<<(const audio::fft::Bins &bins) FL_NOEXCEPT; |
| 60 | |
| 61 | // vec2<T> support - format as (x,y) |
| 62 | template<typename T> |
| 63 | sstream &operator<<(const vec2<T> &v) FL_NOEXCEPT { |
| 64 | mStr.append("("); |
| 65 | mStr.append(v.x); |
| 66 | mStr.append(","); |
| 67 | mStr.append(v.y); |
| 68 | mStr.append(")"); |
| 69 | return *this; |
| 70 | } |
| 71 | |
| 72 | // rect<T> support - format as rect((minx,miny), (maxx,maxy)) |
| 73 | template<typename T> |
| 74 | sstream &operator<<(const rect<T> &r) FL_NOEXCEPT { |
| 75 | mStr.append("rect("); |
| 76 | (*this) << r.mMin; |
| 77 | mStr.append(", "); |
| 78 | (*this) << r.mMax; |
| 79 | mStr.append(")"); |
| 80 | return *this; |
| 81 | } |
| 82 | |
| 83 | // Optional<T> support - format as nullopt or optional(value) |
| 84 | template<typename T> |
| 85 | sstream &operator<<(const Optional<T> &opt) FL_NOEXCEPT { |
| 86 | if (!opt.has_value()) { |
| 87 | mStr.append("nullopt"); |
| 88 | } else { |
| 89 | mStr.append("optional("); |
| 90 | (*this) << *opt; |
| 91 | mStr.append(")"); |