PStack  2.0
Stack trace printer for MSVC and GCC binaries
iomanip.hpp
Go to the documentation of this file.
1 // ===-- include/psystem/framework/iomanip.hpp ------------ -*- C++ -*- --=== //
2 // Copyright (c) 2014 Matt Bisson. All rights reserved.
3 
18 #pragma once
19 #ifndef PSYSTEM_FRAMEWORK_IOMANIP_HPP
20 #define PSYSTEM_FRAMEWORK_IOMANIP_HPP
21 
22 #include "platform.hpp"
23 #include <iostream>
24 #include <iomanip>
25 
26 #include "stack_allocated.hpp"
27 
28 namespace psystem {
29 
68 namespace format {
69 
71 namespace internal {
72 
73 } // namespace internal
74 } // namespace format
75 } // namespace psystem
76 
77 namespace psystem {
78 namespace format {
79 
83 
84 namespace internal {
85 
96 template <typename T>
98 {
99  static_assert(
100  std::is_integral<T>::value,
101  "Mask ostream output must be an integral type.");
102 
103  T value;
104 
106  static void operator delete (void*) = delete;
107  static void operator delete[](void*) = delete;
108  static void *operator new (size_t) = delete;
109  static void *operator new[] (size_t) = delete;
111 };
112 
113 } // namespace internal
114 
137 template <typename T>
139 mask(T const m) noexcept
140 {
142 }
143 
147 
149 namespace internal {
150 
161 template <typename T>
163 {
164  static_assert(
165  std::is_integral<T>::value,
166  "Hex ostream output must be an integral type.");
167 
168  T value;
169 
171  static void operator delete (void*) = delete;
172  static void operator delete[](void*) = delete;
173  static void *operator new (size_t) = delete;
174  static void *operator new[] (size_t) = delete;
176 };
177 
178 } // internal
179 
201 template <typename T>
203 hex(T const v) noexcept
204 {
206 }
207 
211 
212 namespace internal {
213 
224 {
225  void const *value;
226 
228  static void operator delete (void*) = delete;
229  static void operator delete[](void*) = delete;
230  static void *operator new (size_t) = delete;
231  static void *operator new[] (size_t) = delete;
233 };
234 
235 }
236 
259 ptr(void const *p) noexcept
260 {
262 }
263 
285 inline internal::ptr_ostream_output_tag
287 {
288  return internal::ptr_ostream_output_tag{reinterpret_cast<void*>(p)};
289 }
290 
323 template <typename R, typename... Args>
325 ptr(R(*p)(Args...)) noexcept
326 {
327  return internal::ptr_ostream_output_tag{reinterpret_cast<void*>(p)};
328 }
329 
333 
334 namespace internal {
335 
350 {
351  bool value;
352 
354  static void operator delete (void*) = delete;
355  static void operator delete[](void*) = delete;
356  static void *operator new (size_t) = delete;
357  static void *operator new[] (size_t) = delete;
359 };
360 
361 } // namespace internal
362 
384 swtch(bool const s) noexcept
385 {
387 }
388 
390 
391 } // namespace format
392 } // namespace psystem
393 
401 inline std::ostream&
403  std::ostream& out,
405 {
406  return out << ((v.value) ? "on" : "off");
407 }
408 
417 template <typename T>
418 inline std::ostream&
420  std::ostream& out,
422 {
423  return out << "0x" << std::hex << v.value << std::dec;
424 }
425 
434 template <typename T>
435 inline std::ostream&
437  std::ostream& out,
439 {
440  return out
441  << "(0x"
442  << std::setfill('0') << std::setw(sizeof(T)*2) << std::hex << m.value
443  << std::setfill(' ') << std::dec
444  << ')';
445 }
446 
454 inline std::ostream&
456  std::ostream& out,
458 {
459  return out
460  << "0x"
461  << std::setfill('0') << std::setw(sizeof(void*)*2) << std::hex
462  << reinterpret_cast<psystem::integral_address_t>(p.value)
463  << std::setfill(' ') << std::dec;
464 }
465 
466 #endif // PSYSTEM_FRAMEWORK_IOMANIP_HPP
std::ostream & operator<<(std::ostream &out, psystem::format::internal::swtch_ostream_output_tag &&v)
Free function to format boolean values for std::ostream.
Definition: iomanip.hpp:402
Master header file for Platform-wide declarations.
internal::hex_ostream_output_tag< T > hex(T const v) noexcept
Mark output stream data to be formatted as a hexadecimal number.
Definition: iomanip.hpp:203
internal::ptr_ostream_output_tag ptr(void const *p) noexcept
Mark output stream data to be formatted as a memory address.
Definition: iomanip.hpp:259
Internal, intermediate result of the mask() function.
Definition: iomanip.hpp:349
void const * value
The value to output.
Definition: iomanip.hpp:225
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
Internal, intermediate result of the mask() function.
Definition: iomanip.hpp:97
std::uintptr_t address_t
Container type for a memory address.
Definition: platform.hpp:221
Internal, intermediate result of the ptr() function.
Definition: iomanip.hpp:223
T value
The value to output.
Definition: iomanip.hpp:101
bool value
The value to output.
Definition: iomanip.hpp:351
internal::swtch_ostream_output_tag swtch(bool const s) noexcept
Mark output stream data to be formatted as an on/off switch.
Definition: iomanip.hpp:384
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
std::ptrdiff_t integral_address_t
A memory address as an integer type (platform specific).
Definition: platform.hpp:228
Internal, intermediate result of the psystem::format::hex() function.
Definition: iomanip.hpp:162
T value
The value to output.
Definition: iomanip.hpp:166
Defines the psystem::stack_allocated interface.
internal::mask_ostream_output_tag< T > mask(T const m) noexcept
Mark output stream data to be formatted as a bit-mask.
Definition: iomanip.hpp:139