MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLifstream Class Reference

Detailed Description

This class provides fast input file-streaming (binary mode).

Public Member Functions

 TSLifstream ()
 
 TSLifstream (const char *s)
 
 ~TSLifstream ()
 
bool bad () const
 
void clear (int state=0)
 
void close ()
 
const void * dataPointer () const
 
void enablePaging (bool state, TSLFileLength maximumFileSize=102400, unsigned int pageBufferSize=16384)
 
bool eof () const
 
bool erase (TSLFileOffset start, TSLFileOffset end)
 
void get (char &c)
 
int get ()
 
void getline (char *buffer, int size, char delim='\n')
 
bool good () const
 
bool is_open () const
 
void open (const char *s)
 
TSLifstreamoperator>> (char &out)
 
TSLifstreamoperator>> (int &out)
 
TSLifstreamoperator>> (float &out)
 
TSLifstreamoperator>> (double &out)
 
TSLifstreamoperator>> (int64_t &out)
 
TSLifstreamoperator>> (uint64_t &out)
 
int peek () const
 
bool paged ()
 
bool pagingEnabled (TSLFileLength &maximumFileSize, unsigned int &pageBufferSize)
 
TSLifstreamputback (char c)
 
int rdstate () const
 
TSLifstreamread (char *s, int n)
 
TSLifstreamread (unsigned char *s, int n)
 
TSLifstreamread (short *s, int n)
 
TSLifstreamread (unsigned short *s, int n)
 
TSLifstreamread (int *s, int n)
 
TSLifstreamread (unsigned int *s, int n)
 
TSLifstreamread (float *s, int n)
 
TSLifstreamread (double *s, int n)
 
TSLifstreamread (TSLVariant *s)
 
TSLifstreamread (int64_t *s, int n)
 
TSLifstreamread (uint64_t *s, int n)
 
TSLFileLength remaining () const
 
void seekg (TSLFilePosition pos)
 
void setstate (int state)
 
TSLFileLength size () const
 
bool swap ()
 
void swap (bool _swap)
 
TSLFilePosition tellg () const
 
TSLifstreamoperator>> (TSLLong &out)
 
TSLifstreamread (TSLLong *s, int n)
 
TSLifstreamread (TSLULong *s, int n)
 

Static Public Member Functions

static TSLTextEncoding legacyGetEncodingOverride ()
 
static void legacySetEncodingOverride (TSLTextEncoding encoding)
 

Constructor & Destructor Documentation

◆ TSLifstream() [1/2]

TSLifstream::TSLifstream ( )

Default constructor.

◆ TSLifstream() [2/2]

TSLifstream::TSLifstream ( const char * s)

This constructor tries to open the file with the given filename, s.

Parameters
sThe name of the file to open.

◆ ~TSLifstream()

TSLifstream::~TSLifstream ( )

Destructor.

Member Function Documentation

◆ bad()

bool TSLifstream::bad ( ) const

Returns true to indicate a serious I/O error.

◆ clear()

void TSLifstream::clear ( int state = 0)

Sets or clears the error-state flags.

Parameters
stateIf 0, all error-state bits are cleared; otherwise the bits are set according to ios enumerator masks.

◆ close()

void TSLifstream::close ( )

This method closes the file.

◆ dataPointer()

const void * TSLifstream::dataPointer ( ) const

This method returns a pointer to the start of the data buffer.

If the underlying file is paged or an error is detected a NULL pointer will be returned.

◆ enablePaging()

void TSLifstream::enablePaging ( bool state,
TSLFileLength maximumFileSize = 102400,
unsigned int pageBufferSize = 16384 )

This method allows the user to enable paging of the stream.

Once a stream has been opened then the stream may not be paged.

This should be called before the stream is opened.

Parameters
statetrue enable paging, false disable paging.
maximumFileSizeThe maximum file size in Kb to read into memory before paging occurs (Default 100Mb).
pageBufferSizeThe buffer size in Kb to use when paging (Default 16Mb).

◆ eof()

bool TSLifstream::eof ( ) const

Returns true if end of file has been reached.

◆ erase()

bool TSLifstream::erase ( TSLFileOffset start,
TSLFileOffset end )

This method erases the section defined by start to end (inclusive of the index values).

The method will not work on a paged stream and the changes will not be reflected to the underlying storage.

The method is designed for manipulating in-memory data.

Parameters
startStart index.
endEnd index.
Returns
true if the data could be erased, false if the data could not be erased.

◆ get() [1/2]

int TSLifstream::get ( )

Extract a single character from the stream and stores it on the specified reference.

◆ get() [2/2]

void TSLifstream::get ( char & c)

Extract a single character from the stream and return it.

Parameters
cA reference to the char.

◆ getline()

void TSLifstream::getline ( char * buffer,
int size,
char delim = '\n' )

Extracts characters from the stream until either the delimiter is found, the limit size-1 is reached, or end of file is reached. The characters are stored in the specified array followed by a null terminator.

Parameters
bufferThe array for storing the extracted elements.
sizeThe maximum number of elements to extract including the terminating NULL.
delimThe delimiter that marks the end of the line.

◆ good()

bool TSLifstream::good ( ) const

Returns true if all error bits are clear.

◆ is_open()

bool TSLifstream::is_open ( ) const

Returns a nonzero value if this stream is attached to an open disk file identified by a file descriptor; otherwise 0.

◆ legacyGetEncodingOverride()

static TSLTextEncoding TSLifstream::legacyGetEncodingOverride ( )
static

Get the legacy encoding override.

If set, this override specifies the encoding which non-utf8 text read from files should be converted from.

This function is only for use with legacy applications, and will be removed in a future release.

