X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2FAvp.cpp;h=34b124023ca882016efeebfb2157b66a0c31ded4;hb=3e258840b15577cb8bda3cdedd0b9b88e16404b3;hp=59cc6d76a9b0c6f3452d779304af256c1fb44934;hpb=4e12ac57e93c052f716a6305ad8fc099c45899d1;p=anna.git diff --git a/source/diameter/codec/Avp.cpp b/source/diameter/codec/Avp.cpp index 59cc6d7..34b1240 100644 --- a/source/diameter/codec/Avp.cpp +++ b/source/diameter/codec/Avp.cpp @@ -1,4 +1,4 @@ -// ANNA - Anna is Not 'N' Anymore +// ANNA - Anna is Not Nothingness Anymore // // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo // @@ -1579,109 +1579,3 @@ std::string Avp::asXMLString() const throw() { 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()); - } -} -