| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: No names yet. |
| 3 | // Purpose: Contrib. demo |
| 4 | // Author: Aleksandras Gluchovas |
| 5 | // Modified by: |
| 6 | // Created: 27/12/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Aleskandars Gluchovas |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef __IFCONTEXT_G__ |
| 13 | #define __IFCONTEXT_G__ |
| 14 | |
| 15 | #include "srcparser.h" |
| 16 | #include "cjparser.h" |
| 17 | |
| 18 | class spBookmark |
| 19 | { |
| 20 | public: |
| 21 | size_t mFrom; |
| 22 | size_t mLen; |
| 23 | size_t mFileNo; |
| 24 | |
| 25 | inline spBookmark() {} |
| 26 | |
| 27 | inline spBookmark( int from, int len, int fileNo ) |
| 28 | : mFrom( from ), mLen( len ), mFileNo( fileNo ) |
| 29 | {} |
| 30 | }; |
| 31 | |
| 32 | #if defined( wxUSE_TEMPLATE_STL ) |
| 33 | |
| 34 | typedef vector<spBookmark) BookmarkListT |
| 35 | |
| 36 | #else |
| 37 | |
| 38 | typedef WXSTL_VECTOR_SHALLOW_COPY(spBookmark) BookmarkListT; |
| 39 | |
| 40 | #endif |
| 41 | |
| 42 | |
| 43 | class spInterFileContext : public spContext |
| 44 | { |
| 45 | protected: |
| 46 | |
| 47 | BookmarkListT mDeletionMarks; |
| 48 | |
| 49 | BookmarkListT mFiltered; |
| 50 | |
| 51 | size_t mCurFileNo; |
| 52 | |
| 53 | CJSourceParser mParser; |
| 54 | |
| 55 | protected: |
| 56 | |
| 57 | size_t GetFileNoOfContext( spContext& ctx ); |
| 58 | size_t GetFileNo( const string& fname ); |
| 59 | |
| 60 | void InsertBookmarkSorted( BookmarkListT& lst, spBookmark& mark ); |
| 61 | |
| 62 | void DoAppendSourceFragment( string& source, |
| 63 | string& result, |
| 64 | size_t pos, size_t len ); |
| 65 | |
| 66 | void GenerateContextBody( spContext& ctx, |
| 67 | string& source, |
| 68 | string& result, |
| 69 | size_t& lastSavedPos, |
| 70 | size_t& lastKnownPos ); |
| 71 | |
| 72 | public: |
| 73 | |
| 74 | StrListT mFiles; |
| 75 | StrListT mContents; |
| 76 | |
| 77 | public: |
| 78 | |
| 79 | spInterFileContext(); |
| 80 | ~spInterFileContext(); |
| 81 | |
| 82 | void AddFile( const string& fname, const string& content ); |
| 83 | |
| 84 | void RemoveContext( spContext& ctx ); |
| 85 | |
| 86 | void GenrateContents(); |
| 87 | |
| 88 | void ParseContents( SourceParserPlugin* pPlugin = NULL ); |
| 89 | |
| 90 | void WriteToFiles(); |
| 91 | |
| 92 | // overriden method of the base class (finds out the source fragment) |
| 93 | |
| 94 | virtual string GetBody( spContext* pCtx = NULL ); |
| 95 | |
| 96 | virtual string GetHeader( spContext* pCtx = NULL ); |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | #endif |