2009-07-03 04:56:39 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef SOURCE_FILE_H
|
|
|
|
#define SOURCE_FILE_H
|
|
|
|
|
|
|
|
#include <Referenceable.h>
|
|
|
|
|
|
|
|
|
|
|
|
class SourceFile;
|
|
|
|
|
|
|
|
|
|
|
|
class SourceFileOwner {
|
|
|
|
public:
|
|
|
|
virtual ~SourceFileOwner();
|
|
|
|
|
|
|
|
virtual void SourceFileUnused(SourceFile* sourceFile) = 0;
|
|
|
|
virtual void SourceFileDeleted(SourceFile* sourceFile) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class SourceFile : public BReferenceable {
|
2009-07-03 04:56:39 +04:00
|
|
|
public:
|
|
|
|
SourceFile(SourceFileOwner* owner);
|
|
|
|
~SourceFile();
|
|
|
|
|
|
|
|
status_t Init(const char* path);
|
|
|
|
|
|
|
|
int32 CountLines() const;
|
|
|
|
const char* LineAt(int32 index) const;
|
2009-07-15 16:52:18 +04:00
|
|
|
int32 LineLengthAt(int32 index) const;
|
2009-07-03 04:56:39 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void LastReferenceReleased();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SourceFileOwner* fOwner;
|
|
|
|
char* fFileContent;
|
|
|
|
int32* fLineOffsets;
|
|
|
|
int32 fLineCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SOURCE_FILE_H
|