b851058d2a92f9aa86d7c890a8417ee5d0d605e9
[anna.git] / include / anna / diameter / codec / basetypes / Float64.hpp
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 #ifndef anna_diameter_codec_basetypes_Float64_hpp
10 #define anna_diameter_codec_basetypes_Float64_hpp
11
12
13 // Local
14 #include <anna/diameter/codec/basetypes/AvpData.hpp>
15
16 #include <anna/config/defines.hpp>
17
18 #include <anna/comm/functions.hpp>
19
20 namespace anna {
21
22 namespace diameter {
23
24 namespace codec {
25
26 class Avp;
27
28 namespace basetypes {
29
30 /**
31 * Diameter Float64 container
32 */
33 class Float64 : public AvpData {
34
35   F64 a_value;
36
37
38   // Mandatory for basic diameter type:
39   void codeBasic(char* buffer, int &size) throw(anna::RuntimeException);
40   void setPrintableString(const char * printableString) throw(anna::RuntimeException);
41
42 public:
43
44
45   // Class-specific ////////////////////////////////////////////////////////////////////////////////////
46   //
47   /**
48   * Gets the Float64 value
49   *
50   * @return Float64 value
51   */
52   const F64& getValue() const throw() { return a_value; }
53
54   /**
55   * Sets the Float64 value
56   *
57   * @param value Float64 value
58   */
59   void setValue(const F64& value) throw() { a_value = value; }
60   //
61   //////////////////////////////////////////////////////////////////////////////////////////////////////
62
63
64   // gets
65
66   virtual std::string getFormatName() const throw() { return "Float64"; }
67   virtual int getSize() const throw() { return 8; }
68
69
70   // helpers
71
72   std::string asPrintableString() throw(anna::RuntimeException) {
73     return anna::functions::asString(a_value);
74   }
75
76   std::string asString() throw(anna::RuntimeException) {
77     return asPrintableString();
78   }
79
80
81   // sets
82
83   void decode(const char* buffer, const int size) throw(anna::RuntimeException);
84 };
85
86 }
87 }
88 }
89 }
90
91 #endif