1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
10 #include <anna/diameter/helpers/tme/codectypes/Unsigned16.hpp>
13 //------------------------------------------------------------------------------
14 //---------------------------------------------------- Unsigned16::updateBasic()
15 //------------------------------------------------------------------------------
16 void anna::diameter::helpers::tme::codectypes::Unsigned16::updateBasic() noexcept(false) {
18 result += (char)(a_value >> 8);
19 result += (char)a_value;
20 OctetString::setValue(result);
24 //------------------------------------------------------------------------------
25 //--------------------------------------------- Unsigned16::setPrintableString()
26 //------------------------------------------------------------------------------
27 void anna::diameter::helpers::tme::codectypes::Unsigned16::setPrintableString(const char * printableString) noexcept(false) {
28 setValue(atoi(printableString));
32 //------------------------------------------------------------------------------
33 //--------------------------------------------------------- Unsigned16::decode()
34 //------------------------------------------------------------------------------
35 void anna::diameter::helpers::tme::codectypes::Unsigned16::decode(const char* buffer, const int size) noexcept(false) {
37 throw anna::RuntimeException("Unsigned16::decode | Null Buffer provided", ANNA_FILE_LOCATION);
40 throw anna::RuntimeException("Unsigned16::decode | Buffer length must be 2 bytes", ANNA_FILE_LOCATION);
42 a_value = (((U16)buffer[0] << 8) & 0xFF00) +
43 ((U16)buffer[1] & 0x00FF);
44 // Base class decode()
45 OctetString::decode(buffer, size);