diff options
| author | jhurst <jhurst@cinecert.com> | 2015-11-10 19:40:55 +0000 |
|---|---|---|
| committer | jhurst <> | 2015-11-10 19:40:55 +0000 |
| commit | 02915821cfb49cb6851086f5d991cee58328102b (patch) | |
| tree | c71cb099421c6ecf71a5a5ac469ba5e7fcfc413d /src/KM_util.cpp | |
| parent | f758bec505d45084d2563f20514ab4a81b27283a (diff) | |
release
Diffstat (limited to 'src/KM_util.cpp')
| -rwxr-xr-x | src/KM_util.cpp | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/src/KM_util.cpp b/src/KM_util.cpp index 2ccf9e9..d263d6e 100755 --- a/src/KM_util.cpp +++ b/src/KM_util.cpp @@ -129,10 +129,10 @@ Kumu::Result_t::Get(unsigned int i) } // -Kumu::Result_t::Result_t(int v, const char* s, const char* l) : value(v), symbol(s), label(l) +Kumu::Result_t::Result_t(int v, const std::string& s, const std::string& l) : value(v), symbol(s), label(l) { - assert(l); - assert(s); + assert(!l.empty()); + assert(!s.empty()); if ( v == 0 ) return; @@ -162,8 +162,65 @@ Kumu::Result_t::Result_t(int v, const char* s, const char* l) : value(v), symbol return; } + +Kumu::Result_t::Result_t(const Result_t& rhs) +{ + value = rhs.value; + symbol = rhs.symbol; + label = rhs.label; + message = rhs.message; +} + Kumu::Result_t::~Result_t() {} +// +const Kumu::Result_t& +Kumu::Result_t::operator=(const Result_t& rhs) +{ + value = rhs.value; + symbol = rhs.symbol; + label = rhs.label; + message = rhs.message; + return *this; +} + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const std::string& message) const +{ + Result_t result = *this; + result.message = message; + return result; +} + +static int const MESSAGE_BUF_MAX = 2048; + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const int& line, const char* filename) const +{ + assert(filename); + char buf[MESSAGE_BUF_MAX]; + snprintf(buf, MESSAGE_BUF_MAX-1, "%s, line %d", filename, line); + + Result_t result = *this; + result.message = buf; + return result; +} + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const std::string& message, const int& line, const char* filename) const +{ + assert(filename); + char buf[MESSAGE_BUF_MAX]; + snprintf(buf, MESSAGE_BUF_MAX-1, "%s, line %d", filename, line); + + Result_t result = *this; + result.message = message + buf; + return result; +} + //------------------------------------------------------------------------------------------ // DTrace internals |
