/prelude/geordi.hpp

http://github.com/Eelis/geordi · C++ Header · 53 lines · 42 code · 10 blank · 1 comment · 0 complexity · 2b1a43ac68ab8e43e329329a0e2162e7 MD5 · raw file

  1. #ifndef GEORDI_HPP
  2. #define GEORDI_HPP
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <string>
  6. #include <map>
  7. #include <iostream>
  8. #include <sys/utsname.h>
  9. namespace geordi
  10. {
  11. namespace
  12. {
  13. char const parsep[] = "\342\200\251";
  14. // UTF-8 encoding of PARAGRAPH SEPARATOR (U+2029). See "Output separators" in notes.txt.
  15. char const compiler_description[] =
  16. #ifdef __clang__
  17. "Clang " __clang_version__;
  18. #else
  19. "GCC " __VERSION__;
  20. #endif
  21. }
  22. struct error
  23. {
  24. error() { std::printf("%serror: ", parsep); }
  25. ~error() { std::abort(); }
  26. std::ostream & operator()() const { return std::cout; }
  27. };
  28. utsname uname();
  29. template <typename> struct is_character { enum { value = false }; };
  30. #define YES(T) template <> struct is_character<T> { enum { value = true }; };
  31. YES(char) YES(wchar_t)
  32. #if __cplusplus >= 201103
  33. YES(char16_t) YES(char32_t)
  34. #endif
  35. #undef YES
  36. char const * demangle(char const *);
  37. std::map<std::string, std::string> depersist();
  38. void persist(std::string key, std::string value);
  39. }
  40. std::ostream & operator<<(std::ostream &, wchar_t);
  41. std::ostream & operator<<(std::ostream &, wchar_t const *);
  42. std::ostream & operator<<(std::ostream &, std::wstring const &);
  43. #endif // header guard