|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Observes whether any Rational had to be clamped while decoding inside this scope. More...
#include <rational.hpp>
Public Member Functions | |
| WireClampScope () noexcept | |
| Starts a fresh count, saving any enclosing scope's. | |
| WireClampScope (const WireClampScope &)=delete | |
| WireClampScope & | operator= (const WireClampScope &)=delete |
| WireClampScope (WireClampScope &&)=delete | |
| WireClampScope & | operator= (WireClampScope &&)=delete |
| ~WireClampScope () | |
| Folds this scope's count back into the enclosing one. | |
| std::size_t | clamped () const noexcept |
| How many Rational values were clamped so far in this scope. | |
Observes whether any Rational had to be clamped while decoding inside this scope.
Decoding a Rational cannot fail. setWire rebuilds through the canonicalising constructor, which clamps rather than rejects, so {"num":5,"den":0,"dp":2} becomes a perfectly plausible 5/1 and nothing downstream can tell the value was altered.
This makes that observable at the point where it matters – around a decode – without giving Rational an opinion about what should happen next. Whether a clamped value is a protocol violation to reject or a harmless normalisation depends on whether the caller is reading a trusted local value or an untrusted payload off a socket, and only the decoding layer knows which:
Thread-local and scoped: a decode is synchronous on one thread, and a nested decode must not steal its parent's count.
Definition at line 231 of file rational.hpp.
|
inlinenoexcept |
Starts a fresh count, saving any enclosing scope's.
Definition at line 234 of file rational.hpp.
|
inline |
Folds this scope's count back into the enclosing one.
Definition at line 242 of file rational.hpp.
|
inlinenodiscardnoexcept |
How many Rational values were clamped so far in this scope.
Definition at line 246 of file rational.hpp.