casacore
Public Member Functions | List of all members
casacore::STLIO_global_functions_Container_IO Struct Reference

More...

#include <STLIO.h>

Public Member Functions

template<class ITER >
void showDataIter (ostream &, ITER begin, const ITER &end, const char *separator=",", const char *prefix="[", const char *postfix="]")
 Write out an ascii representation of any container using the given begin and end iterator. More...
 
template<class CONTAINER >
void showContainer (ostream &os, const CONTAINER &c, const char *separator=",", const char *prefix="[", const char *postfix="]")
 Write out an ascii representation of any container having a forward iterator. More...
 
template<typename T , typename U >
ostream & operator<< (ostream &os, const std::pair< T, U > &p)
 Write a std::pair. More...
 
template<typename T >
ostream & operator<< (ostream &os, const std::vector< T > &v)
 Write the contents of a vector enclosed in square brackets, using a comma as separator. More...
 
template<typename T >
ostream & operator<< (ostream &os, const std::set< T > &v)
 Write the contents of a set enclosed in square brackets, using a comma as separator. More...
 
template<typename T >
ostream & operator<< (ostream &os, const std::list< T > &v)
 Write the contents of a list enclosed in square brackets, using a comma as separator. More...
 
template<typename T , typename U >
ostream & operator<< (ostream &os, const std::map< T, U > &m)
 Print the contents of a map enclosed in braces, using a comma as separator. More...
 
template<typename T >
LogIOoperator<< (LogIO &os, const std::vector< T > &a)
 Print the contents of a container on LogIO. More...
 
template<typename T >
LogIOoperator<< (LogIO &os, const std::set< T > &a)
 
template<typename T >
LogIOoperator<< (LogIO &os, const std::list< T > &a)
 
template<typename T , typename U >
LogIOoperator<< (LogIO &os, const std::map< T, U > &a)
 
template<typename T >
AipsIOoperator>> (AipsIO &ios, std::vector< T > &)
 Read or write the contents of an STL vector from/to AipsIO. More...
 
template<typename T >
AipsIOoperator<< (AipsIO &ios, const std::vector< T > &)
 
template<typename K , typename V >
AipsIOoperator>> (AipsIO &ios, std::map< K, V > &)
 Read and write the contents of a map object from/to AipsIO. More...
 
template<typename K , typename V >
AipsIOoperator<< (AipsIO &ios, const std::map< K, V > &)
 

Detailed Description

Input/output operators for STL-like containers.

Intended use:

Public interface

Review Status

Reviewed By:
Paul Shannon
Date Reviewed:
1995/02/21

Prerequisite

Synopsis

The function showContainer makes it possible to show any STL-like container (having forward iterators) on an ostream. This include casacore classes like Array, IPosition, and Block, but also STL classes like vector. The separator, prefix, and postfix can be defined at will (they default to, [ ]).

The function showDataIter is similar to showContainer, but uses iterators directly.

Example

IPosition shape (3,10,10,3);
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
void showContainer(ostream &os, const CONTAINER &c, const char *separator=",", const char *prefix="[", const char *postfix="]")
Write out an ascii representation of any container having a forward iterator.
Definition: STLIO.h:111

Motivation

Effortless input/output is clearly a big win.


Definition at line 95 of file STLIO.h.

Member Function Documentation

◆ operator<<() [1/11]

template<typename K , typename V >
AipsIO& casacore::STLIO_global_functions_Container_IO::operator<< ( AipsIO ios,
const std::map< K, V > &   
)

◆ operator<<() [2/11]

template<typename T >
AipsIO& casacore::STLIO_global_functions_Container_IO::operator<< ( AipsIO ios,
const std::vector< T > &   
)

◆ operator<<() [3/11]

template<typename T >
LogIO& casacore::STLIO_global_functions_Container_IO::operator<< ( LogIO os,
const std::list< T > &  a 
)
inline

Definition at line 170 of file STLIO.h.

References casacore::LogIO::output().

◆ operator<<() [4/11]

template<typename T , typename U >
LogIO& casacore::STLIO_global_functions_Container_IO::operator<< ( LogIO os,
const std::map< T, U > &  a 
)
inline

