dlvhex
2.5.0
|
Helpers for printing objects to streams. More...
#include <boost/range/iterator_range.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/optional.hpp>
#include <iostream>
#include <sstream>
#include <set>
#include <vector>
Go to the source code of this file.
Data Structures | |
class | ostream_printable< T > |
With this class, you can make your own classes ostream-printable. More... | |
struct | print_container |
Printable object base class. More... | |
struct | print_stream_container< T > |
Printable object base class. More... | |
struct | print_method_container |
Printable object base class. More... | |
Functions | |
std::ostream & | operator<< (std::ostream &o, print_container *c) |
Streaming operator. | |
template<typename T > | |
print_container * | print_method (const T &t) |
This can be used if T contains a method "ostream& print(ostream&) const". | |
print_container * | print_function (const print_method_container::PrintFn &fn) |
This can be used if some third party method is used to print T. | |
template<typename T > | |
print_container * | printopt (const boost::optional< T > &t) |
Create a print_container for an object only if it is defined. | |
template<typename T > | |
print_container * | printptr (const boost::shared_ptr< T > &t) |
Create a print_container pointer for an object only if it is defined. | |
template<typename T > | |
print_container * | printptr (const boost::shared_ptr< const T > &t) |
Create a print_container pointer for an object only if it is defined. | |
template<typename T > | |
print_container * | printptr (const T *const t) |
Create a print_container pointer for an object only if it is defined. | |
template<typename Range > | |
print_container * | printrange (Range r, const char *open="<", const char *sep=",", const char *close=">") |
Creates a print_container pointer for multiple objects. | |
template<typename T > | |
print_container * | printset (const std::set< T > &t, const char *open="{", const char *sep=",", const char *close="}") |
Creates a print_container pointer for multiple objects in set notation. | |
template<typename T > | |
print_container * | printvector (const std::vector< T > &t, const char *open="[", const char *sep=",", const char *close="]") |
Creates a print_container pointer for multiple objects in vector notation. |
Helpers for printing objects to streams.
Definition in file Printhelpers.h.
std::ostream& operator<< | ( | std::ostream & | o, |
print_container * | c | ||
) | [inline] |
Streaming operator.
o | Output stream to print to. |
c | Container to print using print_container::print. |
o
. Definition at line 104 of file Printhelpers.h.
References print_container::print().
print_container* print_function | ( | const print_method_container::PrintFn & | fn | ) | [inline] |
This can be used if some third party method is used to print T.
E.g. std::ostream& BAR::printFOO(std::ostream& o, const FOO& p) const is printed as ... << print_function(boost::bind(&BAR::printFOO, &bar, _1, foo)) << ... .
fn | print_method_container to create a print_container for. |
fn
. Definition at line 164 of file Printhelpers.h.
Referenced by State::changeState(), and OnlineModelBuilder< EvalGraphT >::printEUMBP().
print_container* print_method | ( | const T & | t | ) | [inline] |
This can be used if T contains a method "ostream& print(ostream&) const".
t | Object to create a container for. |
t
. Definition at line 150 of file Printhelpers.h.
Referenced by OnlineModelBuilder< EvalGraphT >::advanceOModelForIModel().
print_container* printopt | ( | const boost::optional< T > & | t | ) | [inline] |
Create a print_container for an object only if it is defined.
t | Object to print, can be undefined using boost::optional. |
t
if defined and a dummy container otherwise. Definition at line 175 of file Printhelpers.h.
Referenced by OnlineModelBuilder< EvalGraphT >::advanceOModelForIModel(), OnlineModelBuilder< EvalGraphT >::getNextIModel(), OnlineModelBuilder< EvalGraphT >::getNextOModel(), and OnlineModelBuilder< EvalGraphT >::printEUMBPhelper().
print_container* printptr | ( | const boost::shared_ptr< T > & | t | ) | [inline] |
Create a print_container pointer for an object only if it is defined.
t | Object to print, can be undefined using boost::optional. |
t
if defined and a dummy container otherwise. Definition at line 188 of file Printhelpers.h.
Referenced by OfflineModelBuilder< EvalGraphT >::buildIModelsRecursively(), OfflineModelBuilder< EvalGraphT >::buildOModelsRecursively(), OnlineModelBuilder< EvalGraphT >::createIModelFromPredecessorOModels(), TestModelGeneratorFactory::createModelGenerator(), EvaluateState::evaluate(), ModelBuilder< EvalGraphT >::ModelProperties::print(), ExternalAtom::print(), OnlineModelBuilder< EvalGraphT >::printEUMBPhelper(), and OnlineModelBuilder< EvalGraphT >::printEvalGraphModelGraph().
print_container* printptr | ( | const boost::shared_ptr< const T > & | t | ) | [inline] |
Create a print_container pointer for an object only if it is defined.
t | Object to print, can be undefined using boost::optional. |
t
if defined and a dummy container otherwise. Definition at line 202 of file Printhelpers.h.
print_container* printptr | ( | const T *const | t | ) | [inline] |
Create a print_container pointer for an object only if it is defined.
t | Object to print, can be undefined using boost::optional. |
t
if defined and a dummy container otherwise. Definition at line 216 of file Printhelpers.h.
print_container* printrange | ( | Range | r, |
const char * | open = "<" , |
||
const char * | sep = "," , |
||
const char * | close = ">" |
||
) | [inline] |
Creates a print_container pointer for multiple objects.
r | Objects to print, can be undefined using boost::optional. |
open | Begin character. |
sep | Character to be printed between the objects in r . |
close | End character. |
r
.Example: std::cerr << ... << printrange(Range r) << ...;
Definition at line 237 of file Printhelpers.h.
Referenced by BOOST_FIXTURE_TEST_CASE(), EvalHeuristicOldDlvhex::build(), EvalHeuristicEasy::build(), EvalHeuristicGreedy::build(), DLVHEX_NAMESPACE_BEGIN::EvalHeuristicFromHEXSourcecode::build(), ComponentGraph::calculateComponents(), ComponentGraph::collapseComponents(), ComponentGraph::computeCollapsedComponentInfos(), sem< StrongNegationParserModuleSemantics::stronglyNegatedPrefixAtom >::createAtom(), sem< HexGrammarSemantics::classicalAtomFromPrefix >::createAtom(), DependencyGraph::createAuxiliaryRuleIfRequired(), DumpingEvalGraphBuilder::createEvalUnit(), EvalGraphBuilder::createEvalUnit(), DependencyGraph::createHeadBodyUnifyingDependencies(), BaseModelGenerator::evaluateExternalAtomQuery(), BaseModelGenerator::IntegrateExternalAnswerIntoInterpretationCB::output(), DLVHEX_NAMESPACE_BEGIN::EvalHeuristicFromHEXSourcecode::preprocessComponents(), ComponentGraph::ComponentInfo::print(), ComfortInterpretation::print(), printset(), printvector(), ProgramCtx::processPluginOptions(), TestPluginAtomReach::retrieve(), ComfortPluginAtom::retrieve(), TestSetMinusAtom::retrieve(), internal::transitivePredecessorComponents(), internalgreedy::transitivePredecessorComponents(), and ComponentGraph::writeGraphVizComponentLabel().
print_container* printset | ( | const std::set< T > & | t, |
const char * | open = "{" , |
||
const char * | sep = "," , |
||
const char * | close = "}" |
||
) | [inline] |
Creates a print_container pointer for multiple objects in set notation.
t | Objects to print, can be undefined using boost::optional. |
open | Begin character. |
sep | Character to be printed between the objects in r . |
close | End character. |
r
.Example: std::cerr << ... << printset(std::set<T>) << ...;
Definition at line 266 of file Printhelpers.h.
References printrange().
Referenced by DLVHEX_NAMESPACE_BEGIN::EvalHeuristicFromHEXSourcecode::build(), FLPModelGeneratorFactoryBase::createFLPRules(), CAUAlgorithms::AncestryMarkingVisitor< Graph >::examine_edge(), CAUAlgorithms::logAPM(), sem< QueryParserModuleSemantics::queryBody >::operator()(), ComfortPluginAtom::retrieve(), PredicateMask::updateMask(), and verifyModels().
print_container* printvector | ( | const std::vector< T > & | t, |
const char * | open = "[" , |
||
const char * | sep = "," , |
||
const char * | close = "]" |
||
) | [inline] |
Creates a print_container pointer for multiple objects in vector notation.
t | Objects to print, can be undefined using boost::optional. |
open | Begin character. |
sep | Character to be printed between the objects in r . |
close | End character. |
r
.Example: std::cerr << ... << printvector(std::vector<T>) << ...;
Definition at line 284 of file Printhelpers.h.
References printrange().
Referenced by DependencyGraph::createAuxiliaryRuleIfRequired(), DependencyGraph::createHeadBodyUnifyingDependencies(), DependencyGraph::createHeadHeadUnifyingDependencies(), evalheur::executeBuildCommands(), OrdinaryAtom::existsHomomorphism(), ProcessBuf::open(), OrdinaryAtom::print(), Rule::print(), BuiltinAtom::print(), AggregateAtom::print(), Registry::print(), ExternalAtom::print(), ModuleAtom::print(), OrdinaryAtom::unifiesWith(), and ComfortAtom::unifiesWith().