"L. Spiro Engine"
Classes | Typedefs | Enumerations | Functions | Variables

lsstd Namespace Reference

Classes

class  C128BitInteger
 A 128-bit integer class. More...
class  CLargeInteger
 A large-integer template class. More...
class  CStd
 Standard CRT-type functions. More...
class  CSearch
 Standard search-and-sort routines. More...
class  CExternalByteStream
 Allows treating an external array of bytes as a stream. More...
class  IStream
 The base interface for all streams. More...
class  CTime
 High-resolution time class. More...

Typedefs

typedef LSINT32 LSBOOL
typedef LSUINT8 LSUTF8
typedef LSUINT16 LSUTF16
typedef LSUINT32 LSUTF32
typedef wchar_t LSUTFX

Enumerations

enum  LSSTD_LARGE_INTEGER_EXCEPTIONS { LSSTD_LIE_OVERFLOW, LSSTD_LIE_DIVISIONBYZERO, LSSTD_LIE_INVALIDCONVERSION }
enum  LSSTD_ERRORS {
  LSSTD_E_SUCCESS, LSSTD_E_OUTOFMEMORY, LSSTD_E_FILENOTFOUND, LSSTD_E_INVALIDWRITEPERMISSIONS,
  LSSTD_E_NODISKSPACE, LSSTD_E_INVALIDFILETYPE, LSSTD_E_INVALIDCALL, LSSTD_E_INVALIDDATA,
  LSSTD_E_INTERNALERROR, LSSTD_E_FEATURENOTSUPPORTED
}

Functions

m_ui32TotalIndices (0UL)
m_ui32AllocIndices (0UL)
CIndexSorter< _tType > &LSE_CALL operator= (const CIndexSorter< _tType > &_isOther)
CIndexSorter< _tType > &LSE_CALL Sort (const _tType *_ptData, LSUINT32 _ui32Total, LSBOOL _bCheckIfSorted=true)
CIndexSorter< _tType > &LSE_CALL QuickSort (const _tType *_ptData, LSUINT32 _ui32Total, LSBOOL _bCheckIfSorted=false)
CIndexSorter< _tType > &LSE_CALL InsertionSort (const _tType *_ptData, LSUINT32 _ui32Total)
const LSUINT32 *LSE_CALL GetIndices () const
LSVOID LSE_CALL PrepareFor (LSUINT32 _ui32Total)
LSVOID LSE_CALL Reset ()
LSBOOL LSE_CALL ReadBits (LSUINT8 *_pui8Buffer, LSUINT32 _ui32BitsToRead) const
virtual LSUINT32 LSE_CALL ReadBytes (LSUINT8 *_pui8Buffer, LSUINT32 _ui32BytesToRead) const
virtual LSUINT64 LSE_CALL ReadUInt64 () const
virtual LSUINT32 LSE_CALL ReadUInt32 () const
virtual LSUINT16 LSE_CALL ReadUInt16 () const
virtual LSUINT8 LSE_CALL ReadUInt8 () const
virtual LSFLOAT LSE_CALL ReadFloat () const
virtual LSDOUBLE LSE_CALL ReadDouble () const
LSBOOL LSE_CALL WriteBits (const LSUINT8 *_pui8Buffer, LSUINT32 _ui32BitsToWrite)
virtual LSUINT32 LSE_CALL WriteBytes (const LSUINT8 *_pui8Buffer, LSUINT32 _ui32BytesToWrite)
virtual LSBOOL LSE_CALL WriteUInt64 (const LSUINT64 &_ui64Value)
virtual LSBOOL LSE_CALL WriteUInt32 (LSUINT32 _ui32Value)
virtual LSBOOL LSE_CALL WriteUInt16 (LSUINT16 _ui16Value)
virtual LSBOOL LSE_CALL WriteUInt8 (LSUINT8 _ui8Value)
virtual LSBOOL LSE_CALL WriteFloat (LSFLOAT _fValue)
virtual LSBOOL LSE_CALL WriteDouble (const LSDOUBLE &_dValue)
LSUINT32 LSE_CALL GetLengthInBytes () const
const LSUINT8 *LSE_CALL GetRawBytes () const
LSUINT64 LSE_CALL SetPos (LSUINT64 _ui64Pos) const
LSUINT64 LSE_CALL GetPos () const
LSBOOL LSE_CALL PreAlloc (LSUINT64 _ui64NewSize)
LSVOID LSE_CALL Borrow (const LSUINT8 *_pui8Buffer, LSUINTPTR _uiptrSize)
LSBOOL LSE_CALL Alloc (LSUINT32 _ui32Total)
virtual LSVOID *LSE_CALL ReAlloc (LSVOID *_pvOriginal, LSUINT32 _ui32Total) const
virtual LSVOID LSE_CALL Free (LSVOID *_pvOriginal) const

