CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Member Functions | Related Functions | List of all members
cs::xr_tuple Class Reference

Describes an occurrence of a token in a particular kind-role and the definition corresponding to that occurrence. More...

Public Member Functions

 xr_tuple (csuint64 _namehash, xr_kind_role _kr, bool _complete, sfile _file, line_number _line, sfile _def_file, line_number _def_line)
 Constructor. More...
 
std::string as_repr () const
 Get a representation of a xr_tuple object that includes information useful for debugging. More...
 
std::string as_string () const
 Get a simple string representation of a xr_tuple object. More...
 
int cmp (const xr_tuple &other) const
 Comparison function for xr_tuple, with respect to a stable overall ordering. More...
 
bool get_complete () const
 Check: is the definition complete? More...
 
sfile get_def_file () const
 Get the source file containing the token's definition. More...
 
line_number get_def_line () const
 Get the source file line containing the token definition. More...
 
sfile get_file () const
 Get the source file containing the token occurrence. More...
 
xr_kind_role get_kind_role () const
 Get the token's kind-role. More...
 
line_number get_line () const
 Get the source file line containing the token occurrence. More...
 
std::string get_name () const
 Get the source token corresponding to an xr_tuple. More...
 
csuint64 get_namehash () const
 Get a hash of the token name. More...
 
cs_hash_t hash () const
 Hash function for xr_tuple. More...
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const xr_tuple &a, const xr_tuple &b)
 Inequality operator for xr_tuple. More...
 
bool operator< (const xr_tuple &a, const xr_tuple &b)
 Less-than operator for xr_tuple. More...
 
std::ostream & operator<< (std::ostream &out, const xr_tuple &t)
 Print a representation of an xr_tuple object to the specified stream. More...
 
bool operator<= (const xr_tuple &a, const xr_tuple &b)
 Less-than-or-equal operator for xr_tuple. More...
 
bool operator== (const xr_tuple &a, const xr_tuple &b)
 Equality operator for xr_tuple. More...
 
bool operator> (const xr_tuple &a, const xr_tuple &b)
 Greater-than operator for xr_tuple. More...
 
bool operator>= (const xr_tuple &a, const xr_tuple &b)
 Greater-than-or-equal operator for xr_tuple. More...
 

Detailed Description

Describes an occurrence of a token in a particular kind-role and the definition corresponding to that occurrence.

This is the element type of the xr_query_iterator returned by project::token_search().

Constructor & Destructor Documentation

◆ xr_tuple()

cs::xr_tuple::xr_tuple ( csuint64  _namehash,
xr_kind_role  _kr,
bool  _complete,
sfile  _file,
line_number  _line,
sfile  _def_file,
line_number  _def_line 
)
inline

Constructor.

Parameters
[in]_namehashThe token name hash, as produced by get_namehash(). If you are extracting a procedure name to hash, use procedure::basename().
[in]_krThe token kind and role described by the xr_tuple.
[in]_completetrue iff the token definition is complete. Some definitions, such as extern, are incomplete.
[in]_fileThe source file containing the token occurrence.
[in]_lineThe location in _file of the token occurrence.
[in]_def_fileThe source file containing the token definition. There may be multiple corresponding definitions, in which case there will be a separate xr_tuple for each definition.
[in]_def_lineThe location in _def_file of the token definition.

Member Function Documentation

◆ as_repr()

std::string cs::xr_tuple::as_repr ( ) const
inline

Get a representation of a xr_tuple object that includes information useful for debugging.

Returns
The string representation.

◆ as_string()

std::string cs::xr_tuple::as_string ( ) const
inline

Get a simple string representation of a xr_tuple object.

Returns
The string representation.

◆ cmp()

int cs::xr_tuple::cmp ( const xr_tuple other) const
inline

Comparison function for xr_tuple, with respect to a stable overall ordering.

Parameters
otherThe xr_tuple object to compare against.
Returns
An integer N such that:
  • N==0 if the two objects compare equal
  • N<0 if this < other
  • N>0 if this > other

◆ get_complete()

bool cs::xr_tuple::get_complete ( ) const
inline

Check: is the definition complete?

Returns
true if the definition is complete, false if it's incomplete (for example, because it is an extern definition).

◆ get_def_file()

sfile cs::xr_tuple::get_def_file ( ) const
inline

Get the source file containing the token's definition.

Returns
The source file (sfile).

If there are multiple corresponding definitions, there will be a separate xr_tuple object for each definition.

◆ get_def_line()

line_number cs::xr_tuple::get_def_line ( ) const
inline

Get the source file line containing the token definition.

Returns
The source file line (line_number).

◆ get_file()

sfile cs::xr_tuple::get_file ( ) const
inline

Get the source file containing the token occurrence.

Returns
The source file (sfile).

◆ get_kind_role()

xr_kind_role cs::xr_tuple::get_kind_role ( ) const
inline

Get the token's kind-role.

Returns
The token's kind-role (xr_kind_role).

◆ get_line()

line_number cs::xr_tuple::get_line ( ) const
inline

Get the source file line containing the token occurrence.

Returns
The source file line (line_number).

◆ get_name()

std::string cs::xr_tuple::get_name ( ) const
inline

Get the source token corresponding to an xr_tuple.

Returns
The source token, as a string.
Exceptions
result::ELEMENT_NOT_PRESENTif no source token corresponding to the tuple could be found.
result::ERROR_IO_SEEKA procedure name token is the procedure basename as returned by procedure::basename().

◆ get_namehash()

csuint64 cs::xr_tuple::get_namehash ( ) const
inline

Get a hash of the token name.

Returns
A hash of the token name.

A procedure name token is the procedure basename as returned by procedure::basename().

◆ hash()

cs_hash_t cs::xr_tuple::hash ( ) const
inline

Hash function for xr_tuple.

Returns
The hash value.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const xr_tuple a,
const xr_tuple b 
)
related

Inequality operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
false if a and b are equal according to xr_tuple::cmp(), true otherwise.

◆ operator<()

bool operator< ( const xr_tuple a,
const xr_tuple b 
)
related

Less-than operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
true if a < b according to xr_tuple::cmp() , false otherwise.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const xr_tuple t 
)
related

Print a representation of an xr_tuple object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]tThe xr_tuple object to print.
Returns
void

◆ operator<=()

bool operator<= ( const xr_tuple a,
const xr_tuple b 
)
related

Less-than-or-equal operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
true if a <= b according to xr_tuple::cmp() , false otherwise.

◆ operator==()

bool operator== ( const xr_tuple a,
const xr_tuple b 
)
related

Equality operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
true if a and b are equal according to xr_tuple::cmp(), false otherwise.

◆ operator>()

bool operator> ( const xr_tuple a,
const xr_tuple b 
)
related

Greater-than operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
true if a > b according to xr_tuple::cmp() , false otherwise.

◆ operator>=()

bool operator>= ( const xr_tuple a,
const xr_tuple b 
)
related

Greater-than-or-equal operator for xr_tuple.

Parameters
[in]aThe xr_tuple to compare.
[in]bThe xr_tuple to compare against.
Returns
true if a >= b according to xr_tuple::cmp() , false otherwise.

The documentation for this class was generated from the following file: