Ejemplo n.º 1
0
 public bool setValue(String str, DXType type)
 {
     Debug.Assert(str != null);
     return setValue(str, type.getType());
 }
Ejemplo n.º 2
0
        public static bool ParseMDFTypes(ref ParameterDefinition param, String p, int lineNumber)
        {
            DXType input_type;
            Regex reg = new Regex(" or ");
            p = reg.Replace(p, " | ");

            List<String> types = Utils.StringTokenizer(p, "|", new String[] { "" });
            DXTypeVals type;
            foreach (String str in types)
            {
                String sstr = str.Trim();
                type = DXType.StringToType(sstr);
                if (type == DXTypeVals.UndefinedType)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Erroneous parameter type encountered in line {0}.", lineNumber);
                    return false;
                }

                input_type = new DXType(type);
                bool r = param.addType(input_type);
                Debug.Assert(r);
            }
            return true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determines whether the specified string is a valid string value
 /// of the specified type (of DXType constant).
 /// </summary>
 /// <param name="str"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static bool IsValidValue(String str, DXType type)
 {
     Debug.Assert(str != null);
     return IsValidValue(str, type.getType());
 }
Ejemplo n.º 4
0
        public static bool IsValue(String str, ref DXTypeVals type)
        {
            int tuple = 0;

            if (str == null)
                return false;

            Regex r = new Regex(Scanning.Scanner.DoubleOnlyPattern);
            switch (type)
            {
                case DXTypeVals.ScalarType:
                    return r.IsMatch(str);
                    break;
                case DXTypeVals.VectorType:
                    return DXTensor.IsVector(str, ref tuple);
                    break;
                case DXTypeVals.TensorType:
                    return DXTensor.IsTensor(str);
                    break;
                default:
                    if (r.IsMatch(str))
                    {
                        type = DXTypeVals.ScalarType;
                        return true;
                    }
                    if (DXTensor.IsVector(str, ref tuple))
                    {
                        type = DXTypeVals.VectorType;
                        return true;
                    }
                    if (DXTensor.IsTensor(str))
                    {
                        type = DXTypeVals.TensorType;
                        return true;
                    }
                    break;
            }
            return false;
        }
        /// <summary>
        /// Remove (and free) the type in the list that matches t
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public bool removeType(DXType t)
        {
            if (typeStrings != null)
                typeStrings = null;

            foreach (DXType dxtype in types)
            {
                if (dxtype.getType() == t.getType())
                {
                    bool r = this.types.Remove(dxtype);
                    Debug.Assert(r);
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// Append the given type t to the list of acceptable types for this
        /// parameter definition.  The given type is then owned by the 
        /// ParameterDefinition and will be deleted when it is deleted.
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public bool addType(DXType t)
        {
            if (typeStrings != null)
                typeStrings = null;

            if (types == null)
                return false;

            types.Add(t);
            return true;
        }
Ejemplo n.º 7
0
 public DXType duplicate(DXType newt)
 {
     if (newt == null)
         newt = new DXType();
     newt = this;
     return newt;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns true if the source and destination types match; false otherwise.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="destination"></param>
 /// <returns></returns>
 public static bool MatchType(DXType source, DXType destination)
 {
     return MatchType(source.getType(), destination.getType());
 }
Ejemplo n.º 9
0
        public static bool Equals(DXType type1, DXType type2)
        {
            if (Object.Equals(type1, null) && Object.Equals(type2, null))
                return true;
            else if (Object.Equals(type1, null) || Object.Equals(type2, null))
                return false;

            return type1.type == type2.type;
        }