Salome HOME
Merge remote-tracking branch 'origin/master' into V9_dev
[modules/yacs.git] / src / engine / TypeCode.cxx
index 3000150b3ab9d83d745e7f7e84484c5d9f253135..f7c4774474b2a1a5575d51a67074d753ee8306ef 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -139,6 +139,11 @@ int TypeCode::isAdaptable(const TypeCode* tc) const
     }
 }
 
+std::string TypeCode::getPrintStr() const
+{
+  return id();
+}
+
 //! Check if this TypeCode can be used in place of tc
 /*!
  * this TypeCode is equivalent to tc if they have the same kind
@@ -200,6 +205,23 @@ const char *TypeCode::getKindRepr(DynType kind)
   return KIND_STR_REPR[(int)kind];
 }
 
+const TypeCode *TypeCode::subContentType(int lev) const
+{
+  if(lev<0)
+    throw YACS::Exception("subContentType: Invalid input val !");
+  if(lev==0)
+    return this;
+  const TypeCode *ret(this);
+  for(int i=0;i<lev;i++)
+    {
+      const TypeCode *cand(ret->contentType());
+      if(!cand)
+        throw YACS::Exception("subContentType : Invalid input val 2 !");
+      ret=cand;
+    }
+  return ret;
+}
+
 const char * TypeCode::getKindRepr() const
 {
   return KIND_STR_REPR[(int)_kind];
@@ -447,6 +469,12 @@ const char * TypeCodeSeq::shortName() const
   return _shortName.c_str();
 }
 
+std::string TypeCodeSeq::getPrintStr() const
+{
+  std::ostringstream oss; oss << "seq[" << contentType()->getPrintStr() << "]";
+  return oss.str();
+}
+
 const TypeCode * TypeCodeSeq::contentType() const throw(YACS::Exception)
 {
   return _content;