Remove dynamic exceptions
[anna.git] / source / diameter / codec / basetypes / Float32.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
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 //
7
8
9 // Local
10 #include <anna/diameter/codec/basetypes/Float32.hpp>
11
12
13 //------------------------------------------------------------------------------
14 //--------------------------------------------------------- Float32::codeBasic()
15 //------------------------------------------------------------------------------
16 void anna::diameter::codec::basetypes::Float32::codeBasic(char* buffer, int &size) noexcept(false) {
17   /*buffer=*/
18   anna::comm::functions::codeFloat(buffer, a_value);
19   size = getSize();
20 }
21
22
23 //------------------------------------------------------------------------------
24 //------------------------------------------------ Float32::setPrintableString()
25 //------------------------------------------------------------------------------
26 void anna::diameter::codec::basetypes::Float32::setPrintableString(const char * printableString) noexcept(false) {
27   setValue(atof(printableString));
28 }
29
30
31 //------------------------------------------------------------------------------
32 //------------------------------------------------------------ Float32::decode()
33 //------------------------------------------------------------------------------
34 void anna::diameter::codec::basetypes::Float32::decode(const char* buffer, const int size) noexcept(false) {
35   if(!buffer)
36     throw anna::RuntimeException("Float32::decode | Null Buffer provided", ANNA_FILE_LOCATION);
37
38   if(size != 4)
39     throw anna::RuntimeException("Float32::decode | Buffer length must be 4 bytes", ANNA_FILE_LOCATION);
40
41   a_value = anna::comm::functions::decodeFloat(buffer);
42 }
43