9#ifndef SQUID_SRC_BASE_IOMANIP_H
10#define SQUID_SRC_BASE_IOMANIP_H
49template <
class Po
inter>
71template <
class Po
inter>
79template <
class Po
inter>
87template <
class Po
inter>
110template <
class Integer>
118 static_assert(std::is_integral<Integer>::value || std::is_enum<Integer>::value);
141template <
class Integer>
145 const auto oldFlags = os.flags();
146 const auto oldFill = os.fill();
149 os << (*
number.forceCase ? std::uppercase : std::nouppercase);
151 if (
number.forcePadding) {
152 os.width(*
number.forcePadding);
160 os << std::hex << +
number.io_manip;
168template <
class Integer>
172void PrintHex(std::ostream &,
const char *data,
size_t n);
175template <
typename Container>
197 void print(std::ostream &)
const;
209template <
typename Container>
215 for (
const auto &item: container) {
232 if (opened && suffix)
236template <
typename Container>
240 manipulator.
print(os);
245template <
typename Container>
void PrintHex(std::ostream &, const char *data, size_t n)
Prints the first n data bytes using hex notation. Does nothing if n is 0.
std::ostream & operator<<(std::ostream &os, const RawPointerT< Pointer > &pd)
prints RawPointerT<>, dereferencing the io_manip pointer if possible
auto asList(const Container &c)
a helper to ease AsList object creation
RawPointerT< Pointer > RawPointer(const char *label, const Pointer &ptr)
convenience wrapper for creating RawPointerT<> objects
AsHex< Integer > asHex(const Integer n)
a helper to ease AsHex object creation
auto & minDigits(const size_t w)
std::optional< bool > forceCase
Print hex digits in upper (or, with a false parameter value, lower) case.
auto & upperCase(const bool u=true)
Print hex digits in upper (or, with a false parameter value, lower) case.
std::optional< size_t > forcePadding
Integer io_manip
the integer to print
std::ostream manipulator to print containers as flat lists
const char * suffix
a c-string to print after the last item (if any). Caller must ensure lifetime.
auto & prefixedBy(const char *const p)
a c-string to print before the first item (if any). Caller must ensure lifetime.
const Container & container
zero or more items to print
const char * delimiter
a c-string to print between consecutive items (if any). Caller must ensure lifetime.
auto & quoted(const char *const preQ, const char *const postQ)
c-strings to print before and after each item. Caller must ensure lifetime.
void print(std::ostream &) const
writes the container to the given stream
auto & delimitedBy(const char *const d)
a c-string to print between consecutive items (if any). Caller must ensure lifetime.
auto & quoted(const char *const q="\"")
c-string to print before and after each item. Caller must ensure lifetime.
const char * preQuote
optional c-string to print before each item;
const char * prefix
a c-string to print before the first item (if any). Caller must ensure lifetime.
AsList(const Container &c)
const char * postQuote
optional c-string to print after each item;
auto & suffixedBy(const char *const p)
a c-string to print after the last item (if any). Caller must ensure lifetime.
AtMostOnce(const T &t)
caller must ensure t lifetime extends to the last use of this AtMostOnce instance
void print(std::ostream &os)
static std::ostream & Extra(std::ostream &)
RawPointerT(const char *aLabel, const Pointer &aPtr)
bool onExtraLine
a possibly nil pointer to the being-debugged object
RawPointerT< Pointer > & orNil(const char *nilTextToUse="[nil]")
enable and, optionally, customize reporting of nil pointers
const char * nilText
the name or description of the being-debugged object
RawPointerT< Pointer > & asExtra()
Report the pointed-to-object on a dedicated Debug::Extra line.
static const char * delimiter