56 #ifndef LIB_TIME_DIGXEL_H 57 #define LIB_TIME_DIGXEL_H 63 #include <boost/operators.hpp> 64 #include <boost/lexical_cast.hpp> 79 using boost::lexical_cast;
89 template<
typename NUM,
size_t len>
92 enum{ bufsiz = len+1 };
94 char printbuffer_[bufsiz];
105 void clear() { printbuffer_[0] =
'\0'; }
106 bool empty() {
return '\0' == *printbuffer_; }
119 size_t space = std::snprintf (printbuffer_, bufsiz, formatSpec_, val);
120 REQUIRE (space < bufsiz,
"Digxel value exceeded available buffer size. " 121 "For showing %s, %zu+1 chars instead of just %zu+1 would be required." 122 ,
cStr(lexical_cast<string>(val)), space, len);
134 template<
typename NUM>
180 size_t maxlen()
const {
return 1; }
181 CBuf show (
int val) {
return val<0?
"-":
" "; }
192 using std::placeholders::_1;
214 template<
typename NUM
218 :
public boost::totally_ordered<Digxel<NUM,FMT>>
225 typedef function<void(NUM)> _Mutator;
241 template<
typename FUN,
class THIS>
245 mutator = bind (mutate, &
self, _1 );
257 operator NUM()
const {
return value_; }
258 operator string()
const {
return show(); }
260 size_t maxlen()
const {
return buffer_.maxlen(); }
266 return buffer_.show (value_);
273 if (n == value_)
return;
281 setValueRaw (NUM newVal)
283 if (newVal != value_)
293 Digxel& operator+= (NUM inc) { *
this = value_ + inc;
return *
this; }
294 Digxel& operator-= (NUM dec) { *
this = value_ - dec;
return *
this; }
295 Digxel& operator++ () { *
this = value_ + 1;
return *
this; }
296 Digxel& operator-- () { *
this = value_ - 1;
return *
this; }
297 NUM operator++ (
int) { NUM p(value_); *
this =p+1;
return p;}
298 NUM operator-- (
int) { NUM p(value_); *
this =p-1;
return p;}
301 bool operator< (
Digxel const& o)
const {
return value_ < NUM(o); }
319 :
public Digxel<int,digxel::SignFormatter>
326 setValueRaw (val<0? -1:+1);
333 installMutator (&Signum::storeSign, *
this);
336 using _Par::operator=;
338 friend int operator*= (
Signum& s,
int c) { s = c*s;
return s; }
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
void installMutator(FUN mutate, THIS &self)
install an external functor to be applied on any new digxel value.
inline string literal This is a marker type to indicate that
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
Implementation namespace for support and library code.
Marker types to indicate a literal string and a Symbol.
_Mutator mutator
Functor for setting a new digxel value.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A number element for building structured numeric displays.
Lumiera error handling (C++ interface).
special Digxel to show a sign.
int64_t FrameCnt
relative framecount or frame number.