Returns the legacy text encoding override.

◆ legacySetEncodingOverride()

static void TSLifstream::legacySetEncodingOverride ( TSLTextEncoding encoding)
static

Set the legacy text encoding override.

If set, this override specifies the encoding which non-utf8 text read from files should be converted from.

This function is only for use with legacy applications, and will be removed in a future release.

This function is not thread safe, and should be called once at the start of an application.

Parameters
encodingThe text encoding to use.

◆ open()

void TSLifstream::open ( const char * s)

This method tries to open the file with the given filename, s.

Parameters
sThe name of the file to open.

◆ operator>>() [1/7]

TSLifstream & TSLifstream::operator>> ( char & out)

Reads formatted data from the file's buffer.

Parameters
outThe required char.

◆ operator>>() [2/7]

TSLifstream & TSLifstream::operator>> ( double & out)

Reads formatted data from the file's buffer.

Parameters
outThe required double.

◆ operator>>() [3/7]

TSLifstream & TSLifstream::operator>> ( float & out)

Reads formatted data from the file's buffer.

Parameters
outThe required float.

◆ operator>>() [4/7]

TSLifstream & TSLifstream::operator>> ( int & out)

Reads formatted data from the file's buffer.

Parameters
outThe required int.

◆ operator>>() [5/7]

TSLifstream & TSLifstream::operator>> ( int64_t & out)

Reads formatted data from the file's buffer.

Parameters
outThe required 64bit int

◆ operator>>() [6/7]

TSLifstream & TSLifstream::operator>> ( TSLLong & out)

Reads formatted data from the file's buffer.

Parameters
outThe required TSLLong

◆ operator>>() [7/7]

TSLifstream & TSLifstream::operator>> ( uint64_t & out)

Reads formatted data from the file's buffer.

Parameters
outThe required 64bit unsigned int

◆ paged()

bool TSLifstream::paged ( )

This method returns the true if the stream is being paged, i.e. the data is not all contained in memory.

◆ pagingEnabled()

bool TSLifstream::pagingEnabled ( TSLFileLength & maximumFileSize,
unsigned int & pageBufferSize )

This method allows the user to query if paging is enabled.

This does not mean that the stream will have been paged. You need to call paged() to query if the stream is actually paged.

Parameters
maximumFileSizeThe maximum file size to read into memory before paging occurs is returned in this parameter.
pageBufferSizeThe buffer size to use when paging is returned in this parameter.
Returns
true if the stream is paged, false otherwise.

◆ peek()

int TSLifstream::peek ( ) const

Returns the next character without extracting it from the stream.

◆ putback()

TSLifstream & TSLifstream::putback ( char c)

Puts a character back into the stream.

Parameters
cThe character to put back.

◆ rdstate()

int TSLifstream::rdstate ( ) const

The member function returns the stored stream state information.

◆ read() [1/13]

TSLifstream & TSLifstream::read ( char * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a char array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [2/13]

TSLifstream & TSLifstream::read ( double * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a double array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [3/13]

TSLifstream & TSLifstream::read ( float * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a float array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [4/13]

TSLifstream & TSLifstream::read ( int * s,
int n )

This unformatted input method extracts up to n bytes and stores them in an int array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [5/13]

TSLifstream & TSLifstream::read ( int64_t * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a short array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [6/13]

TSLifstream & TSLifstream::read ( short * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a short array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [7/13]

TSLifstream & TSLifstream::read ( TSLLong * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a TSLLong array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [8/13]

TSLifstream & TSLifstream::read ( TSLULong * s,
int n )

This unformatted input method extracts up to n bytes and stores them in an TSLULong array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [9/13]

TSLifstream & TSLifstream::read ( TSLVariant * s)

This unformatted input method extracts one TSLVariant and stores it in the variable pointed to by s.

Parameters
sStorage for the extracted element.

◆ read() [10/13]

TSLifstream & TSLifstream::read ( uint64_t * s,
int n )

This unformatted input method extracts up to n bytes and stores them in a short array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [11/13]

TSLifstream & TSLifstream::read ( unsigned char * s,
int n )

This unformatted input method extracts up to n bytes and stores them in an unsigned char array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [12/13]

TSLifstream & TSLifstream::read ( unsigned int * s,
int n )

This unformatted input method extracts up to n bytes and stores them in an unsigned int array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ read() [13/13]

TSLifstream & TSLifstream::read ( unsigned short * s,
int n )

This unformatted input method extracts up to n bytes and stores them in an unsigned short array beginning at s. Note that n is the number of bytes, not the number of elements. The number of bytes can be calculated by multiplying the number of elements by the size of the elements' data type.

Parameters
sThe array for storing the extracted elements.
nThe number of bytes to copy from the stream.

◆ remaining()

TSLFileLength TSLifstream::remaining ( ) const

Returns the number of unread bytes remaining in the stream if known. If the number of remaining bytes is unknown, this method will return 0.

◆ seekg()

void TSLifstream::seekg ( TSLFilePosition pos)

Changes the get pointer for the stream.

Parameters
posThe new position value.

◆ setstate()

void TSLifstream::setstate ( int state)

The member function effectively calls clear (state | rdstate() ).

◆ size()

TSLFileLength TSLifstream::size ( ) const

This method returns the size of the stream.

◆ swap() [1/2]

bool TSLifstream::swap ( )

Returns true if byte swapping is on, false otherwise.

◆ swap() [2/2]

void TSLifstream::swap ( bool _swap)

Allows the user to set the byte swapping on the stream.

Parameters
_swaptrue byte swap, false do not byte swap.

◆ tellg()

TSLFilePosition TSLifstream::tellg ( ) const

Get the value for the stream's get pointer.