JASSv2
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
JASS::query_term Class Reference

Details of a query term as parsed from the query. More...

#include <query_term.h>

Collaboration diagram for JASS::query_term:
Collaboration graph
[legend]

Public Member Functions

 query_term ()
 Constructor for an empty object.
 
 query_term (const query_term &original)
 Copy constructor. More...
 
 query_term (const slice &term, size_t query_frequency=1)
 Constructor. More...
 
 operator std::string () const
 Convert to a std::string. Useful for serialising.
 
slice token (void) const
 Return the token as a slice. More...
 
size_t frequency () const
 Return the frequency of this term in this query. More...
 
bool operator< (const query_term &with) const
 Convert to a std::string. Useful for serialising.
 

Static Public Member Functions

static void unittest (void)
 Unit test this class.
 

Private Attributes

slice term
 The term. Note that the memory is kept elsewhere.
 
size_t query_frequency
 Number of times the term occurs in the query.
 

Friends

class query_term_list
 
std::ostream & operator<< (std::ostream &stream, const query_term &term)
 Dump the contents of a query_term down an output stream. More...
 

Detailed Description

Details of a query term as parsed from the query.

Objects of this type are generated by the query parsers and used to pass around details of a term used in a query

Constructor & Destructor Documentation

◆ query_term() [1/2]

JASS::query_term::query_term ( const query_term original)
inline

Copy constructor.

Parameters
original[in] object to copy (note:n This is a shallow copy).

◆ query_term() [2/2]

JASS::query_term::query_term ( const slice term,
size_t  query_frequency = 1 
)
inline

Constructor.

Parameters
term[in] Term that this object reprrsents.
query_frequency[in] the number of times the term occurs in the query.

Create a new query term object from a string and a frequency. Node that the term slice is copied and that the term is nod duplicated. That is, the memory containing the query term belongs to the caller and not to this object. This isn't a problem because ll memory associated with processing a query should be in a single allocator object.

Member Function Documentation

◆ frequency()

size_t JASS::query_term::frequency ( ) const
inline

Return the frequency of this term in this query.

Returns
The frequency

◆ token()

slice JASS::query_term::token ( void  ) const
inline

Return the token as a slice.

Returns
The token.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const query_term term 
)
friend

Dump the contents of a query_term down an output stream.

Parameters
stream[in] The stream to write to.
term[in] The query_term to write.
Returns
The stream once the slice has been written.

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