/* take a block of text and parse it into a sequencer config. it returns an */ /* error code. if an error occurs, then *SeqOut is invalid, otherwise it will */ /* be valid. the text file remains unaltered. *ErrorLine is numbered from 1. */ public static BuildSeqErrors BuildSequencerFromText( string TextFile, out int ErrorLine, out SequencerConfigSpecRec SeqOut) { ScannerRec <SeqKeywordType> Scanner; SequencerConfigSpecRec Sequencer; BuildSeqErrors Error; SeqOut = null; ErrorLine = -1; Sequencer = NewSequencerConfigSpec(); Scanner = new ScannerRec <SeqKeywordType>(TextFile, SeqKeywordTable); Error = ParseSequencer( Sequencer, Scanner, out ErrorLine); if (Error == BuildSeqErrors.eBuildSeqNoError) { /* success */ SeqOut = Sequencer; } return(Error); }
/* create a new one */ public static SequencerConfigSpecRec NewSequencerConfigSpec() { SequencerConfigSpecRec Spec = new SequencerConfigSpecRec(); Spec.List = new OneTrackRec[0]; return(Spec); }
/* add a track to it (copies the strings, but takes ownership of track object) */ public static void AddTrackToSequencerConfigSpec( SequencerConfigSpecRec Spec, string TrackName, string TrackGroupName) { OneTrackRec OneTrack = new OneTrackRec(); OneTrack.TrackGroupName = TrackGroupName; OneTrack.TrackName = TrackName; Array.Resize(ref Spec.List, Spec.List.Length + 1); Spec.List[Spec.List.Length - 1] = OneTrack; }
public static string SequencerConfigGetGroupName( SequencerConfigSpecRec Spec, int Index) { return(Spec.List[Index].TrackGroupName); }
/* get number of thingies in it */ public static int GetSequencerConfigLength(SequencerConfigSpecRec Spec) { return(Spec.List.Length); }
private static BuildSeqErrors ParseSequencer( SequencerConfigSpecRec Sequencer, ScannerRec <SeqKeywordType> Scanner, out int ErrorLine) { TokenRec <SeqKeywordType> Token; TokenRec <SeqKeywordType> TokenName; TokenRec <SeqKeywordType> TokenGroup; ErrorLine = -1; while (true) { Token = Scanner.GetNextToken(); if (Token.GetTokenType() == TokenTypes.eTokenEndOfInput) { break; } if ((Token.GetTokenType() != TokenTypes.eTokenKeyword) || (Token.GetTokenKeywordTag() != SeqKeywordType.eSeqKeywordTrack)) { ErrorLine = Scanner.GetCurrentLineNumber(); return(BuildSeqErrors.eBuildSeqExpectedTrack); } /* parse the track */ /* "name" */ TokenName = Scanner.GetNextToken(); if (TokenName.GetTokenType() != TokenTypes.eTokenString) { ErrorLine = Scanner.GetCurrentLineNumber(); return(BuildSeqErrors.eBuildSeqExpectedTrackName); } /* group */ Token = Scanner.GetNextToken(); if ((Token.GetTokenType() != TokenTypes.eTokenKeyword) || (Token.GetTokenKeywordTag() != SeqKeywordType.eSeqKeywordGroup)) { ErrorLine = Scanner.GetCurrentLineNumber(); return(BuildSeqErrors.eBuildSeqExpectedGroup); } /* "group" */ TokenGroup = Scanner.GetNextToken(); if (TokenGroup.GetTokenType() != TokenTypes.eTokenString) { ErrorLine = Scanner.GetCurrentLineNumber(); return(BuildSeqErrors.eBuildSeqExpectedGroupName); } /* ; */ Token = Scanner.GetNextToken(); if (Token.GetTokenType() != TokenTypes.eTokenSemicolon) { ErrorLine = Scanner.GetCurrentLineNumber(); return(BuildSeqErrors.eBuildSeqExpectedSemicolon); } /* add it */ AddTrackToSequencerConfigSpec( Sequencer, TokenName.GetTokenStringValue(), TokenGroup.GetTokenStringValue()); } return(BuildSeqErrors.eBuildSeqNoError); }