ANNA Suite  2020b
Multipurpose development suite for Telco applications
Format.hpp
Go to the documentation of this file.
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_Format_hpp
10 #define anna_diameter_codec_Format_hpp
11 
12 
15 
16 // STL
17 #include <string>
18 
19 
20 namespace anna {
21 
22 namespace diameter {
23 
24 namespace codec {
25 
29 struct Format {
30  enum _v {
31  None = -1, // Initialized
32 
33 // Reserved
34  Unknown, // Unregistered at diameter dictionary
35  Any, // used on generic AVP
36 // RFC 3588
37  OctetString, // S8* n (possible zero-padding)
38  Integer32, // S32 4
39  Integer64, // S64 8
40  Unsigned32, // U32 4
41  Unsigned64, // U64 8
42  Float32, // F32 4
43  Float64, // F64 8
44  Grouped, // U32* 4*n
45  Address, // S8* 4 (IPv4) or 16 (IPv6)
46  Time, // S8* 4
47  UTF8String, // S8* n (possible zero-padding)
48  DiameterIdentity, // S8* n (possible zero-padding)
49  DiameterURI, // S8* n (possible zero-padding)
50  Enumerated, // S32 4
51  IPFilterRule, // S8* n (possible zero-padding)
52  QoSFilterRule // S8* n (possible zero-padding)
53  };
54 
56 
64  static const char* asText(const Format::_v v) noexcept(false) {
65  return asCString(v);
66  }
67 
68 
76  static bool isReserved(const std::string & formatName) {
77  if(formatName == asText(Format::Unknown)) return true;
78 
79  if(formatName == asText(Format::Any)) return true;
80 
81  return false;
82  }
83 
84 
90  static bool isRFC3588(const std::string & formatName) {
91  if(isReserved(formatName)) return false;
92 
93  return (asEnum(formatName) != None);
94  }
95 
96 };
97 
98 
99 }
100 }
101 }
102 
103 
104 #endif
105 
static const char * asText(const Format::_v v) noexcept(false)
Definition: Format.hpp:64
Definition: Format.hpp:29
static bool isRFC3588(const std::string &formatName)
Definition: Format.hpp:90
Definition: Format.hpp:35
_v
Definition: Format.hpp:30
Definition: Format.hpp:46
Definition: QoSFilterRule.hpp:30
static bool isReserved(const std::string &formatName)
Definition: Format.hpp:76
Definition: app.hpp:12
Definition: Format.hpp:31
anna_declare_enum(diameter::codec::Format)