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/codec/basetypes/Unsigned32.hpp>
13 //------------------------------------------------------------------------------
14 //------------------------------------------------------ Unsigned32::codeBasic()
15 //------------------------------------------------------------------------------
16 void anna::diameter::codec::basetypes::Unsigned32::codeBasic(char* buffer, int &size) throw(anna::RuntimeException) {
17 buffer[0] = (char)(a_value >> 24);
18 buffer[1] = (char)(a_value >> 16);
19 buffer[2] = (char)(a_value >> 8);
20 buffer[3] = (char)a_value;
25 //------------------------------------------------------------------------------
26 //--------------------------------------------- Unsigned32::setPrintableString()
27 //------------------------------------------------------------------------------
28 void anna::diameter::codec::basetypes::Unsigned32::setPrintableString(const char * printableString) throw(anna::RuntimeException) {
29 setValue(atoi(printableString));
33 //------------------------------------------------------------------------------
34 //--------------------------------------------------------- Unsigned32::decode()
35 //------------------------------------------------------------------------------
36 void anna::diameter::codec::basetypes::Unsigned32::decode(const char* buffer, const int size) throw(anna::RuntimeException) {
38 throw anna::RuntimeException("Unsigned32::decode | Null Buffer provided", ANNA_FILE_LOCATION);
41 throw anna::RuntimeException("Unsigned32::decode | Buffer length must be 4 bytes", ANNA_FILE_LOCATION);
43 a_value = (((U32)buffer[0] << 24) & 0xFF000000) +
44 (((U32)buffer[1] << 16) & 0x00FF0000) +
45 (((U32)buffer[2] << 8) & 0x0000FF00) +
46 ((U32)buffer[3] & 0x000000FF);