Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

_InternalSourcePosition Class Reference

Internally used source position class. More...

#include <sourcepos.h>

Inheritance diagram for _InternalSourcePosition:

Inheritance graph
[legend]
Collaboration diagram for _InternalSourcePosition:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ~_InternalSourcePosition ()
 Destructor [overriding virtual].

SourceFileNode file () const
 Get the associated file node or a NULL ref:.

int line () const
 Get line number.

int lpos () const
 Get lpos (curser position in line).

TLString path () const
 Get path to file.

void SetLine (int l)
 Explicitly set the line. Normally not used.

void SetLPos (int l)
 Explicitly set the lpos. Normally not used.

TLString PosString (bool with_file=1) const
 Get string representation of this position without include hierarchy.

TLString PosRangeString (const SourcePosition &end, bool with_file=1) const
 String representation of position range.

TLString PosStringRelative (const SourcePosition &rpos) const
 Write position relative to rpos.

TLString IncludeHierarchyStr () const
 Return string representation of include hierarchy.


Static Public Member Functions

SourcePosition CreateSinglePosition (const SourceFileNode &sfn, int line, int lpos)

Private Member Functions

bool test_equal (const _InternalSourcePosition &b) const
 Test if two source positions are equal; used by operator== and !=.

 _InternalSourcePosition (const _InternalSourcePosition &)
 NOT "C++-safe"; do not call these.

void operator= (const _InternalSourcePosition &)
 _InternalSourcePosition (const SourceFileNode &fnode, int line, int lpos)
 Construct an internal source position; internally used.


Private Attributes

SourceFileNode _file
 File and all the include hierarchy.

int _line
 Line number.

int _lpos
 Position on the line.


Friends

class SourcePositionArchive
class RefNode< _InternalSourcePosition >
bool operator== (const SourcePosition &a, const SourcePosition &b)
 operator==() returns true for same position in same file.


Detailed Description

Internally used source position class.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Use the ref-counting SourcePosition class instead of directly this.

The SourcePosition class lets you access the public methods of this one via the operator->().

Note:
The source position code is semi thread-safe, i.e. it is assumed that there is only one thread per SourcePositionArchive (i.e. only one thread does scanning and parsing). The created SourcePosition objects may then be used by several threads.

Definition at line 92 of file sourcepos.h.


Constructor & Destructor Documentation

_InternalSourcePosition::_InternalSourcePosition const _InternalSourcePosition  )  [private]
 

NOT "C++-safe"; do not call these.

Referenced by CreateSinglePosition().

_InternalSourcePosition::_InternalSourcePosition const SourceFileNode fnode,
int  line,
int  lpos
[private]
 

Construct an internal source position; internally used.

Definition at line 155 of file sourcepos.cc.

References _line, _lpos, and SourceFileNode.

_InternalSourcePosition::~_InternalSourcePosition  ) 
 

Destructor [overriding virtual].

Definition at line 164 of file sourcepos.cc.

References _file.


Member Function Documentation

SourcePosition _InternalSourcePosition::CreateSinglePosition const SourceFileNode sfn,
int  line,
int  lpos
[static]
 

Can be used to create a single SourcePosition.
If you create more of them use the source position archive because it saves you a lot of memory.

Definition at line 147 of file sourcepos.cc.

References _InternalSourcePosition(), SourceFileNode, and SourcePosition.

Referenced by SCLocation::SCLocation().

SourceFileNode _InternalSourcePosition::file  )  const [inline]
 

Get the associated file node or a NULL ref:.

Definition at line 122 of file sourcepos.h.

References _file, and SourceFileNode.

Referenced by PosRangeString().

TLString _InternalSourcePosition::IncludeHierarchyStr  )  const
 

Return string representation of include hierarchy.

This is suitable to be prepended before e.g. a PosString(). Each include statement gets written into a line of its own; (the character is a newline unless hierarchy is empty).

Definition at line 22 of file sourcepos.cc.

References _file.

int _InternalSourcePosition::line  )  const [inline]
 

Get line number.

Definition at line 126 of file sourcepos.h.

References _line.

int _InternalSourcePosition::lpos  )  const [inline]
 

Get lpos (curser position in line).

Definition at line 128 of file sourcepos.h.

References _lpos.

void _InternalSourcePosition::operator= const _InternalSourcePosition  )  [private]
 

TLString _InternalSourcePosition::path  )  const [inline]
 

Get path to file.

Definition at line 130 of file sourcepos.h.

References _file.

Referenced by PosString().

TLString _InternalSourcePosition::PosRangeString const SourcePosition end,
bool  with_file = 1
const
 

String representation of position range.

Uses simple position if the positions equal.
Omits file completely if with_file=0.

Todo:
#warning "This may handle cases with line/lpos<0 incorrectly."

Definition at line 59 of file sourcepos.cc.

References _line, _lpos, file(), PosString(), SourceFileNode, SourcePosition, and TLString::sprintf().

TLString _InternalSourcePosition::PosString bool  with_file = 1  )  const
 

Get string representation of this position without include hierarchy.

String looks like "file" or "file:line" or "file:line:lpos".
File is omitted if with_file=0.

Definition at line 30 of file sourcepos.cc.

References _line, _lpos, path(), and TLString::sprintf().

Referenced by PosRangeString(), and PosStringRelative().

TLString _InternalSourcePosition::PosStringRelative const SourcePosition rpos  )  const
 

Write position relative to rpos.

That means: leave away file if it is the same file.

Definition at line 116 of file sourcepos.cc.

References _file, _line, _lpos, PosString(), SourcePosition, and TLString::sprintf().

void _InternalSourcePosition::SetLine int  l  )  [inline]
 

Explicitly set the line. Normally not used.

Definition at line 134 of file sourcepos.h.

References _line.

void _InternalSourcePosition::SetLPos int  l  )  [inline]
 

Explicitly set the lpos. Normally not used.

Definition at line 136 of file sourcepos.h.

References _lpos.

bool _InternalSourcePosition::test_equal const _InternalSourcePosition b  )  const [private]
 

Test if two source positions are equal; used by operator== and !=.

Definition at line 132 of file sourcepos.cc.


Friends And Related Function Documentation

bool operator== const SourcePosition a,
const SourcePosition b
[friend]
 

operator==() returns true for same position in same file.

See also:
SourceFileNode::operator==()

Definition at line 178 of file sourcepos.h.

friend class RefNode< _InternalSourcePosition > [friend]
 

Definition at line 95 of file sourcepos.h.

friend class SourcePositionArchive [friend]
 

Definition at line 94 of file sourcepos.h.


Member Data Documentation

SourceFileNode _InternalSourcePosition::_file [private]
 

File and all the include hierarchy.

Definition at line 104 of file sourcepos.h.

Referenced by file(), IncludeHierarchyStr(), path(), PosStringRelative(), and ~_InternalSourcePosition().

int _InternalSourcePosition::_line [private]
 

Line number.

Definition at line 105 of file sourcepos.h.

Referenced by _InternalSourcePosition(), line(), PosRangeString(), PosString(), PosStringRelative(), and SetLine().

int _InternalSourcePosition::_lpos [private]
 

Position on the line.

Definition at line 106 of file sourcepos.h.

Referenced by _InternalSourcePosition(), lpos(), PosRangeString(), PosString(), PosStringRelative(), and SetLPos().


The documentation for this class was generated from the following files:
Generated on Sat Feb 19 22:35:19 2005 for Ray by doxygen 1.3.5