-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// http://redmine.teslayout.com/projects/anna-suite
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-// cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
#ifndef anna_diameter_codec_Avp_hpp
*/
std::string getXMLdata(bool & isHex, const anna::diameter::stack::Format *stackFormat) const throw();
- /**
- Interpret xml data in order to dump over the class content.
-
- \param avpNode Avp root node
- */
- void fromXML(const anna::xml::Node* avpNode) throw(anna::RuntimeException);
-
-
- /**
- Encodes buffer with the class content.
-
- * @param buffer Raw data to be encoded
- * @param size Size of raw data to be encoded
- */
- void code(char* buffer, int &size) const throw(anna::RuntimeException);
-
/**
Decodes Avp data part.
const Unknown * getUnknown() const throw(anna::RuntimeException) { assertFormat("Unknown"); return a_Unknown; }
+ /**
+ Decodes buffer provided over class content. If an error ocurred, decoding will stop launching exception (fatal error) or a warning trace (perhaps the achieved
+ avp is valid against all odds then validation will go on). In case that validation is enabled (codec::Engine::ValidationMode) an exception will be launched
+ depending on validation depth (codec::Engine::ValidationDepth).
+
+ Useful as serialization procedure with #code
+
+ @param db Buffer data block processed
+ */
+ void decode(const anna::DataBlock &db) throw(anna::RuntimeException);
+
+
+ /**
+ Interpret xml data in order to dump over the class content.
+
+ \param avpNode Avp root node
+ */
+ void fromXML(const anna::xml::Node* avpNode) throw(anna::RuntimeException);
+
+
+ /**
+ Encodes buffer with the class content. This method is internally used to encode diameter messages, but is declared as public, to allow
+ its use as serialization procedure. Then, it's assumed that this Avp is valid (validation shall be applied as part of a whole diameter
+ message but nothing will be verified now).
+
+ * @param buffer Raw data to be encoded (shall be externally allocated)
+ * @param size Size of raw data to be encoded
+ */
+ void code(char* buffer, int &size) const throw(anna::RuntimeException);
+
+
// Helpers
/**
*/
std::string asXMLString() const throw();
+ /**
+ Comparison operator by mean serialization
+
+ @param a1 Instance 1 for Avp class
+ @param a2 Instance 2 for Avp class
+
+ @return Comparison result
+ */
+ friend bool operator == (const Avp & a1, const Avp & a2) throw() { return (a1.asXMLString() == a2.asXMLString()); }
+
+ /**
+ Match a regular expression (string pattern) regarding xml string serialization for this avp.
+ This works same as #Message::isLike
+
+ @param pattern Pattern to match
+
+ \return Returns the match result
+ */
+ bool isLike(const std::string &pattern) const throw();
+
/**
Counts the number of ocurrences of Avps (first level) with the identifier provided