Variables

__pad0__
F LSUINTPTR _uiptrLen
LSUINT32 * m_pui32Indices
LSUINT32 m_ui32TotalIndices
LSUINT32 m_ui32AllocIndices
LSUINT64 m_ui64TotalBits
LSUINT32 * m_pui32Buffer
LSUINT32 m_ui32Total
LSUINT32 m_ui32Alloc
LSBOOL m_bBorrowed
LSUINT64 m_ui64Pos

Detailed Description

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A standard 32-bit cyclic redundancy check calculator.

Copyright L. Spiro 2012 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A 128-bit integer class. This is a high-performance 128-bit signed integer class. Use this when you do not need larger values than 128 bits can hold and require performance.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A large-integer template class. Represents a number containing at most _uMaxDigits digits in radix 10. Provides standard operators synthesized in software mode. This class is not intended for use in any high-performance situation. Use this class when precision is more important than speed.

Multiple instances of this class can cause a heavy hit to the stack unless allocated to the heap.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Sorts data by index references. Instead of moving the actual data around, it creates an index table for that data and sorts the indices. This is often faster than trying to sort data composed of many-byte elements. Uses a quick sort. The data being sorted must provide < and == operators.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Standard search-and-sort routines.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provides a generic bit stream.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Allows treating an external array of bytes as a stream. Allows modifying the array but not beyond the actual length of the array. This is useful for situations when you have a file image loaded to memory and you wish to read from it in the fashion of a byte stream.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: This interface serves as the base class for all streams. File streams, bit streams, network streams, etc., are built on top of this.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Cross-platform time-management. Tracks time in microseconds (1,000,000 per second). Also provides frame count and virtual time/frame values for pausing. When paused, virtual values re not updated, causing any objects/systems using the virtual time values to stop (effectively pausing them). Use the regular time values for systems that cannot be paused, such as the menus, which should flash and animate regardless of the pause status.


Typedef Documentation

typedef LSINT32 lsstd::LSBOOL

Boolean type.

typedef LSUINT8 lsstd::LSUTF8

UTF types.

typedef wchar_t lsstd::LSUTFX

wchar_t is 16 bits on Windows and 32 bits on everything else. This means L"" string literals are of variable size. The X here indicates the variable number of bits, and should remind you not to send data of this format to files or over networks.


Enumeration Type Documentation

Error codes.

Enumerator:
LSSTD_E_SUCCESS 

No error.

LSSTD_E_OUTOFMEMORY 

Out of memory.

LSSTD_E_FILENOTFOUND 

File was not found at the given path.

LSSTD_E_INVALIDWRITEPERMISSIONS 

Unable to write to a file.

LSSTD_E_NODISKSPACE 

Unable to write to a file (disk space).

LSSTD_E_INVALIDFILETYPE 

File exists but is not in the expected format.

LSSTD_E_INVALIDCALL 

Invalid call.

LSSTD_E_INVALIDDATA 

Invalid input data.

LSSTD_E_INTERNALERROR 

Internal error.

LSSTD_E_FEATURENOTSUPPORTED 

Feature not yet supported.

Exceptions that can be thrown by this class.


Function Documentation

LSBOOL LSE_CALL lsstd::Alloc ( LSUINT32  _ui32Total) [protected]

Allocate the given number of LSUINT32's and store the result in m_pui32Buffer. Note that this function should not be overloaded when adding memory-manager functionality to this class.

Parameters:
_ui32TotalTotal number of LSUINT32's to allocate.
Returns:
Returns false on failure.
LSVOID LSE_CALL lsstd::Borrow ( const LSUINT8 *  _pui8Buffer,
LSUINTPTR  _uiptrSize 
)

Point the stream to an existing buffer. The buffer cannot be resized from within this instance. This can be a very dangerous function and must be used with caution. This causes its existing buffer to be freed.

Parameters:
_pui8BufferThe buffer to be used by this stream directly.
_uiptrSizeThe size of the buffer to which _pui8Buffer points.
virtual LSVOID LSE_CALL lsstd::Free ( LSVOID *  _pvOriginal) const [protected, virtual]

