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 //
9 #ifndef anna_diameter_codec_Format_hpp
10 #define anna_diameter_codec_Format_hpp
13 #include <anna/core/RuntimeException.hpp>
14 #include <anna/core/define.autoenum.hpp>
27 * Diameter RFC3588 Avp Data Format definition
31 None = -1, // Initialized
34 Unknown, // Unregistered at diameter dictionary
35 Any, // used on generic AVP
37 OctetString, // S8* n (possible zero-padding)
45 Address, // S8* 4 (IPv4) or 16 (IPv6)
47 UTF8String, // S8* n (possible zero-padding)
48 DiameterIdentity, // S8* n (possible zero-padding)
49 DiameterURI, // S8* n (possible zero-padding)
51 IPFilterRule, // S8* n (possible zero-padding)
52 QoSFilterRule // S8* n (possible zero-padding)
55 anna_declare_enum(diameter::codec::Format);
60 * @param v Format type
62 * @return Format description
64 static const char* asText(const Format::_v v) throw(anna::RuntimeException) {
70 * Boolean about if format type is reserved (API internal use)
72 * @param formatName Format text name
74 * @return Boolean 'true' if reserved for internal use, 'false' if is user format type (RFC 3588 or application-specific)
76 static bool isReserved(const std::string & formatName) {
77 if(formatName == asText(Format::Unknown)) return true;
79 if(formatName == asText(Format::Any)) return true;
86 * Boolean about if format type belongs to RFC 3588
87 * @param formatName Format text name
88 * @return Boolean 'true' if belongs to RFC 3588, 'false' if is application-specific)
90 static bool isRFC3588(const std::string & formatName) {
91 if(isReserved(formatName)) return false;
93 return (asEnum(formatName) != None);