Remove dynamic exceptions
[anna.git] / include / anna / diameter / helpers / tme / codectypes / Unsigned16.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_helpers_tme_codectypes_Unsigned16_hpp
10 #define anna_diameter_helpers_tme_codectypes_Unsigned16_hpp
11
12
13 // Local
14 #include <anna/diameter/codec/basetypes/OctetString.hpp>
15
16 #include <anna/config/defines.hpp>
17
18
19 namespace anna {
20
21 namespace diameter {
22
23 namespace codec {
24 class Avp;
25 }
26
27 namespace helpers {
28
29 namespace tme {
30
31 namespace codectypes {
32
33 /**
34 * Diameter Unsigned16 container
35 */
36 class Unsigned16 : codec::basetypes::OctetString {
37
38   U16 a_value;
39
40
41   // Only for derived diameter type:
42   void updateBasic() noexcept(false);
43   void setPrintableString(const char * printableString) noexcept(false);
44
45 public:
46
47
48   // Class-specific ////////////////////////////////////////////////////////////////////////////////////
49   //
50   /**
51   * Gets the Unsigned16 value
52   *
53   * @return Unsigned16 value
54   */
55   const U16& getValue() const { return a_value; }
56
57   /**
58   * Sets the Unsigned16 value
59   *
60   * @param value Unsigned16 value
61   */
62   void setValue(const U16& value) { a_value = value; updateBasic(); }
63   //
64   //////////////////////////////////////////////////////////////////////////////////////////////////////
65
66
67   // gets
68
69   std::string getFormatName() const { return "Unsigned16"; }
70
71
72   // helpers
73
74   std::string asPrintableString() noexcept(false) {
75     return anna::functions::asString(a_value);
76   }
77
78   std::string asString() noexcept(false) {
79     return asPrintableString();
80   }
81
82
83   // sets
84
85   void decode(const char* buffer, const int size) noexcept(false);
86
87
88   // exports /////////////////////////////
89   using AvpData::getSize;
90   using AvpData::code;
91   //using OctetString::asPrintableString;
92   using AvpData::asDataBlockString;
93   //using OctetString::asString;
94   using AvpData::asHexString;
95   //using OctetString::decode;
96   using AvpData::fromPrintableString;
97   using AvpData::fromHexString;
98 };
99
100 }
101 }
102 }
103 }
104 }
105
106 #endif