-// ANNA - Anna is Not 'N' Anymore
+// ANNA - Anna is Not Nothingness Anymore
//
// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
//
-// https://bitbucket.org/testillano/anna
+// 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
// 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 Google Inc. nor the names of its
+// * 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.
//
return anna::xml::Compiler().apply(asXML(&root));
}
-
-/////////////////////
-// FORMAT-SPECIFIC //
-/////////////////////
-
-
-//------------------------------------------------------------------------------
-//---------------------------------------------------- Avp::initializeByFormat()
-//------------------------------------------------------------------------------
-void Avp::initializeByFormat() throw() {
- a_ISDNNumber = NULL;
- a_ISDNAddress = NULL;
- a_Unsigned16 = NULL;
-}
-
-
-//------------------------------------------------------------------------------
-//--------------------------------------------------------- Avp::clearByFormat()
-//------------------------------------------------------------------------------
-void Avp::clearByFormat() throw() {
- delete a_ISDNNumber;
- delete a_ISDNAddress;
- delete a_Unsigned16;
-}
-
-
-//------------------------------------------------------------------------------
-//---------------------------------------------------- Avp::allocationByFormat()
-//------------------------------------------------------------------------------
-void Avp::allocationByFormat(const stack::Format *stackFormat) throw() {
- if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber = new ISDNNumber();
- else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress = new ISDNAddress();
- else if(stackFormat->getName() == "Unsigned16") a_Unsigned16 = new Unsigned16();
-}
-
-
-//------------------------------------------------------------------------------
-//----------------------------------------------------- Avp::getLengthByFormat()
-//------------------------------------------------------------------------------
-U24 Avp::getLengthByFormat(const stack::Format *stackFormat) const throw() {
- U24 result = 0;
-
- if(stackFormat->getName() == "ISDNNumber") result += a_ISDNNumber->getSize();
- else if(stackFormat->getName() == "ISDNAddress") result += a_ISDNAddress->getSize();
- else if(stackFormat->getName() == "Unsigned16") result += a_Unsigned16->getSize();
-
- return result;
-}
-
-
-//------------------------------------------------------------------------------
-//------------------------------------------------ Avp::decodeDataPartByFormat()
-//------------------------------------------------------------------------------
-void Avp::decodeDataPartByFormat(const char * buffer, int size, const stack::Format *stackFormat) throw(anna::RuntimeException) {
- if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber->decode(buffer, size);
- else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress->decode(buffer, size);
- else if(stackFormat->getName() == "Unsigned16") a_Unsigned16->decode(buffer, size);
-}
-
-
-//------------------------------------------------------------------------------
-//---------------------------------------------------------- Avp::codeByFormat()
-//------------------------------------------------------------------------------
-void Avp::codeByFormat(char* dataPart, const stack::Format *stackFormat) const throw(anna::RuntimeException) {
- int dataBytes;
-
- if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber->code(dataPart, dataBytes);
- else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress->code(dataPart, dataBytes);
- else if(stackFormat->getName() == "Unsigned16") a_Unsigned16->code(dataPart, dataBytes);
-}
-
-
-//------------------------------------------------------------------------------
-//---------------------------------------------------- Avp::getXMLdataByFormat()
-//------------------------------------------------------------------------------
-std::string Avp::getXMLdataByFormat(bool & isHex, const stack::Format *stackFormat) const throw() {
- std::string result;
-
- if(stackFormat->getName() == "ISDNNumber") {
- isHex = true;
- return a_ISDNNumber->asHexString();
- } else if(stackFormat->getName() == "ISDNAddress") {
- isHex = true;
- return a_ISDNAddress->asHexString();
- } else if(stackFormat->getName() == "Unsigned16") return a_Unsigned16->asPrintableString();
-
- return result;
-}
-
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------- Avp::fromXMLByFormat()
-//------------------------------------------------------------------------------
-void Avp::fromXMLByFormat(const anna::xml::Attribute* data, const anna::xml::Attribute* hexData, const stack::Format *stackFormat) throw(anna::RuntimeException) {
- if(stackFormat->getName() == "ISDNNumber") {
- if(data) a_ISDNNumber->fromPrintableString(data->getValue().c_str());
- else if(hexData) a_ISDNNumber->fromHexString(hexData->getValue());
- } else if(stackFormat->getName() == "ISDNAddress") {
- if(data) a_ISDNAddress->fromPrintableString(data->getValue().c_str());
- else if(hexData) a_ISDNAddress->fromHexString(hexData->getValue());
- } else if(stackFormat->getName() == "Unsigned16") {
- if(data) a_Unsigned16->fromPrintableString(data->getValue().c_str());
- else if(hexData) a_Unsigned16->fromHexString(hexData->getValue());
- }
-}
-