C# 클래스 Sfm2Xml.ByteReader

Replacement reader class for byte reading.
파일 보기 프로젝트 열기: sillsdev/FieldWorks 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
m_FileData byte[]
m_FileName string

공개 메소드들

메소드 설명
ByteReader ( string filename ) : System

Constructor requires a file name

ByteReader ( string filename, ClsLog &Log ) : System

Constructor requires a file name

ByteReader ( string filename, byte contents ) : System

Constructor (used for tests) take spurious file name and pretends contents are the byte array

GetLookAheadSfmMarkerAndData ( string &sfmMarker, byte &sfmData, byte &sfmBadBytes ) : bool

Return the next sfm marker and its data for view.

GetNextSfmMarkerAndData ( string &sfmMarker, byte &sfmData, byte &badSfmData ) : bool

This is the public method that returns the 'next' marker and data and boolean as to the success of the operation. This method will return the look ahead values and then fetch the next ones. This supports the ability to look ahead a single sfm now for beter planning. (Possible enhancement would be to read the whole file in and store the infor in an internal structure, but that would lead to a duplication of memory - the contents being stored twice.) So, for now as it isn't needed, we'll just read ahead one token.

Rewind ( ) : void

보호된 메소드들

메소드 설명
InArray ( byte dataArray, byte data ) : bool

Helper method to look through an array of bytes and return true if it's found

비공개 메소드들

메소드 설명
BytesMatch ( byte readData, long readPos, byte searchData ) : bool

Tests if the data bytes starting at the given position match the given search data.

CheckforAndHandleBOM ( ) : void

This will look at the start of the file for the BOM and process it if it's found.

CopySpaceIfMatched ( byte readData, long &readPos, long limitPos, byte &writeData, long &writePos, byte searchData ) : bool

Tests the given data at the given position for a match with given search data. If there is no match, or the match is at the end of the given data, the data is copied into a separate buffer. Otherwise, a space is copied over. This effectivly copies the given data to the output data, replacing matching searched-for data with a space, except at the end.

GetBytesUptoNextSfmMarker ( ) : byte[]

Assumption ************************************************ All sfm markers are assumed to begin a new line, ie follow a newline, and begin with a backslash '\'. The following parsing code is based on this assumption. Assumption ************************************************

GetEOLForThisFile ( ) : byte[]

Can't assume that it's a newline sequence, it could be a cr or lf or ?? Check the first XXXX bytes and see what the counts are for the characters and then determine the EOL.

Init ( string filename ) : void
Init ( string filename, byte content ) : void
IsCurrentData ( byte data ) : bool

Search the m_FileData array at the current position and see if the passed in data is an exact match for that number of bytes.

getNextSfmMarkerAndData ( string &sfmMarker, byte &sfmData, byte &badSfmBytes ) : bool

Worker method that returns the sfm marker as a string and the data for it as an array of bytes.

메소드 상세

ByteReader() 공개 메소드

Constructor requires a file name
public ByteReader ( string filename ) : System
filename string
리턴 System

ByteReader() 공개 메소드

Constructor requires a file name
public ByteReader ( string filename, ClsLog &Log ) : System
filename string
Log ClsLog
리턴 System

ByteReader() 공개 메소드

Constructor (used for tests) take spurious file name and pretends contents are the byte array
public ByteReader ( string filename, byte contents ) : System
filename string
contents byte
리턴 System

GetLookAheadSfmMarkerAndData() 공개 메소드

Return the next sfm marker and its data for view.
public GetLookAheadSfmMarkerAndData ( string &sfmMarker, byte &sfmData, byte &sfmBadBytes ) : bool
sfmMarker string
sfmData byte
sfmBadBytes byte
리턴 bool

GetNextSfmMarkerAndData() 공개 메소드

This is the public method that returns the 'next' marker and data and boolean as to the success of the operation. This method will return the look ahead values and then fetch the next ones. This supports the ability to look ahead a single sfm now for beter planning. (Possible enhancement would be to read the whole file in and store the infor in an internal structure, but that would lead to a duplication of memory - the contents being stored twice.) So, for now as it isn't needed, we'll just read ahead one token.
public GetNextSfmMarkerAndData ( string &sfmMarker, byte &sfmData, byte &badSfmData ) : bool
sfmMarker string
sfmData byte
badSfmData byte
리턴 bool

InArray() 보호된 메소드

Helper method to look through an array of bytes and return true if it's found
protected InArray ( byte dataArray, byte data ) : bool
dataArray byte
data byte
리턴 bool

Rewind() 공개 메소드

public Rewind ( ) : void
리턴 void

프로퍼티 상세

m_FileData 보호되어 있는 프로퍼티

protected byte[] m_FileData
리턴 byte[]

m_FileName 보호되어 있는 프로퍼티

protected string m_FileName
리턴 string