Free bytes. Override this to add functionality such as use of memory managers etc.

Parameters:
_pvOriginalPointer to the data, allocated with ReAlloc() to free.
const LSUINT32* LSE_CALL lsstd::GetIndices ( ) const

Get a pointer to the (sorted) index data.

Returns:
Returns a pointer to the (sorted) index data.
LSUINT32 LSE_CALL lsstd::GetLengthInBytes ( ) const

Get the length of the stream in bytes.

Returns:
Returns the length of the stream in bytes. All bits up to the last byte are used. The last byte may have some unused bits.
LSUINT64 LSE_CALL lsstd::GetPos ( ) const

Get the stream position in bits.

Returns:
Returns the stream position in bits.
const LSUINT8* LSE_CALL lsstd::GetRawBytes ( ) const

Get a pointer to the beginning of the actual bytes in the stream.

Returns:
Returns the actual bytes in the stream.
CIndexSorter<_tType>& LSE_CALL lsstd::InsertionSort ( const _tType *  _ptData,
LSUINT32  _ui32Total 
)

Sort the given data using an insertion sort.

Parameters:
_ptDataThe data to sort.
_ui32TotalTotal objects to sort.
Returns:
Returns a reference to this object.
CIndexSorter<_tType>& LSE_CALL lsstd::operator= ( const CIndexSorter< _tType > &  _isOther)

Assignment operator.

Parameters:
_isOtherThe object to copy.
Returns:
Returns the copied instance.
LSBOOL LSE_CALL lsstd::PreAlloc ( LSUINT64  _ui64NewSize)

Pre-allocate a given amount in bits. If the amount is less than or equal to the currently allocated amount, true is returned with no action taking place.

Parameters:
_ui64NewSizeThe new size to allocate.
Returns:
Returns true if allocation succeeds. False is returned if allocation takes place but fails.
LSVOID LSE_CALL lsstd::PrepareFor ( LSUINT32  _ui32Total)

Prepares to sort the given number of elements, but does not sort them.

Parameters:
PARMThe number of elements to prepare to sort.
CIndexSorter<_tType>& LSE_CALL lsstd::QuickSort ( const _tType *  _ptData,
LSUINT32  _ui32Total,
LSBOOL  _bCheckIfSorted = false 
)

Sort the given data using a quick sort.

Parameters:
_ptDataThe data to sort.
_ui32TotalTotal objects to sort.
_bCheckIfSortedIf true, the sort first checks to see if items need sorting.
Returns:
Returns a reference to this object.
LSBOOL LSE_CALL lsstd::ReadBits ( LSUINT8 *  _pui8Buffer,
LSUINT32  _ui32BitsToRead 
) const

Read bits from the stream. Stream position is advanced by the amount read.

Parameters:
_pui8BufferBuffer to be filled with the bits read from the stream.
_ui32BitsToReadNumber of bits to read.
Returns:
Returns true if all bits were successfully read from the bit stream.
virtual LSUINT32 LSE_CALL lsstd::ReadBytes ( LSUINT8 *  _pui8Buffer,
LSUINT32  _ui32BytesToRead 
) const [virtual]

Read bytes from the stream. Stream position is advanced by the amount read.

Parameters:
_pui8BufferBuffer to hold the bytes read from the stream.
_ui32BytesToReadNumber of bytes to read.
Returns:
Returns the actual number of bytes read or LSSTD_SE_ERROR on error.
virtual LSDOUBLE LSE_CALL lsstd::ReadDouble ( ) const [virtual]

Reads a 64-bit double from the stream and advances the stream position.

Returns:
Returns the 64-bit double at the current position in the stream.
virtual LSFLOAT LSE_CALL lsstd::ReadFloat ( ) const [virtual]

Reads a 32-bit float from the stream and advances the stream position.

Returns:
Returns the 32-bit float at the current position in the stream.
virtual LSUINT16 LSE_CALL lsstd::ReadUInt16 ( ) const [virtual]

Reads a 16-bit unsigned integer from the stream and advances the stream position.

Returns:
Returns the 16-bit unsigned integer at the current position in the stream.
virtual LSUINT32 LSE_CALL lsstd::ReadUInt32 ( ) const [virtual]

Reads a 32-bit unsigned integer from the stream and advances the stream position.

Returns:
Returns the 32-bit unsigned integer at the current position in the stream.
virtual LSUINT64 LSE_CALL lsstd::ReadUInt64 ( ) const [virtual]

