Module: sems
Branch: master
Commit: ccdbae75ed715978362e9b2c01083c192c334c84
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=ccdbae75ed715978362e9b2c01083c192c334c84

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Sat Jun 19 17:23:03 2010 +0200

make varPrintArg usable from modules

varPrintArg() prints an AmArg variable into var (string) array,
useful for modules

---

 apps/dsm/DSMCall.cpp        |   25 -------------------------
 apps/dsm/DSMStateEngine.cpp |   27 +++++++++++++++++++++++++++
 apps/dsm/DSMStateEngine.h   |    2 ++
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/apps/dsm/DSMCall.cpp b/apps/dsm/DSMCall.cpp
index a58f78e..2ad8ebc 100644
--- a/apps/dsm/DSMCall.cpp
+++ b/apps/dsm/DSMCall.cpp
@@ -332,31 +332,6 @@ void DSMCall::onSipReply(const AmSipReply& reply, int 
old_dlg_status) {
   }
 }
 
-static void varPrintArg(const AmArg& a, map<string, string>& dst, const 
string& name) {
-  switch (a.getType()) {
-  case AmArg::Undef: dst[name] =  "null"; return;
-  case AmArg::Int: dst[name] =  a.asInt()<0 ? 
-      "-"+int2str(abs(a.asInt())):int2str(abs(a.asInt())); return;
-  case AmArg::Bool:
-     dst[name] = a.asBool()?"true":"false"; return;     
-  case AmArg::Double:
-    dst[name] = double2str(a.asDouble()); return;
-  case AmArg::CStr:
-    dst[name] = a.asCStr(); return;
-  case AmArg::Array:
-    for (size_t i = 0; i < a.size(); i ++)
-      varPrintArg(a.get(i), dst, name+"["+int2str(i)+"]");
-    return;
-  case AmArg::Struct:
-    for (AmArg::ValueStruct::const_iterator it = a.asStruct()->begin();
-        it != a.asStruct()->end(); it ++) {
-      varPrintArg(it->second, dst, name+"."+it->first);
-    }
-    return;
-  default: dst[name] = "<UNKONWN TYPE>"; return;
-  }
-}
-
 void DSMCall::process(AmEvent* event)
 {
 
diff --git a/apps/dsm/DSMStateEngine.cpp b/apps/dsm/DSMStateEngine.cpp
index b88b53d..82b11f5 100644
--- a/apps/dsm/DSMStateEngine.cpp
+++ b/apps/dsm/DSMStateEngine.cpp
@@ -465,3 +465,30 @@ DSMTransition::DSMTransition()
 DSMTransition::~DSMTransition(){
 }
 
+
+
+
+void varPrintArg(const AmArg& a, map<string, string>& dst, const string& name) 
{
+  switch (a.getType()) {
+  case AmArg::Undef: dst[name] =  "null"; return;
+  case AmArg::Int: dst[name] =  a.asInt()<0 ? 
+      "-"+int2str(abs(a.asInt())):int2str(abs(a.asInt())); return;
+  case AmArg::Bool:
+     dst[name] = a.asBool()?"true":"false"; return;     
+  case AmArg::Double:
+    dst[name] = double2str(a.asDouble()); return;
+  case AmArg::CStr:
+    dst[name] = a.asCStr(); return;
+  case AmArg::Array:
+    for (size_t i = 0; i < a.size(); i ++)
+      varPrintArg(a.get(i), dst, name+"["+int2str(i)+"]");
+    return;
+  case AmArg::Struct:
+    for (AmArg::ValueStruct::const_iterator it = a.asStruct()->begin();
+        it != a.asStruct()->end(); it ++) {
+      varPrintArg(it->second, dst, name+"."+it->first);
+    }
+    return;
+  default: dst[name] = "<UNKONWN TYPE>"; return;
+  }
+}
diff --git a/apps/dsm/DSMStateEngine.h b/apps/dsm/DSMStateEngine.h
index 636d616..e0882c2 100644
--- a/apps/dsm/DSMStateEngine.h
+++ b/apps/dsm/DSMStateEngine.h
@@ -29,6 +29,7 @@
 
 #include "DSMElemContainer.h"
 #include "AmSipMsg.h"
+#include "AmArg.h"
 
 class AmSession;
 class DSMSession;
@@ -235,5 +236,6 @@ class DSMStateEngine {
   bool onInvite(const AmSipRequest& req, DSMSession* sess);
 };
 
+extern void varPrintArg(const AmArg& a, map<string, string>& dst, const 
string& name);
 
 #endif

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to