X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2FMessage.cpp;h=a686c71dcf33e327eaaa840ed7704395032f1f85;hb=26c27c2b83f99e6df420addc90010eb0d4a7724e;hp=31b7d14a6f2f67127d42ca327f9c5a8b2d372aec;hpb=8b8309d46e9ccc968d3a315e86e70c5a806706d0;p=anna.git diff --git a/source/diameter/codec/Message.cpp b/source/diameter/codec/Message.cpp index 31b7d14..a686c71 100644 --- a/source/diameter/codec/Message.cpp +++ b/source/diameter/codec/Message.cpp @@ -998,9 +998,16 @@ anna::xml::Node* Message::asXML(anna::xml::Node* parent) const throw() { //------------------------------------------------------------------------------ //------------------------------------------------------- Message::asXMLString() //------------------------------------------------------------------------------ -std::string Message::asXMLString() const throw() { +std::string Message::asXMLString(bool normalize) const throw() { anna::xml::Node root("root"); - return anna::xml::Compiler().apply(asXML(&root)); + + anna::xml::Compiler::Mode::_v mode = normalize ? anna::xml::Compiler::Mode::Sort : anna::xml::Compiler::Mode::Visual; + std::string result = anna::xml::Compiler().apply(asXML(&root), mode); + + if (normalize) + result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); + + return result; } @@ -1009,5 +1016,6 @@ std::string Message::asXMLString() const throw() { //------------------------------------------------------------------------------ bool Message::isLike(const std::string &pattern) const throw() { anna::RegularExpression re(pattern); - return re.isLike(asXMLString()); + return re.isLike(asXMLString(true /* normalize by mean sorting attribute names and removing new lines */)); } +