New Batch Converter. Fix flags problem regarding may/shouldnot uncertainty
[anna.git] / source / diameter / codec / Message.cpp
index 4938a03..b374b90 100644 (file)
@@ -234,7 +234,7 @@ void Message::setApplicationId(U32 aid) throw() {
   a_applicationId = aid;
 
   // Default behaviour:
-  if (!getEngine()->selectStackWithApplicationId()) return;
+  if (!getEngine()->hasSelectStackWithApplicationId()) return;
 
   // Adapts for Application-ID stack identifier:
   getEngine()->setDictionary(aid);
@@ -345,10 +345,9 @@ void Message::decode(const anna::DataBlock &db, Message *ptrAnswer) throw(anna::
 
   U24 code = DECODE3BYTES_INDX_VALUETYPE(buffer, 5, U24);
 
-  // This is called before setId, and in general before any operation which needs to know about the stack elements.
-  setApplicationId(DECODE4BYTES_INDX_VALUETYPE(buffer, 8, U32)); // centralize set, because it could be used for stack selection.
+  a_id = CommandId(code, requestBit() /* based on a_flags */);
 
-  setId(CommandId(code, requestBit() /* based on a_flags */));
+  setApplicationId(DECODE4BYTES_INDX_VALUETYPE(buffer, 8, U32)); // centralize set, because it could be used for stack selection.
 
   a_hopByHop = DECODE4BYTES_INDX_VALUETYPE(buffer, 12, U32);
 
@@ -771,6 +770,9 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc
   int i_aux;
   unsigned int u_aux;
 
+  // Clear the message
+  clear();
+
   if(version) {
     i_aux = version->getIntegerValue();
 
@@ -784,8 +786,8 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc
   }
 
   // Application-id
-  // This is called before setId, and in general before any operation which needs to know about the stack elements.
-  setApplicationId(appid->getIntegerValue()); // this could set the dictionary...
+  // This is called before any operation which needs to know about the stack elements (this could set the dictionary)
+  setApplicationId(appid->getIntegerValue());
 
   // Dictionary
   const stack::Dictionary * dictionary = getEngine()->getDictionary();
@@ -816,7 +818,7 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc
       throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
     }
 
-    setId(stackCommand->getId());
+    setId(stackCommand->getId(), false /* don't clear */);
     // 'P', 'E' and 'T' flags:
     bool activateP = pbit ? (pbit->getValue() == "yes") : false;
     bool activateE = ebit ? (ebit->getValue() == "yes") : false;
@@ -867,7 +869,7 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc
     a_flags = i_aux;
     int flagsBCK = a_flags;
     // Final assignments
-    setId(CommandId(u_code, requestBit() /* based on a_flags */));
+    a_id = CommandId(u_code, requestBit() /* based on a_flags */);
     // Flags could have been updated regarding dictionary, but during parsing we must respect xml file:
     a_flags = flagsBCK;
   }