C12Adapter Opensource C++ Interface
MFileNameAndLineNumber Class Reference

Memory saving fast copied storage for file name and file line. More...

Public Types

typedef std::vector< MFileNameAndLineNumberVectorType
 Type that represents an array of files and lines, or a stack.
 

Public Member Functions

 MFileNameAndLineNumber ()
 Class constructor that initializes the object with zero file name and line number.
 
 MFileNameAndLineNumber (const MFileNameAndLineNumber &other)
 Class constructor that initializes the object from a copy object.
 
 MFileNameAndLineNumber (Muint32 data)
 Class constructor that initializes the object from the internal data, as returned by GetData.
 
 MFileNameAndLineNumber (const MStdString &fileName, unsigned lineNumber)
 Most useful constructor that creates file name and line number information.
 
MFileNameAndLineNumberoperator= (const MFileNameAndLineNumber &other)
 Assignment operator that makes this file and line as of the given argument.
 
bool operator== (const MFileNameAndLineNumber &other) const
 Equality operator that tests whether the two files and line data are the same.
 
bool operator!= (const MFileNameAndLineNumber &other) const
 Inequality operator that tests whether the two files and line data are the same.
 
void Set (const MStdString &fileName, unsigned lineNumber)
 Setter, that initializes data for the whole class. More...
 
bool IsEmpty () const
 Checks whether there is no file and line information in an object.
 
void Clear ()
 Clear file name and line number information.
 
MStdString GetFileName () const
 Get file name associated with the object.
 
unsigned GetFileNameIndex () const
 Internal service that returns file name index in the internal array. More...
 
Muint32 GetData () const
 Return the internal representaion of a class.
 
unsigned GetFileLineNumber () const
 Get file line, or zero if there is no information.
 
void operator++ ()
 Increment line information by one line.
 
void operator+= (unsigned i)
 Increase line number by a given count. More...
 
bool IsSameFileDifferentLine (const MFileNameAndLineNumber &other) const
 True if the given file and line information refers to a different line within the same file. More...
 

Static Public Member Functions

static void Uninitialize ()
 Clear all file and line information within a class. More...
 

Detailed Description

Memory saving fast copied storage for file name and file line.

Since the number of file names with which the program works is limited, Internally, a table is used to store them in one place.

Member Function Documentation

unsigned MFileNameAndLineNumber::GetFileNameIndex ( ) const
inline

Internal service that returns file name index in the internal array.

This can be convenient for comparison of files for equality.

bool MFileNameAndLineNumber::IsSameFileDifferentLine ( const MFileNameAndLineNumber other) const

True if the given file and line information refers to a different line within the same file.

This is a handy way of detecting if there is a duplicate definition of the same entry. Notice if the entity is defined in the same line this check will be a false positive.

Parameters
otherAnother file and name information to check.
Returns
True if the given entity is in the same file, but the line is different.
void MFileNameAndLineNumber::operator+= ( unsigned  i)
inline

Increase line number by a given count.

Parameters
iincrease
void MFileNameAndLineNumber::Set ( const MStdString fileName,
unsigned  lineNumber 
)

Setter, that initializes data for the whole class.

Precondition
The line value shall be smaller than (1 << FILENAMEANDLINENUMBER_NAME_SHIFT) Or it will not be stored correctly.
static void MFileNameAndLineNumber::Uninitialize ( )
static

Clear all file and line information within a class.

All memory is freed, No file and line information will be available after