/**
         * @brief Load data from parameter into the form details.
         * @param a_param is the member to extract data from.
         * @param a_editMode is whether member is being modified or added.
         * @return void.
         * */
        public void Populate(CppMember a_param, bool a_editMode)
        {
            editMode = a_editMode;

            TXT_ParamName.Text = a_param.name;
            TXT_ParamType.Text = a_param.type;

            // Const status
            if (a_param.modifier == "CONST")
            {
                CB_ConstOpt.Checked = true;
            }

            // Memory type
            if (a_param.memType == "*")
            {
                RB_PointerOpt.Checked = true;
            }
            else if (a_param.memType == "&")
            {
                RB_ReferenceOpt.Checked = true;
            }
            else
            {
                RB_ValOpt.Checked = true;
            }

            // Change button text to reflect the mode of the form
            if (editMode)
            {
                BTN_ParamConfirm.Text = "Confirm Changes";
            }
        }
Exemple #2
0
        /**
         * @brief Load data from member into the form details.
         * @param a_member is the member to extract data from.
         * @param a_editMode is whether member is being modified or added.
         * @return void.
         * */
        public void Populate(CppMember a_member, bool a_editMode)
        {
            editMode = a_editMode;

            CB_MemberAccess.SelectedItem = a_member.access;
            CB_Identifiers.SelectedItem  = a_member.modifier;

            TXT_MemberName.Text = a_member.name;
            TXT_Type.Text       = a_member.type;

            // Memory type
            if (a_member.memType == "*")
            {
                RB_PointerOpt.Checked = true;
            }
            else if (a_member.memType == "&")
            {
                RB_ReferenceOpt.Checked = true;
            }
            else
            {
                RB_ValueOpt.Checked = true;
            }

            // Virtual
            if (a_member.isVirtual)
            {
                CheckBox_VirtualOpt.Checked = true;
            }

            // Function
            if (a_member.isFunction)
            {
                CheckBox_FunctionOpt.Checked = true;

                // Populate parameters (if any)
                foreach (var param in a_member.args)
                {
                    LV_Params.Items.Add(param.ToString());
                }
            }

            // Change button text to reflect the mode of the form
            if (editMode)
            {
                BTN_MemberConfirm.Text = "Confirm Changes";
            }
        }
Exemple #3
0
        private void loadXMLFile(string a_filePath)
        {
            using (XmlReader reader = XmlReader.Create(a_filePath))
            {
                // Refresh all data before loading new data
                RefreshClassData();

                // Read file line by line
                while (reader.Read())
                {
                    /// CLASS-SPECIFIC DATA
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Class")
                    {
                        // Prepare new class structure
                        CppClass newClass = new CppClass(reader.GetAttribute("name"),
                                                         (reader.GetAttribute("isVirtual") == "True" ? true : false), // Use ternary to convert string to bool
                                                         reader.GetAttribute("base_name"),
                                                         reader.GetAttribute("base_access"));

                        // Add to list of classes
                        classes.Add(newClass);

                        // Add string representation
                        LV_Classes.Items.Add(newClass.ToString());
                    }

                    /// MEMBER-SPECIFIC DATA
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Member")
                    {
                        // Prepare new member structure
                        CppMember newMember = new CppMember(reader.GetAttribute("access"),
                                                            reader.GetAttribute("modifier"),
                                                            reader.GetAttribute("type"),
                                                            reader.GetAttribute("name"),
                                                            reader.GetAttribute("memory_type"),
                                                            (reader.GetAttribute("isVirtual") == "True" ? true : false),
                                                            (reader.GetAttribute("isFunction") == "True" ? true : false));

                        // Add to current class
                        classes.Last().members.Add(newMember);
                    }

                    /// PARAMETER-SPECIFIC DATA
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Parameter")
                    {
                        // Prepare new parameter structure
                        CppMember newParam = new CppMember("",
                                                           reader.GetAttribute("const_status"),
                                                           reader.GetAttribute("type"),
                                                           reader.GetAttribute("name"),
                                                           reader.GetAttribute("memory_type"),
                                                           false,
                                                           false);

                        // Add to current member
                        classes.Last().members.Last().args.Add(newParam);
                    }
                }
            }

            // Ensure further saves will overwrite currently opened file
            currentFileName = a_filePath;

            // Display name of file in form title
            UpdateFormTitle();
        }
Exemple #4
0
        /**
         *   @brief Using user specified info, add string of member representation to listview.
         *   NOTE: Overrides GenerateFunction.
         *   @return Bool of whether item was successfully generated or not.
         * */
        protected override bool GenerateItem()
        {
            // Quit out early with failure if no class or sub-class name (if inheriting)
            if (TXT_Type.Text == "" || TXT_MemberName.Text == "")
            {
                return(false);
            }

            // Determine optional paramter representation
            string virtOpt    = (CheckBox_VirtualOpt.Checked) ? "VIRTUAL" : "";
            string funcBraces = (CheckBox_FunctionOpt.Checked) ? "(" : "";

            // Determine representation of return type/member type
            string memType = "";

            if (RB_PointerOpt.Checked)
            {
                memType = "*";
            }
            else if (RB_ReferenceOpt.Checked)
            {
                memType = "&";
            }

            // Determine parameter string
            for (int i = 0; i < LV_Params.Items.Count; ++i)
            {
                funcBraces += LV_Params.Items[i].Text;

                // Format if not final parameter
                if (i != LV_Params.Items.Count - 1)
                {
                    funcBraces += ", ";
                }
            }

            // If function, close off braces
            if (CheckBox_FunctionOpt.Checked)
            {
                funcBraces += ")";
            }

            // e.g. PRIVATE INLINE int& bagels(int thing, const float morg)
            textBuffer = CB_MemberAccess.SelectedItem.ToString() + space + virtOpt + space + CB_Identifiers.SelectedItem.ToString() + space
                         + TXT_Type.Text + memType + space + TXT_MemberName.Text + funcBraces;

            // Modify current selected member or add new one depending on form mode
            if (editMode)
            {
                m_mainForm.LV_Members.Items[m_mainForm.selectedMemberIndex].Text = textBuffer;
            }
            else
            {
                m_mainForm.LV_Members.Items.Add(textBuffer);
            }

            // Apply properties to blueprints of current member
            CppMember currentMember = m_mainForm.selectedClass.members[m_mainForm.selectedMemberIndex];      // Added member is at the end of the list

            currentMember.access     = CB_MemberAccess.SelectedItem.ToString();
            currentMember.isVirtual  = CheckBox_VirtualOpt.Checked;
            currentMember.modifier   = CB_Identifiers.SelectedItem.ToString();
            currentMember.type       = TXT_Type.Text;
            currentMember.memType    = memType;
            currentMember.name       = TXT_MemberName.Text;
            currentMember.isFunction = CheckBox_FunctionOpt.Checked;

            return(true);
        }