Reads a 64-bit unsigned integer from the stream and advances the stream position.

Returns:
Returns the 64-bit unsigned integer at the current position in the stream.
virtual LSUINT8 LSE_CALL lsstd::ReadUInt8 ( ) const [virtual]

Reads an 8-bit unsigned integer from the stream and advances the stream position.

Returns:
Returns the 8-bit unsigned integer at the current position in the stream.
virtual LSVOID* LSE_CALL lsstd::ReAlloc ( LSVOID *  _pvOriginal,
LSUINT32  _ui32Total 
) const [protected, virtual]

Re-allocate bytes. Override this to add functionality such as use of memory managers etc.

Parameters:
_pvOriginalAddress to re-alloate. Pass NULL to allocate new data.
_ui32TotalTotal number of bytes to allocate.
Returns:
Returns the re-allocated bytes or NULL upon failure.
LSVOID LSE_CALL lsstd::Reset ( )

Reset the stream completely. Frees all resources it was using.

Reset everything. Clears all resources created by this instance.

Reset all contents.

LSUINT64 LSE_CALL lsstd::SetPos ( LSUINT64  _ui64Pos) const

Set the stream position in bits. If the position is set past the end of the stream length, it is clamped to the end of the string.

Parameters:
_ui64PosThe new position of the stream in bits.
Returns:
Returns the old position of the stream in bits.
CIndexSorter<_tType>& LSE_CALL lsstd::Sort ( const _tType *  _ptData,
LSUINT32  _ui32Total,
LSBOOL  _bCheckIfSorted = true 
)

Sort the given data.

Parameters:
_ptDataThe data to sort.
_ui32TotalTotal objects to sort.
_bCheckIfSortedIf true, the sort first checks to see if items need sorting.
Returns:
Returns a reference to this object.
LSBOOL LSE_CALL lsstd::WriteBits ( const LSUINT8 *  _pui8Buffer,
LSUINT32  _ui32BitsToWrite 
)

Write bits to the current position in the stream. Stream position is advanced by the amount written.

Parameters:
_pui8BufferBuffer containing the bits to write to the stream.
_ui32BitsToWriteNumber of bits to write from _pui8Buffer.
Returns:
Returns true if all bits were written to the stream.
virtual LSUINT32 LSE_CALL lsstd::WriteBytes ( const LSUINT8 *  _pui8Buffer,
LSUINT32  _ui32BytesToWrite 
) [virtual]

Write bytes to the stream. Stream position is advanced by the amount written.

Parameters:
_pui8BufferBuffer containing the bytes to write to the stream.
_ui32BytesToWriteNumber of bytes to write.
Returns:
Returns the actual number of bytes written or LSSTD_SE_ERROR on error.
virtual LSBOOL LSE_CALL lsstd::WriteDouble ( const LSDOUBLE &  _dValue) [virtual]

Writes a 64-bit double from the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.
virtual LSBOOL LSE_CALL lsstd::WriteFloat ( LSFLOAT  _fValue) [virtual]

Writes a 32-bit float from the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.
virtual LSBOOL LSE_CALL lsstd::WriteUInt16 ( LSUINT16  _ui16Value) [virtual]

Writes a 16-bit unsigned integer to the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.
virtual LSBOOL LSE_CALL lsstd::WriteUInt32 ( LSUINT32  _ui32Value) [virtual]

Writes a 32-bit unsigned integer to the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.
virtual LSBOOL LSE_CALL lsstd::WriteUInt64 ( const LSUINT64 &  _ui64Value) [virtual]

Writes a 64-bit unsigned integer to the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.
virtual LSBOOL LSE_CALL lsstd::WriteUInt8 ( LSUINT8  _ui8Value) [virtual]

Writes an 8-bit unsigned integer from the stream and advances the stream position.

Returns:
Returns true if the value was fully written to the stream.

Variable Documentation

Is the buffer borrowed?

We buffer 32 bits worth at a time.

Sorted indices.

Allocated length of the list in bytes.

Total indices allocated.

Total length of the allocated list in bytes.

Total indices.

LSUINT64 lsstd::m_ui64Pos

Stream position in bits. Why mutable? Because reading from a stream requires const functions! This makes sense in terms of logical const-correctness. If this stream were to be compared against another stream, m_ui64Pos would not be a factor in determining if they were equal, thus modifying m_ui64Pos has no influence on the logical const-ness of this object. Mutable it is.

Length of the stream in bits.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator