コード例 #1
0
ファイル: CmdLineExec.cs プロジェクト: chrishoen/Dev_RisLibCs
        //**********************************************************************
        // Pop the executive from the nested executive stack that is
        // contained in the nested anchor that is contained in the command

        public void nestedPop(CmdLineCmd aCmd)
        {
            // Guard
            if (aCmd.mNestedAnchor == null)
            {
                return;
            }

            // Pop the executive from the nested executive stack
            aCmd.mNestedAnchor.nestedPop();
        }
コード例 #2
0
ファイル: CmdLineExec.cs プロジェクト: chrishoen/Dev_RisLibCs
        //**********************************************************************
        // Push the executive onto the nested executive stack that is
        // contained in the nested anchor that is contained in the command

        public void nestedPush(CmdLineCmd aCmd, BaseCmdLineExec aNextExec)
        {
            // Guard
            if (aCmd.mNestedAnchor == null)
            {
                return;
            }

            // Push the executive onto the nested executive stack
            aCmd.mNestedAnchor.nestedPush(aNextExec);
        }
コード例 #3
0
        public static void execute(BaseCmdLineExec aExec)
        {
            aExec.reset();

            bool tGoing = true;

            while (tGoing)
            {
                // Read command line
                CmdLineCmd tCmd      = new CmdLineCmd();
                String     tCParBuff = Console.ReadLine();
                tCmd.putCmdLineString(tCParBuff);

                // Toggle print
                if (tCmd.isCmd("P"))
                {
                    Prn.ToggleSuppress();
                }
                // Exit
                else if (tCmd.isCmd("EXIT") || tCmd.isCmd("E"))
                {
                    aExec.executeExit();
                    tGoing = false;
                }
                // Execute command
                else
                {
                    aExec.execute(tCmd);

                    if (tCmd.isBadCmd())
                    {
                        Console.WriteLine("INVALID COMMAND");
                        Console.WriteLine("-----------------------------------------");
                    }
                }
            }
        }
コード例 #4
0
ファイル: CmdLineExec.cs プロジェクト: chrishoen/Dev_RisLibCs
        //**********************************************************************
        // This is called by an executer to execute a single command line.
        // It is passed in a pointer to the command and a pointer to an
        // command line file executer. The pointers are stored so as to
        // be available to inherited class methods used to process specific
        // commands.

        public abstract void execute(CmdLineCmd aCmd);
コード例 #5
0
ファイル: CmdLineFile.cs プロジェクト: chrishoen/Dev_RisLibCs
        //**********************************************************************
        //**********************************************************************
        //**********************************************************************
        // This method applies a command line executive to process all of the
        // command lines in the file

        public void execute(BaseCmdLineExec aExec)
        {
            // Guard
            if (mReader == null)
            {
                return;
            }

            //--------------------------------------------------------------
            //--------------------------------------------------------------
            //--------------------------------------------------------------
            // Locals

            // Command line executive for current nesting level
            BaseCmdLineExec tExec = aExec;

            // Command line string for current line
            String tCmdLine;

            // Loop line number
            int tLineNumber = 0;

            // Nested anchor. This is used to manage files that contain nested records,
            // which are processed by nested executives.
            CmdLineExecNestedAnchor tNestedAnchor = new CmdLineExecNestedAnchor();

            // Initialize to the initial executive
            tNestedAnchor.initialize(aExec);

            //--------------------------------------------------------------
            //--------------------------------------------------------------
            //--------------------------------------------------------------
            // Loop to read each command line in the file

            tLineNumber = 0;

            bool tGoing = true;

            while (tGoing)
            {
                // Command for current line
                CmdLineCmd tCmd = new CmdLineCmd();

                // Set the command nested anchor pointer.  This is piggybacked
                // onto the command so that it can be used by the executive.
                tCmd.mNestedAnchor = tNestedAnchor;

                tLineNumber++;

                // Read command line
                tCmdLine = mReader.ReadLine();

                if (tCmdLine == null)
                {
                    break;
                }

                // If the command line is not empty and not a comment
                // then process it, else go on to the next line
                if (tCmdLine.Length > 0)
                {
                    // Put command line string to command line command
                    // for parsing
                    tCmd.putCmdLineString(tCmdLine);

                    // Process the parsed command line
                    if (tCmd.isCmd("EXIT"))
                    {
                        // If exit then exit the loop
                        tGoing = false;
                    }
                    // If not an exit then process the parsed command line
                    else
                    {
                        // If tExec is not zero
                        if (tExec != null)
                        {
                            // Call the executive to process the command
                            tExec.execute(tCmd);
                        }
                        // Else tExec is not valid, there was a prior unrecognized Begin
                        // and zero was nestedPushed
                        else
                        {
                            if (tCmd.isCmd("END"))
                            {
                                // Pop the executive from the nested executive stack
                                // This will balance the unrecognized Begin
                                tNestedAnchor.nestedPop();
                            }
                        }

                        // If the command pushed to the anchor stack
                        if (tNestedAnchor.mChangeFlag)
                        {
                            // If the command pushed a new executive onto the anchor
                            // stack because it entered a new nested section, or if it
                            // popped an executive from the anchor stack because it is
                            // leaving a nested section then get the next executive from
                            // the anchor stack
                            tNestedAnchor.mChangeFlag = false;
                            tExec = tNestedAnchor.mExec;
                        }

                        // If the command set the exit flag then exit the loop
                        if (tExec != null)
                        {
                            if (tExec.mExitFlag)
                            {
                                tGoing = false;
                            }
                        }
                    }
                }
            }
        }