dlvhex  2.5.0
ComfortTerm Struct Reference

String-based term object (comfort interface). More...

#include <include/dlvhex2/ComfortPluginInterface.h>

Inheritance diagram for ComfortTerm:
Collaboration diagram for ComfortTerm:

Public Types

enum  Type { STR, INT }

Public Member Functions

bool isConstant () const
 detect whether object stores a constant.
bool isVariable () const
 detect whether object stores a variable.
bool isInteger () const
 detect whether object stores an integer.
bool isAnon () const
 detect whether object stores an anonymous variable.
bool operator== (const ComfortTerm &other) const
 Check equality.
bool operator!= (const ComfortTerm &other) const
 Check inequality.
bool operator< (const ComfortTerm &other) const
 Compare terms.
std::ostream & print (std::ostream &o) const
 Print term (using ostream_printable<T>).
 ComfortTerm ()
 Constructor.
 ComfortTerm (int intval)
 Constructor for integer terms.
 ComfortTerm (std::string strval, bool addQuotes=false)
 Constructor for constant or string terms.
std::string getUnquotedString () const
 Retrieves the term as string without quotes, independent if it is stored with or without quotes.
std::string getString () const
 Retrieves the internal term as string.
std::string getVariable () const
 Retrieves the internal term as string.

Static Public Member Functions

static ComfortTerm createVariable (const std::string &s)
 Construct variable term.
static ComfortTerm createConstant (const std::string &s)
 Construct constant term.
static ComfortTerm createInteger (int i)
 Construct integer term.

Data Fields

Type type
 Type of stored content.
std::string strval
 String content storage.
int intval
 Integer content storage.

Protected Member Functions

 ComfortTerm (Type type, const std::string &strval, int intval)
 Constructor.

Detailed Description

String-based term object (comfort interface).

This term object stores integers or strings, where strings can be constants or variables.

You can stream instances of this class into std::ostream&.

Definition at line 82 of file ComfortPluginInterface.h.


Member Enumeration Documentation

Enumerator:
STR 

String term.

INT 

Integer term.

Definition at line 85 of file ComfortPluginInterface.h.


Constructor & Destructor Documentation

ComfortTerm::ComfortTerm ( Type  type,
const std::string &  strval,
int  intval 
) [inline, protected]

Constructor.

Use "create..." functions to create comfort terms.

Parameters:
typeSee ComfortTerm::type.
strvalSee ComfortTerm::strval.
intvalSee ComfortTerm::intval.

Definition at line 219 of file ComfortPluginInterface.h.

Constructor.

Definition at line 224 of file ComfortPluginInterface.h.

ComfortTerm::ComfortTerm ( int  intval) [inline]

Constructor for integer terms.

Parameters:
intvalInteger.

Definition at line 228 of file ComfortPluginInterface.h.

ComfortTerm::ComfortTerm ( std::string  strval,
bool  addQuotes = false 
) [inline]

Constructor for constant or string terms.

Parameters:
strvalValue.
addQuotesTrue to store "\p strval" and false to store strval.

Definition at line 234 of file ComfortPluginInterface.h.


Member Function Documentation

static ComfortTerm ComfortTerm::createConstant ( const std::string &  s) [inline, static]

Construct constant term.

Parameters:
sString representation of the constant term.
Returns:
Term.

Definition at line 154 of file ComfortPluginInterface.h.

Referenced by ComfortInterpretation::keep(), ComfortInterpretation::matchPredicate(), ComfortInterpretation::remove(), TestAAtom::retrieve(), and TestBAtom::retrieve().

static ComfortTerm ComfortTerm::createInteger ( int  i) [inline, static]

Construct integer term.

Parameters:
iString representation of the integer term.
Returns:
Term.

Definition at line 162 of file ComfortPluginInterface.h.

Referenced by TestMinusOneAtom::retrieve().

static ComfortTerm ComfortTerm::createVariable ( const std::string &  s) [inline, static]

Construct variable term.

Parameters:
sString representation of the term.
Returns:
Term.

Definition at line 146 of file ComfortPluginInterface.h.

std::string ComfortTerm::getString ( ) const [inline]

Retrieves the internal term as string.

Returns:
Internal term as string (including quotes if stored).

Definition at line 251 of file ComfortPluginInterface.h.

std::string ComfortTerm::getUnquotedString ( ) const [inline]

Retrieves the term as string without quotes, independent if it is stored with or without quotes.

Returns:
Term as string without quotes, independent if it is stored with or without quotes.

Definition at line 241 of file ComfortPluginInterface.h.

std::string ComfortTerm::getVariable ( ) const [inline]

Retrieves the internal term as string.

Returns:
Internal variable as string.

Definition at line 258 of file ComfortPluginInterface.h.

bool ComfortTerm::isAnon ( ) const [inline]

detect whether object stores an anonymous variable.

Returns:
True if anonymous variable and false otherwise.

Definition at line 138 of file ComfortPluginInterface.h.

bool ComfortTerm::isConstant ( ) const [inline]

detect whether object stores a constant.

Returns:
True if constant and false otherwise.

Definition at line 118 of file ComfortPluginInterface.h.

bool ComfortTerm::isInteger ( ) const [inline]

detect whether object stores an integer.

Returns:
True if integer and false otherwise.

Definition at line 132 of file ComfortPluginInterface.h.

Referenced by print().

bool ComfortTerm::isVariable ( ) const [inline]

detect whether object stores a variable.

Returns:
True if variable and false otherwise.

Definition at line 125 of file ComfortPluginInterface.h.

bool ComfortTerm::operator!= ( const ComfortTerm other) const [inline]

Check inequality.

Parameters:
otherTerm to compare to.
Returns:
True if this term is not equal to other and false otherwise.

Definition at line 183 of file ComfortPluginInterface.h.

bool ComfortTerm::operator< ( const ComfortTerm other) const [inline]

Compare terms.

We require this for storing ComfortTerm in sets.

Parameters:
otherTerm to compare to.
Returns:
True if this term is smaller than other and false otherwise.

Definition at line 193 of file ComfortPluginInterface.h.

References intval, strval, and type.

bool ComfortTerm::operator== ( const ComfortTerm other) const [inline]

Check equality.

Parameters:
otherTerm to compare to.
Returns:
True if this term is equal to other and false otherwise.

Definition at line 170 of file ComfortPluginInterface.h.

References intval, strval, and type.

std::ostream & ComfortTerm::print ( std::ostream &  o) const

Print term (using ostream_printable<T>).

Non-virtual on purpose. (see Printhelpers.h)

Parameters:
oStream to print to.
Returns:
o.

Definition at line 56 of file ComfortPluginInterface.cpp.

References intval, isInteger(), and strval.


Field Documentation

Integer content storage.

Only relevant if type == INT.

Definition at line 112 of file ComfortPluginInterface.h.

Referenced by operator<(), operator==(), and print().

std::string ComfortTerm::strval

String content storage.

Only relevant if type == STR.

Definition at line 105 of file ComfortPluginInterface.h.

Referenced by ComfortAtom::isStrongNegated(), operator<(), operator==(), and print().

Type of stored content.

Indicates, whether strval or intval contains relevant data.

Definition at line 98 of file ComfortPluginInterface.h.

Referenced by operator<(), and operator==().


The documentation for this struct was generated from the following files: