-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
305 additions
and
234 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
#include "SEFileLineReader.h" | ||
|
||
SEFileLineReader::SEFileLineReader(void) | ||
{ | ||
lastEndOfLineIndex = 0; | ||
} | ||
|
||
SEFileLineReader::~SEFileLineReader(void) | ||
{ | ||
} | ||
|
||
void SEFileLineReader::HandleString(const sechar* string, bool isEndOfFile) | ||
{ | ||
//split string | ||
stringBuffer.append( string ); | ||
|
||
int currentEndOfLineIndex = lastEndOfLineIndex; | ||
SEString substring; | ||
|
||
while( true ) | ||
{ | ||
currentEndOfLineIndex = stringBuffer.find( "\n", currentEndOfLineIndex+1 ); | ||
if( currentEndOfLineIndex == string::npos && !isEndOfFile ) | ||
{ | ||
//substring = stringBuffer.substr( lastEndOfLineIndex, stringBuffer.length() - 1 - lastEndOfLineIndex ); | ||
//mHandler->HandleString( substring.c_str(), isEndOfFile ); | ||
break; | ||
|
||
}else if( currentEndOfLineIndex != string::npos ) | ||
{ | ||
substring = stringBuffer.substr( lastEndOfLineIndex, currentEndOfLineIndex-lastEndOfLineIndex ); | ||
|
||
lastEndOfLineIndex = currentEndOfLineIndex; | ||
mHandler->HandleString( substring.c_str(), isEndOfFile ); | ||
|
||
}else | ||
break; | ||
} | ||
#include "SEFileLineReader.h" | ||
|
||
SEFileLineReader::SEFileLineReader(void) | ||
{ | ||
lastEndOfLineIndex = 0; | ||
} | ||
|
||
SEFileLineReader::~SEFileLineReader(void) | ||
{ | ||
} | ||
|
||
void SEFileLineReader::HandleString(const sechar* string, bool isEndOfFile) | ||
{ | ||
//split string | ||
stringBuffer.append( string ); | ||
|
||
int currentEndOfLineIndex = lastEndOfLineIndex; | ||
SEString substring; | ||
|
||
while( true ) | ||
{ | ||
currentEndOfLineIndex = stringBuffer.find( "\n", currentEndOfLineIndex+1 ); | ||
if( currentEndOfLineIndex == string::npos && !isEndOfFile ) | ||
{ | ||
//substring = stringBuffer.substr( lastEndOfLineIndex, stringBuffer.length() - 1 - lastEndOfLineIndex ); | ||
//mHandler->HandleString( substring.c_str(), isEndOfFile ); | ||
break; | ||
|
||
}else if( currentEndOfLineIndex != string::npos ) | ||
{ | ||
substring = stringBuffer.substr( lastEndOfLineIndex, currentEndOfLineIndex-lastEndOfLineIndex ); | ||
|
||
lastEndOfLineIndex = currentEndOfLineIndex; | ||
mDelegate->HandleString( substring.c_str(), isEndOfFile ); | ||
|
||
}else | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
#include "SEFileReaderBase.h" | ||
#include "SEPathBase.h" | ||
|
||
#define SEFILEREADER_BUFFER_LENGHT 1024 | ||
|
||
SEFileReaderBase::SEFileReaderBase(void) | ||
{ | ||
} | ||
|
||
SEFileReaderBase::~SEFileReaderBase(void) | ||
{ | ||
Close(); | ||
} | ||
|
||
void SEFileReaderBase::Load(const SEPathBase* filePath) | ||
{ | ||
Close(); | ||
mCurrentFile = filePath; | ||
|
||
sechar buffer[SEFILEREADER_BUFFER_LENGHT]; | ||
TRACE( filePath->cString() ); | ||
|
||
FILE* file = fopen(filePath->cString(), "r"); | ||
int feofFlag = feof(file); | ||
|
||
while( feofFlag == 0 ) | ||
{ | ||
memset(buffer,0,sizeof(buffer)); | ||
|
||
//fgets( buffer, SEWindowsFileReader_BUFFER_LENGHT-1, file ); | ||
fread(buffer, SEFILEREADER_BUFFER_LENGHT-1, 1, file); | ||
|
||
feofFlag = feof(file); | ||
HandleString( buffer, static_cast<bool>( feofFlag != 0 ) ); | ||
} | ||
|
||
fclose(file); | ||
} | ||
|
||
void SEFileReaderBase::Close() | ||
{ | ||
mCurrentFile = NULL; | ||
} | ||
|
||
void SEFileReaderBase::HandleString(const sechar* string, bool isEndOfFile) | ||
{ | ||
if( mHandler ) | ||
mHandler->HandleString(string, isEndOfFile); | ||
} | ||
|
||
void SEFileReaderBase::SetHandler( SEFileReaderHandlerInterface* _handler ) | ||
{ | ||
mHandler = _handler; | ||
} | ||
|
||
SEFileReaderHandlerInterface* SEFileReaderBase::handler() | ||
{ | ||
return mHandler; | ||
} | ||
#include "SEFileReaderBase.h" | ||
#include "SEPathBase.h" | ||
|
||
#define SEFILEREADER_BUFFER_LENGHT 1024 | ||
|
||
SEFileReaderBase::SEFileReaderBase(void) | ||
{ | ||
} | ||
|
||
SEFileReaderBase::~SEFileReaderBase(void) | ||
{ | ||
Close(); | ||
} | ||
|
||
void SEFileReaderBase::Load(const SEPathBase* filePath) | ||
{ | ||
Close(); | ||
mCurrentFile = filePath; | ||
|
||
sechar buffer[SEFILEREADER_BUFFER_LENGHT]; | ||
TRACE( filePath->cString() ); | ||
|
||
FILE* file = fopen(filePath->cString(), "r"); | ||
SEAssert(file!=0, "file not open"); | ||
|
||
int feofFlag = feof(file); | ||
|
||
while( feofFlag == 0 ) | ||
{ | ||
memset(buffer,0,sizeof(buffer)); | ||
|
||
//fgets( buffer, SEWindowsFileReader_BUFFER_LENGHT-1, file ); | ||
fread(buffer, SEFILEREADER_BUFFER_LENGHT-1, 1, file); | ||
|
||
feofFlag = feof(file); | ||
HandleString( buffer, static_cast<bool>( feofFlag != 0 ) ); | ||
} | ||
|
||
fclose(file); | ||
} | ||
|
||
void SEFileReaderBase::Close() | ||
{ | ||
mCurrentFile = NULL; | ||
} | ||
|
||
void SEFileReaderBase::HandleString(const sechar* string, bool isEndOfFile) | ||
{ | ||
if( mDelegate ) | ||
mDelegate->HandleString(string, isEndOfFile); | ||
} | ||
|
||
void SEFileReaderBase::SetDelegate( SEFileReaderDelegate* _delegate ) | ||
{ | ||
mDelegate = _delegate; | ||
} | ||
|
||
SEFileReaderDelegate* SEFileReaderBase::delegate() | ||
{ | ||
return mDelegate; | ||
} |
Oops, something went wrong.