1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef SOURCE_FILE_H 6#define SOURCE_FILE_H 7 8#include <Referenceable.h> 9 10 11class SourceFile; 12 13 14class SourceFileOwner { 15public: 16 virtual ~SourceFileOwner(); 17 18 virtual void SourceFileUnused(SourceFile* sourceFile) = 0; 19 virtual void SourceFileDeleted(SourceFile* sourceFile) = 0; 20}; 21 22 23 24class SourceFile : public BReferenceable { 25public: 26 SourceFile(SourceFileOwner* owner); 27 ~SourceFile(); 28 29 status_t Init(const char* path); 30 31 int32 CountLines() const; 32 const char* LineAt(int32 index) const; 33 int32 LineLengthAt(int32 index) const; 34 35protected: 36 virtual void LastReferenceReleased(); 37 38private: 39 SourceFileOwner* fOwner; 40 char* fFileContent; 41 int32* fLineOffsets; 42 int32 fLineCount; 43}; 44 45 46 47#endif // SOURCE_FILE_H 48