65 #ifndef LIB_TIME_DIGXEL_H 66 #define LIB_TIME_DIGXEL_H 72 #include <boost/operators.hpp> 73 #include <boost/lexical_cast.hpp> 88 using boost::lexical_cast;
98 template<
typename NUM,
size_t len>
101 enum{ bufsiz = len+1 };
103 char printbuffer_[bufsiz];
114 void clear() { printbuffer_[0] =
'\0'; }
115 bool empty() {
return '\0' == *printbuffer_; }
128 size_t space = std::snprintf (printbuffer_, bufsiz, formatSpec_, val);
129 REQUIRE (space < bufsiz,
"Digxel value exceeded available buffer size. " 130 "For showing %s, %zu+1 chars instead of just %zu+1 would be required." 131 ,
cStr(lexical_cast<string>(val)), space, len);
143 template<
typename NUM>
189 size_t maxlen()
const {
return 1; }
190 CBuf show (
int val) {
return val<0?
"-":
" "; }
201 using std::placeholders::_1;
223 template<
typename NUM
227 :
public boost::totally_ordered<Digxel<NUM,FMT>>
234 typedef function<void(NUM)> _Mutator;
250 template<
typename FUN,
class THIS>
254 mutator = bind (mutate, &
self, _1 );
266 operator NUM()
const {
return value_; }
267 operator string()
const {
return show(); }
269 size_t maxlen()
const {
return buffer_.maxlen(); }
275 return buffer_.show (value_);
282 if (n == value_)
return;
290 setValueRaw (NUM newVal)
292 if (newVal != value_)
302 Digxel& operator+= (NUM inc) { *
this = value_ + inc;
return *
this; }
303 Digxel& operator-= (NUM dec) { *
this = value_ - dec;
return *
this; }
304 Digxel& operator++ () { *
this = value_ + 1;
return *
this; }
305 Digxel& operator-- () { *
this = value_ - 1;
return *
this; }
306 NUM operator++ (
int) { NUM p(value_); *
this =p+1;
return p;}
307 NUM operator-- (
int) { NUM p(value_); *
this =p-1;
return p;}
310 bool operator< (
Digxel const& o)
const {
return value_ < NUM(o); }
328 :
public Digxel<int,digxel::SignFormatter>
335 setValueRaw (val<0? -1:+1);
342 installMutator (&Signum::storeSign, *
this);
345 using _Par::operator=;
347 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.