xo-umbrella2/xo-indentlog/include/xo/indentlog/print/quoted_char.hpp
Roland Conybeare 966c3903e1 git subrepo clone git@github.com:Rconybea/xo-indentlog.git xo-indentlog
subrepo:
  subdir:   "xo-indentlog"
  merged:   "0834c6ad"
upstream:
  origin:   "git@github.com:Rconybea/xo-indentlog.git"
  branch:   "main"
  commit:   "0834c6ad"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 21:30:17 -04:00

43 lines
848 B
C++

/* @file quoted_char.hpp */
#pragma once
#include <iostream>
namespace xo {
template<typename CharT>
class quoted_char {
public:
quoted_char(CharT ch) : ch_{ch} {}
void print(std::ostream & os) const {
switch(ch_) {
case '\033':
os << "\\033";
break;
case '\n':
os << "\\n";
break;
case '\r':
os << "\\r";
break;
default:
os << ch_;
}
}
private:
CharT ch_;
}; /*quoted_char*/
template<typename CharT>
inline std::ostream &
operator<<(std::ostream & os, quoted_char<CharT> const & x) {
x.print(os);
return os;
} /*operator<<*/
} /*namespace xo*/
/* end quoted_char.hpp */