Generated on for Gecode by doxygen 1.17.0
Test::Instance::Data Class Reference

Named values read from an instance. More...

#include <gecode/instance.hh>

Public Member Functions

 Data (void)
 Empty data.

Entries

int entries (void) const
 Return number of entries.
std::string name (int i) const
 Return name of entry i, in the order they were defined.
bool has (const std::string &n) const
 Test whether there is an entry n.
ValueType type (const std::string &n) const
 Return the value type of entry n.
int depth (const std::string &n) const
 Return the depth of entry n (0 for scalars).

Values

int size (const std::string &n, const IntArgs &path=IntArgs()) const
 Return the length of the array or row n at path.
long long int integer (const std::string &n, const IntArgs &path=IntArgs()) const
 Return the integer n at path.
double number (const std::string &n, const IntArgs &path=IntArgs()) const
 Return the number n at path (integers are converted).
std::string text (const std::string &n, const IntArgs &path=IntArgs()) const
 Return the string n at path.
IntArgs ints (const std::string &n, const IntArgs &path=IntArgs()) const
 Return all integers in the array or row n at path.
ArgArray< double > numbers (const std::string &n, const IntArgs &path=IntArgs()) const
 Return all numbers in the array or row n at path.

Output

void dzn (std::ostream &os) const
 Print all entries as MiniZinc data.

Detailed Description

Named values read from an instance.

Every entry has a name, a value type (see ValueType), and a depth: depth 0 is a scalar, depth 1 an array, depth 2 an array of arrays, and so on. Arrays may be ragged, that is, rows can have different lengths.

The accessors take a path of indices (from 0) that selects a row or a single value, such as d.ints("clause", {3}) for row 3 of clause or d.text("s", {1, 0, 2}); without a path they refer to the whole entry. They throw Error if the name is unknown, if the value has the wrong type or depth, if an index is out of range, or if an integer does not fit into an int.

Definition at line 406 of file instance.hh.

Constructor & Destructor Documentation

◆ Data()

Empty data.

Definition at line 354 of file data.cpp.

Member Function Documentation

◆ entries()

int Gecode::Instance::Data::entries ( void ) const

Return number of entries.

Definition at line 358 of file data.cpp.

◆ name()

std::string Gecode::Instance::Data::name ( int i) const

Return name of entry i, in the order they were defined.

Definition at line 363 of file data.cpp.

◆ has()

bool Gecode::Instance::Data::has ( const std::string & n) const

Test whether there is an entry n.

Definition at line 370 of file data.cpp.

◆ type()

ValueType Gecode::Instance::Data::type ( const std::string & n) const

Return the value type of entry n.

Definition at line 375 of file data.cpp.

◆ depth()

int Gecode::Instance::Data::depth ( const std::string & n) const

Return the depth of entry n (0 for scalars).

Definition at line 380 of file data.cpp.

◆ size()

int Gecode::Instance::Data::size ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return the length of the array or row n at path.

Definition at line 385 of file data.cpp.

◆ integer()

long long int Gecode::Instance::Data::integer ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return the integer n at path.

Definition at line 390 of file data.cpp.

◆ number()

double Gecode::Instance::Data::number ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return the number n at path (integers are converted).

Definition at line 395 of file data.cpp.

◆ text()

std::string Gecode::Instance::Data::text ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return the string n at path.

Definition at line 400 of file data.cpp.

◆ ints()

IntArgs Gecode::Instance::Data::ints ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return all integers in the array or row n at path.

Definition at line 405 of file data.cpp.

◆ numbers()

ArgArray< double > Gecode::Instance::Data::numbers ( const std::string & n,
const IntArgs & path = IntArgs() ) const

Return all numbers in the array or row n at path.

Definition at line 410 of file data.cpp.

◆ dzn()

void Gecode::Instance::Data::dzn ( std::ostream & os) const

Print all entries as MiniZinc data.

Rectangular arrays of up to six dimensions are printed as MiniZinc arrays, so the form depends on the data: rows that happen to have equal lengths give a two-dimensional array. Other arrays are printed as arrays of 1-tuples of arrays (MiniZinc 2.7 or later), preceded by a comment with its type, for example

% x: array[int] of tuple(array[int] of int)
x = [([5],), ([6, 7],)];

where row i is x[i].1.

Definition at line 537 of file data.cpp.


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