Definition at line 173 of file STLIO.h.

References casacore::LogIO::output().

◆ operator<<() [5/11]

template<typename T >
LogIO& casacore::STLIO_global_functions_Container_IO::operator<< ( LogIO os,
const std::set< T > &  a 
)
inline

Definition at line 167 of file STLIO.h.

References casacore::LogIO::output().

◆ operator<<() [6/11]

template<typename T >
LogIO& casacore::STLIO_global_functions_Container_IO::operator<< ( LogIO os,
const std::vector< T > &  a 
)
inline

Print the contents of a container on LogIO.

Definition at line 164 of file STLIO.h.

References casacore::LogIO::output().

◆ operator<<() [7/11]

template<typename T >
ostream& casacore::STLIO_global_functions_Container_IO::operator<< ( ostream &  os,
const std::list< T > &  v 
)
inline

Write the contents of a list enclosed in square brackets, using a comma as separator.

Definition at line 146 of file STLIO.h.

References showContainer().

◆ operator<<() [8/11]

template<typename T , typename U >
ostream& casacore::STLIO_global_functions_Container_IO::operator<< ( ostream &  os,
const std::map< T, U > &  m 
)
inline

Print the contents of a map enclosed in braces, using a comma as separator.

Definition at line 155 of file STLIO.h.

References showContainer().

◆ operator<<() [9/11]

template<typename T , typename U >
ostream& casacore::STLIO_global_functions_Container_IO::operator<< ( ostream &  os,
const std::pair< T, U > &  p 
)
inline

Write a std::pair.

Definition at line 119 of file STLIO.h.

◆ operator<<() [10/11]

template<typename T >
ostream& casacore::STLIO_global_functions_Container_IO::operator<< ( ostream &  os,
const std::set< T > &  v 
)
inline

Write the contents of a set enclosed in square brackets, using a comma as separator.

Definition at line 137 of file STLIO.h.

References showContainer().

◆ operator<<() [11/11]

template<typename T >
ostream& casacore::STLIO_global_functions_Container_IO::operator<< ( ostream &  os,
const std::vector< T > &  v 
)
inline

Write the contents of a vector enclosed in square brackets, using a comma as separator.

Definition at line 128 of file STLIO.h.

References showContainer().

◆ operator>>() [1/2]

template<typename K , typename V >
AipsIO& casacore::STLIO_global_functions_Container_IO::operator>> ( AipsIO ios,
std::map< K, V > &   
)

Read and write the contents of a map object from/to AipsIO.

It is done in the same way as the old SimpleOrderedMap class, so persistent SimpleOrderedMap objects in CTDS can be read as std::map and vice-versa.

◆ operator>>() [2/2]

template<typename T >
AipsIO& casacore::STLIO_global_functions_Container_IO::operator>> ( AipsIO ios,
std::vector< T > &   
)

Read or write the contents of an STL vector from/to AipsIO.

The container is written in the same way as Block, thus can be read back that way and vice-versa.

◆ showContainer()

template<class CONTAINER >
void casacore::STLIO_global_functions_Container_IO::showContainer ( ostream &  os,
const CONTAINER &  c,
const char *  separator = ",",
const char *  prefix = "[",
const char *  postfix = "]" 
)
inline

Write out an ascii representation of any container having a forward iterator.

Note that a multi-dimensional Array object is linearized. An arbitrary separator, prefix, and postfix can be given. E.g. for separator ', ' the output looks like [1, 2, 3].

Definition at line 111 of file STLIO.h.

References casacore::C::c, and showDataIter().

Referenced by operator<<().

◆ showDataIter()

template<class ITER >
void casacore::STLIO_global_functions_Container_IO::showDataIter ( ostream &  ,
ITER  begin,
const ITER &  end,
const char *  separator = ",",
const char *  prefix = "[",
const char *  postfix = "]" 
)

Write out an ascii representation of any container using the given begin and end iterator.

An arbitrary separator, prefix, and postfix can be given. E.g. for separator ', ' the output looks like [1, 2, 3].

Referenced by showContainer().


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