ostream.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
5 #ifndef UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED
6 #define UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED
7 
9 #include <cstdio>
10 
11 namespace uavcan
12 {
23 {
24  OStream() { }
25 
26 public:
27  static OStream& instance()
28  {
29  static OStream s;
30  return s;
31  }
32 
34  {
35  std::printf("\n");
36  return stream;
37  }
38 };
39 
40 inline OStream& operator<<(OStream& s, long long x) { std::printf("%lld", x); return s; }
41 inline OStream& operator<<(OStream& s, unsigned long long x) { std::printf("%llu", x); return s; }
42 
43 inline OStream& operator<<(OStream& s, long x) { std::printf("%ld", x); return s; }
44 inline OStream& operator<<(OStream& s, unsigned long x) { std::printf("%lu", x); return s; }
45 
46 inline OStream& operator<<(OStream& s, int x) { std::printf("%d", x); return s; }
47 inline OStream& operator<<(OStream& s, unsigned int x) { std::printf("%u", x); return s; }
48 
49 inline OStream& operator<<(OStream& s, short x) { return operator<<(s, static_cast<int>(x)); }
50 inline OStream& operator<<(OStream& s, unsigned short x) { return operator<<(s, static_cast<unsigned>(x)); }
51 
52 inline OStream& operator<<(OStream& s, long double x) { std::printf("%Lg", x); return s; }
53 inline OStream& operator<<(OStream& s, double x) { std::printf("%g", x); return s; }
54 inline OStream& operator<<(OStream& s, float x) { return operator<<(s, static_cast<double>(x)); }
55 
56 inline OStream& operator<<(OStream& s, char x) { std::printf("%c", x); return s; }
57 inline OStream& operator<<(OStream& s, const char* x) { std::printf("%s", x); return s; }
58 
59 inline OStream& operator<<(OStream& s, OStream&(*manip)(OStream&)) { return manip(s); }
60 
61 }
62 
63 #endif // UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED
stream
Definition: dsdl/test.py:6
OStream & operator<<(OStream &s, long long x)
Definition: ostream.hpp:40
static OStream & instance()
Definition: ostream.hpp:27
static OStream & endl(OStream &stream)
Definition: ostream.hpp:33


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39