//============================================================================ /// <summary> /// Adds a scalar to an array or record. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aType">The basic type for this scalar.</param> /// <returns>A ref to the newly created scalar.</returns> //============================================================================ public override TTypedValue addScalar(String sName, TBaseType aType) { TInitValue newScalar; TTypedValue result = null; if (FIsArray || FIsRecord) { newScalar = new TInitValue(sName, aType); if (isArray()) { // Arrays pass their default value and valid range down to their elements if (newScalar.getDefault() != null) { newScalar.getDefault().copyFrom(FDefault); } if (newScalar.getMin() != null) { newScalar.getMin().copyFrom(FMin); } if (newScalar.getMax() != null) { newScalar.getMax().copyFrom(FMax); } } addMember(newScalar); result = newScalar; } return(result); }
//============================================================================ /// <summary> /// Creates a one dimensional array of scalar items. /// </summary> /// <param name="sArrayName">Name of this array.</param> /// <param name="aBaseType">Set the base type of this array.</param> /// <param name="iNoElements">Create it with this number of elements.</param> //============================================================================ public TDDMLValue(String sArrayName, TBaseType aBaseType, int iNoElements) : base(sArrayName, aBaseType, iNoElements) { //required in this derived class //add array elements which are scalars addScalar("", aBaseType); //calls suitable virtual function setElementCount((uint)iNoElements); }
/// <summary> /// Get string converted from data /// </summary> public override void GetString(TBaseType trg, ref StringBuilder sb, string delimiter) { foreach (var tmp in Acc(trg)) { sb.Append(tmp.ToString()).Append(delimiter); } return; }
/// <summary> /// Get string converted from data /// </summary> public override void GetString(TBaseType trg, ref StringBuilder sb, string delimiter) { TMemType tmp = Acc(trg); foreach (var temp in _csv._accList) { temp.GetString(tmp, ref sb, delimiter); } return; }
//============================================================================ /// <summary> /// Creates a scalar of this iBaseType with sName. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">Base type of this scalar.</param> //============================================================================ public TInitValue(String sName, TBaseType aBaseType) : base(sName, aBaseType) { //FMax = null; //FMin = null; FDefault = null; FDescr = ""; //required in this derived class //create a scalar type of TTypedValue constructScalar(sName, aBaseType); //calls suitable virtual functions }
//============================================================================ /// <summary> /// Used to add a scalar to a record or array /// </summary> /// <param name="sName">Name of the scalar value.</param> /// <param name="aType">Use this type.</param> /// <returns>The scalar value added.</returns> //============================================================================ public override TTypedValue addScalar(String sName, TBaseType aType) { TSDMLValue newScalar; TTypedValue result = null; if (FIsArray || FIsRecord) { newScalar = new TSDMLValue(sName, aType); addMember(newScalar); result = newScalar; } return(result); }
/// <summary> /// Get string converted from data /// </summary> public override void GetString(TBaseType trg, ref StringBuilder sb, string delimiter) { TMemType[] tmp = _acc(trg); for (int i = 0; i < _csv.Count(); i++) { TMemType tmpp = _acc(trg)[i]; foreach (var tmpmember in _csv[i]._accList) { tmpmember.GetString(tmpp, ref sb, delimiter); } } return; }
public void testCreateMember() { TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvmdx); sqlparser.sqltext = "CREATE MEMBER CURRENTCUBE.Measures.[_Internet Current Quarter Sales Performance Status] \n" + "AS 'Case When IsEmpty(KpiValue(\"Internet Current Quarter Sales Performance\")) Then Null When KpiValue(\"Internet Current Quarter Sales Performance\") < 1 Then -1 When KpiValue(\"Internet Current Quarter Sales Performance\") >= 1 And KpiValue(\"Internet Current Quarter Sales Performance\") < 1.07 Then 0 Else 1 End', \n" + "ASSOCIATED_MEASURE_GROUP = 'Internet Sales';"; int i = sqlparser.parse(); Assert.IsTrue(i == 0); TMdxCreateMember createMember = (TMdxCreateMember)sqlparser.sqlstatements.get(0); TMdxWithMemberNode withMemberNode = createMember.Specification; string newQuery = "select " + TBaseType.getStringInsideLiteral(withMemberNode.ExprNode.ToString()) + " on 1 from t"; sqlparser.sqltext = newQuery; i = sqlparser.parse(); Assert.IsTrue(i == 0); //System.out.println(sqlparser.sqlstatements.get(0).sqlstatementtype); TMdxSelect select = (TMdxSelect)sqlparser.sqlstatements.get(0); TMdxAxisNode axisNode = select.Axes[0]; TMdxCaseNode caseNode = (TMdxCaseNode)axisNode.ExpNode; Assert.IsTrue(caseNode.WhenList.Count == 3); }
/// <summary> /// Add a scalar value. /// </summary> /// <param name="sName">Name</param> /// <param name="aType">Type</param> /// <returns></returns> public abstract TTypedValue addScalar(String sName, TBaseType aType);
//====================================================================== /// <summary> /// Contains common code used by the constructors to set the field values of this /// type when it is a scalar. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">The type for this scalar.</param> // N.Herrmann Apr 2002 //====================================================================== protected void constructScalar(String sName, TBaseType aBaseType) { FBaseType = aBaseType; FData = null; // FDataSize = 0; Name = sName; FIsScalar = true; FIsArray = false; FIsRecord = false; setUnits(""); createScalar(); //allocates memory and initialises }
//====================================================================== /// <summary> /// Loads the description of this typed value from the parsed xml text. /// Assume that parser.getDescription() has been called. /// </summary> // N.Herrmann Apr 2002 //====================================================================== protected void getDescription() { FName = parser.Name; FUnit = parser.Units; if (FBaseType == TBaseType.ITYPE_EMPTY) { FBaseType = TBaseType.ITYPE_DEF; if (parser.Kind.Length > 0) { while ((FBaseType > TBaseType.ITYPE_EMPTY) && (parser.Kind != sTYPECODES[(int)FBaseType])) FBaseType--; } } FIsScalar = parser.IsScalar; FIsArray = parser.IsArray; FIsRecord = parser.IsRecord; }
/// <summary> /// Get string converted from data /// </summary> public override void GetString(TBaseType trg, ref StringBuilder sb, string delimiter) { sb.Append((Acc(trg)).ToString()).Append(delimiter); return; }
public abstract void GetString(TBaseType trg, ref StringBuilder sb, string delimiter);
//============================================================================ /// <summary> /// The new member to add to this structure. /// </summary> /// <param name="typedValue">Typed value to copy.</param> // N.Herrmann Apr 2002 //============================================================================ protected void initTypeCopy(TTypedValue typedValue) { uint i; Name = typedValue.Name; FBaseType = typedValue.baseType(); FIsScalar = typedValue.isScalar(); FIsArray = typedValue.isArray(); FIsRecord = typedValue.isRecord(); setUnits(typedValue.units()); if (FIsScalar) { createScalar(); switch (FBaseType) { //For scalars, copy the value data. case TBaseType.ITYPE_INT1: //Data pertaining to arrays and records case TBaseType.ITYPE_INT2: // is ultimately stored in their case TBaseType.ITYPE_INT4: // constituent scalars case TBaseType.ITYPE_INT8: setValue(typedValue.asInt()); break; case TBaseType.ITYPE_SINGLE: setValue(typedValue.asSingle()); break; case TBaseType.ITYPE_DOUBLE: setValue(typedValue.asDouble()); break; case TBaseType.ITYPE_BOOL: setValue(typedValue.asBool()); break; case TBaseType.ITYPE_CHAR: case TBaseType.ITYPE_WCHAR: setValue(typedValue.asChar()); break; case TBaseType.ITYPE_STR: case TBaseType.ITYPE_WSTR: setValue(typedValue.asStr()); break; } } else if (FIsArray || FIsRecord) { uint iCount = typedValue.count(); if (FIsArray && (iCount == 0)) { if (typedValue.item(0) != null) newMember(typedValue.item(0)); setElementCount(0); } else for (i = 1; i <= iCount; i++) newMember(typedValue.item(i)); //clones and adds this typed value } }
//============================================================================ /// <summary> /// Creates a scalar of this aBaseType with sName. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">Base type of this scalar.</param> //============================================================================ public TDDMLValue(String sName, TBaseType aBaseType) : base(sName, aBaseType) { //required in this derived class //create a scalar type of TTypedValue constructScalar(sName, aBaseType); //calls suitable virtual functions }
//============================================================================ /// <summary> /// Used to add a scalar to a record or array /// </summary> /// <param name="sName">Name of the scalar value.</param> /// <param name="aType">Use this type.</param> /// <returns>The scalar value added.</returns> //============================================================================ public override TTypedValue addScalar(String sName, TBaseType aType) { TSDMLValue newScalar; TTypedValue result = null; if (FIsArray || FIsRecord) { newScalar = new TSDMLValue(sName, aType); addMember(newScalar); result = newScalar; } return result; }
//====================================================================== /// <summary> /// Do the parsing of this type. If it is a structured type, then it will /// attempt to find all the children. Called during the construction process. /// </summary> // N.Herrmann Apr 2002 //====================================================================== protected void parseType() { if (FIsScalar) //decide here if this is a scalar and whether to get fields createScalar(); else getFldElemList(); //get the fields/elements if ((FBaseType == TBaseType.ITYPE_EMPTY) && FIsArray) { FBaseType = findArrayType(this); //retrieve base type from a child } else if ((FBaseType == TBaseType.ITYPE_DEF) && !FIsArray) { FIsRecord = true; } }
//============================================================================ /// <summary> /// Creates a one dimensional array of scalar items. /// </summary> /// <param name="sArrayName">Name of this array.</param> /// <param name="aBaseType">Set the base type of this array.</param> /// <param name="iNoElements">Create it with this number of elements.</param> //============================================================================ public TSDMLValue(String sArrayName, TBaseType aBaseType, int iNoElements) : base (sArrayName, aBaseType, iNoElements) { //required in this derived class //add array elements which are scalars addScalar("", aBaseType); //calls suitable virtual function setElementCount((uint)iNoElements); }
//Common code for the constructors //Some of these functions call virtual functions, so they are called //in the derived classes. //====================================================================== /// <summary> /// Sets the FBaseType class type. /// </summary> /// <param name="sBaseType">The base type string. See <see cref="sTYPECODES"/></param> // N.Herrmann Apr 2002 //====================================================================== protected void setBaseType(String sBaseType) { if (sBaseType != null && (sBaseType.Length > 0)) { FBaseType = TBaseType.ITYPE_DEF; while ((FBaseType > TBaseType.ITYPE_EMPTY) && (sBaseType != sTYPECODES[(int)FBaseType])) FBaseType--; } else FBaseType = TBaseType.ITYPE_EMPTY; }
//============================================================================ /// <summary> /// Copy constructor. This constructor makes a copy of the source's structure. /// For specialised child classes, this constructor should be overriden. /// </summary> /// <param name="typedValue">Use this typed value as the source.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(TTypedValue typedValue) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = typedValue.FBaseType; FData = null; FDataSize = 0; parser = null; //won't be using a parser here childTemplate = null; FUnit = ""; //Called in the derived classes because it calls virtual functions //initTypeCopy(typedValue) }
//============================================================================ /// <summary> /// Creates a 1-dimensional array of arbitrary type /// baseValue is used as a blue print only. /// </summary> /// <param name="arrayName">Name of the array.</param> /// <param name="baseValue">Blue print typed value.</param> /// <param name="noElements">Number of elements for the array.</param> //============================================================================ public TTypedValue(String arrayName, TTypedValue baseValue, int noElements) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = baseValue.FBaseType; parser = null; FData = null; FDataSize = 0; childTemplate = null; FUnit = ""; }
//============================================================================ /// <summary> /// Creates a one dimensional array of scalar items. /// </summary> /// <param name="sArrayName">Name of this array.</param> /// <param name="aBaseType">Set the base type of this array.</param> /// <param name="iNoElements">Create it with this number of elements.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(String sArrayName, TBaseType aBaseType, int iNoElements) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = aBaseType; parser = null; FData = null; FDataSize = 0; childTemplate = null; Name = sArrayName; FUnit = ""; FIsScalar = false; FIsArray = true; FIsRecord = false; //Called in the derived classes because they call virtual functions //addScalar("", iBaseType); //calls suitable virtual function //setElementCount(iNoElements); }
//============================================================================ /// <summary> /// Creates a scalar of this aBaseType with sName. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">Base type of this scalar.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(String sName, TBaseType aBaseType) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = aBaseType; //Called in the derived classes because it calls virtual functions //constructScalar(szName, iBaseType); //create a scalar type of TTypedValue parser = null; childTemplate = null; FUnit = ""; }
//============================================================================ /// <summary> /// Creates a scalar of this aBaseType with szName. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">Base type of this scalar.</param> /// <seealso cref="TTypedValue">TTypedValue Class</seealso> //============================================================================ public TSDMLValue(String sName, TBaseType aBaseType) : base (sName, aBaseType) { //required in this derived class //create a scalar type of TTypedValue constructScalar(sName, aBaseType); //calls suitable virtual functions }
public Field(string name, TBaseType value) { Name = name; Value = value; }