//======================================================================= /// <summary> /// Creates a driving property object using the XML describing the property. /// </summary> /// <param name="sXML">XML for the driving property containing the DDML type.</param> //======================================================================= public TCompDriver(String sXML) { TSDMLParser parser; XmlNode anode; String sBuf; sDescr = ""; sFullDescr = ""; parser = new TSDMLParser(sXML); anode = parser.firstElementChild(parser.rootNode(), "type"); initType = new TDDMLValue(parser, anode, ""); FName = parser.getAttrValue(parser.rootNode(), "name"); initType.Name = FName; sDescr = parser.getAttrValue(parser.rootNode(), "descr"); FMinConn = 1; // Default sBuf = parser.getAttrValue(parser.rootNode(), "minsrc"); if (sBuf.Trim().Length > 0) { FMinConn = Convert.ToInt32(sBuf); } FMaxConn = 1; // Default sBuf = parser.getAttrValue(parser.rootNode(), "maxsrc"); if (sBuf.Trim().Length > 0) { FMaxConn = Convert.ToInt32(sBuf); } anode = parser.firstElementChild(parser.rootNode(), "description"); if (anode != null) { sFullDescr = parser.getText(anode); } }
//========================================================================= /// <summary> /// Initialise the component's properties from the SDML init section. /// </summary> /// <param name="sdml">The SDML for the init section.</param> //========================================================================= public void setXML(string sdml) { XmlNode anode; TSDMLParser parser = new TSDMLParser(sdml); anode = parser.firstElementChild(parser.rootNode(), "init"); while (anode != null) { TSDMLValue sdmlVal = new TSDMLValue(parser, anode, ""); writeValue(sdmlVal.Name, sdmlVal); anode = parser.nextElementSibling(anode, "init"); } }
//======================================================================= /// <summary> /// Creates a component property from the XML description of a property. /// </summary> /// <param name="sXML">XML for the property containing the DDML type. e.g. /// <property name="name" access="read" init="F"> /// <type kind="string"><defval></defval> /// </type> /// </property> /// </param> //======================================================================= public TCompProperty(String sXML) { TSDMLParser parser; String access; XmlNode anode; //create a parser. (not very nice creating a second parser but....) parser = new TSDMLParser(sXML); anode = parser.firstElementChild(parser.rootNode(), "type"); InitValue = new TInitValue(parser, anode, ""); bRead = false; bWrite = false; bInit = false; sDescr = ""; sFullDescr = ""; Name = parser.getAttrValue(parser.rootNode(), "name"); InitValue.Name = Name; sDescr = parser.getAttrValue(parser.rootNode(), "descr"); access = parser.getAttrValue(parser.rootNode(), "access"); if (access == "both") { bRead = true; bWrite = true; } if ((access == "read") || (access.Length == 0)) { bRead = true; } if (access == "write") { bWrite = true; } if (parser.getAttrValue(parser.rootNode(), "init") == "T") { bInit = true; initialiseMembers(InitValue); } anode = parser.firstElementChild(parser.rootNode(), "description"); if (anode != null) { sFullDescr = parser.getText(anode); } }
//====================================================================== /// <summary> /// Uses the parents parser and the base node for this this type to build the /// type. Called by the descendant constructor. /// </summary> /// <param name="parentParser">Pointer to the parents parser.</param> /// <param name="baseNode">DOM Node to use as the root node.</param> // N.Herrmann Apr 2002 //====================================================================== protected void buildType(TSDMLParser parentParser, XmlNode baseNode) { XmlNode parentsNode; parser = parentParser; //use the parent's parser parentsNode = parentParser.rootNode(); //store parser.setTopNode(baseNode); parser.getDescription(); //gets the values from the dom into the parser fields getDescription(); //set the description fields from the parser parseType(); //do the parsing of this type parser = null; //has only been borrowed parentParser.setTopNode(parentsNode); //restore the topElement of the parser }