// $Revision: 1.2 $ // Copyright (C) 1994 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_SNIPPETS #define TaligentSamples_SNIPPETS #ifndef TaligentSamples_SNIPPETDISPLAY #include "SnippetDisplay.h" #endif #ifndef Taligent_STANDARDTEXT #include #endif #ifndef Taligent_FILESYSTEMINTERFACE #include #endif // ----------------------------------------------------------------------------- // TSnippets // // The default snippet class has protocol for running a snippet member function, // and for displaying the input and output to the function. class TSnippets { public: TaligentTypeExtensionDeclarationsMacro(TSnippets) virtual ~TSnippets(); virtual TStream& operator>>=(TStream&) const; virtual TStream& operator<<=(TStream&); virtual short GetNumberOfSnippets() const; virtual void RunSnippet(short index); virtual void RunAllSnippets(); virtual TSnippetDisplay& GetDisplay(); virtual void SetDisplay(TSnippetDisplay*); virtual void GetName(TText&) const; virtual void GetSnippetName(short, TText&) const; virtual void GetSnippetSource(short, TText&) const; typedef void (TSnippets::*SnippetMemberFn)(); protected: TSnippets(); TSnippets(const TSnippets&); struct TSnippetInfo { TaligentTypeExtensionDeclarationsMacro(TSnippets::TSnippetInfo) TSnippetInfo(SnippetMemberFn fn, const TText& sourceName); void (TSnippets::*fMemberFn)(); TStandardText fSourceName; TStandardText fSourceText; private: TSnippetInfo(); }; virtual void AdoptSnippetInfo(TSnippetInfo*); virtual void CacheSourceText(TSnippetInfo* info) const; virtual void GetSourceFileName(TText&) const; virtual TFile GetSourceFile() const; virtual void FormatSource(TStandardText&) const; private: bool fHaveNotSearchedForFile; TFile fSourceFile; TArrayOf fSnippetInfo; TSnippetDisplay* fDisplay; // not owned. static TSnippetDisplay* fgDefaultDisplay; enum EVersion { kOriginalVersion }; }; // Utility macro for subclasses of TSnippets. #define SNIPPETINFO(member) AdoptSnippetInfo(new TSnippetInfo((TSnippets::SnippetMemberFn)member, TStandardText(#member))) #endif // TaligentSamples_SNIPPETS