MCPcopy Create free account
hub / github.com/Signalsmith-Audio/reverb-example-code / Result

Class Result

wav.h:45–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44public:
45 struct Result {
46 enum class Code {
47 OK = 0,
48 IO_ERROR,
49 FORMAT_ERROR,
50 UNSUPPORTED,
51 WEIRD_CONFIG
52 };
53 Code code = Code::OK;
54 std::string reason;
55
56 Result(Code code, std::string reason="") : code(code), reason(reason) {};
57 Result(const Result &other) : code(other.code), reason(other.reason) {};
58 Result & operator=(const Result &other) {
59 // TODO: what is this? Why do we only copy if it's _not_ OK?
60 if (code == Code::OK) {
61 code = other.code;
62 reason = other.reason;
63 }
64 return *this;
65 }
66 // Used to neatly test for success
67 explicit operator bool () const {
68 return code == Code::OK;
69 };
70 const Result & warn(std::ostream& output=std::cerr) const {
71 if (!(bool)*this) {
72 output << "WAV error: " << reason << std::endl;
73 }
74 return *this;
75 }
76 };
77
78 unsigned int sampleRate = 48000;
79 unsigned int channels = 1;

Callers 3

WavClass · 0.85
readMethod · 0.85
writeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected