OKlibrary  0.2.1.6
OKlib::InputOutput::LiteralReadingExtended< Int > Class Template Reference

Extended policy, which allows arbitrary strings as variables. More...

#include <Dimacs.hpp>

List of all members.

Public Types

typedef Int int_type

Static Public Member Functions

static void read (std::istream &in, int_type &literal)
 Used by the Dimacs-parser to read a literal.
static int_type index (const std::string name)
static std::string name (const int_type index)
 The original name of an index; assumes a valid index.
static int_type number_variables ()
 The (precise) number of variables found in total.

Detailed Description

template<typename Int>
class OKlib::InputOutput::LiteralReadingExtended< Int >

Extended policy, which allows arbitrary strings as variables.

The Dimacs-parser uses member-function read(in, literal), where literal is an integer-reference, containing the literal converted to an integer.

The mapping between strings and natural numbers established so far is available as follows:

  • index(name) returns the index of a variable (runs in logarithmic time; return 0 if not found);
  • name(index) returns the name belonging to an index (runs in constant time, assumes a valid index).

Throws exceptions in case of syntax errors, according to the following restrictions on the strings:

  • They must be non-empty.
  • They must not contain space-symbols (more precisely, they are read in at once when streaming-in std::string).
  • A leading '-' is interpreted as negation.
  • A string equal "0" is the end-of-clause-marker.

Definition at line 102 of file Dimacs.hpp.


Member Typedef Documentation

template<typename Int>
typedef Int OKlib::InputOutput::LiteralReadingExtended< Int >::int_type

Definition at line 104 of file Dimacs.hpp.


Member Function Documentation

template<typename Int>
static int_type OKlib::InputOutput::LiteralReadingExtended< Int >::index ( const std::string  name) [inline, static]

The mapping from strings (representing variables) to natural numbers (in the order of occurrences in the input-stream). Returns 0 if string is not element of the domain of the map.

Definition at line 146 of file Dimacs.hpp.

Referenced by OKlib::InputOutput::LiteralReadingExtended< Int >::name().

template<typename Int>
static std::string OKlib::InputOutput::LiteralReadingExtended< Int >::name ( const int_type  index) [inline, static]

The original name of an index; assumes a valid index.

Definition at line 157 of file Dimacs.hpp.

References OKlib::InputOutput::LiteralReadingExtended< Int >::index().

template<typename Int>
static int_type OKlib::InputOutput::LiteralReadingExtended< Int >::number_variables ( ) [inline, static]

The (precise) number of variables found in total.

Definition at line 163 of file Dimacs.hpp.

template<typename Int>
static void OKlib::InputOutput::LiteralReadingExtended< Int >::read ( std::istream &  in,
int_type literal 
) [inline, static]

Used by the Dimacs-parser to read a literal.

Definition at line 115 of file Dimacs.hpp.

References BoolVarLit::neg.


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