LCOV - code coverage report
Current view: top level - src/AH/PrintStream - PrintStream.hpp (source / functions) Hit Total Coverage
Test: 00f463b534fbea22f0b596e091a60715679e3064 Lines: 3 3 100.0 %
Date: 2024-11-03 16:33:35 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**
       2             :  * @brief   [PrintStream library](https://github.com/tttapa/Arduino-PrintStream/blob/6a9e0d365be0b3d84187daa2a8a7bda8d541472e/src/PrintStream.h)
       3             :  */
       4             : 
       5             : #ifndef PrintStream_h
       6             : #define PrintStream_h
       7             : 
       8             : #include <AH/Arduino-Wrapper.h> // Print
       9             : #include <AH/Settings/NamespaceSettings.hpp>
      10             : 
      11             : BEGIN_AH_NAMESPACE
      12             : 
      13             : /// @addtogroup  AH_PrintStream
      14             : /// @{
      15             : 
      16             : typedef Print &manipulator(Print &);
      17             : 
      18             : Print &endl(Print &printer);
      19             : Print &flush(Print &printer);
      20             : Print &hex(Print &printer);
      21             : Print &bin(Print &printer);
      22             : Print &dec(Print &printer);
      23             : /* Print &oct(Print &printer); */
      24             : Print &boolalpha(Print &printer);
      25             : Print &noboolalpha(Print &printer);
      26             : Print &leadingzeros(Print &printer);
      27             : Print &noleadingzeros(Print &printer);
      28             : Print &uppercase(Print &printer);
      29             : Print &nouppercase(Print &printer);
      30             : Print &showbase(Print &printer);
      31             : Print &noshowbase(Print &printer);
      32             : 
      33             : Print &operator<<(Print &printer, const __FlashStringHelper *s);
      34             : #ifdef ARDUINO
      35             : Print &operator<<(Print &printer, const String &s);
      36             : #endif
      37             : Print &operator<<(Print &printer, const char s[]);
      38             : Print &operator<<(Print &printer, char c);
      39             : Print &operator<<(Print &printer, unsigned char c);
      40             : Print &operator<<(Print &printer, int i);
      41             : Print &operator<<(Print &printer, unsigned int i);
      42             : Print &operator<<(Print &printer, int8_t i);
      43             : Print &operator<<(Print &printer, long i);
      44             : Print &operator<<(Print &printer, unsigned long i);
      45             : Print &operator<<(Print &printer, float f);
      46             : Print &operator<<(Print &printer, double d);
      47             : Print &operator<<(Print &printer, const Printable &p);
      48             : Print &operator<<(Print &printer, bool b);
      49             : 
      50             : Print &operator<<(Print &printer, manipulator pf);
      51             : 
      52             : struct Setbase {
      53             :     uint8_t M_base;
      54             : };
      55             : Setbase setbase(uint8_t base);
      56             : Print &operator<<(Print &printer, Setbase f);
      57             : 
      58             : struct Setprecision {
      59             :     int M_n;
      60             : };
      61             : Setprecision setprecision(int n);
      62             : Print &operator<<(Print &printer, Setprecision f);
      63             : 
      64             : struct Setbytesep {
      65             :     char M_bytesep;
      66             : };
      67             : Setbytesep setbytesep(char bytesep);
      68             : Print &operator<<(Print &printer, Setbytesep f);
      69             : 
      70             : struct HexDump {
      71           1 :     HexDump(const uint8_t *data, size_t length) : data(data), length(length) {}
      72             :     template <size_t N>
      73             :     explicit HexDump(const uint8_t (&data)[N]) : HexDump {data, N} {}
      74             :     const uint8_t *data;
      75             :     size_t length;
      76             : };
      77             : 
      78             : Print &operator<<(Print &p, HexDump h);
      79             : 
      80             : /// @}
      81             : 
      82             : END_AH_NAMESPACE
      83             : 
      84             : #ifndef ARDUINO
      85             : 
      86             : #include <iomanip>
      87             : #include <iostream>
      88             : 
      89             : BEGIN_AH_NAMESPACE
      90             : 
      91             : // TODO: check conflicts between Arduino version and C++ STL version
      92             : using std::endl;
      93             : // using std::setbase;
      94             : // using std::setprecision;
      95             : using std::boolalpha;
      96             : using std::dec;
      97             : using std::flush;
      98             : using std::hex;
      99             : using std::noboolalpha;
     100             : using std::noshowbase;
     101             : using std::nouppercase;
     102             : using std::showbase;
     103             : using std::uppercase;
     104             : 
     105             : inline std::ostream &operator<<(std::ostream &os, uint8_t u) {
     106             :     // I'm lazy, I should probably implement one for uint8_t to get the leading
     107             :     // zeros right
     108             :     return os << static_cast<unsigned short>(u);
     109             : }
     110             : 
     111          33 : inline std::ostream &operator<<(std::ostream &os,
     112             :                                 const __FlashStringHelper *s) {
     113          33 :     return os << reinterpret_cast<const char *>(s);
     114             : }
     115             : 
     116             : std::ostream &operator<<(std::ostream &p, HexDump h);
     117             : 
     118             : END_AH_NAMESPACE
     119             : 
     120             : #endif
     121             : 
     122             : #endif // PrintStream_h

Generated by: LCOV version 1.15