Loading...
Searching...
No Matches
casacore::STLIO_global_functions_Container_IO Struct Reference
casa package (libcasa_casa) » BasicSL_module

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.
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.
template<typename T, typename U>
ostream & | operator<< (ostream &os, const std::pair< T, U > &p)
| Write a std::pair.
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.
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.
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.
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.
template<typename T>
LogIO & | operator<< (LogIO &os, const std::vector< T > &a)
| Print the contents of a container on LogIO.
template<typename T>
LogIO & | operator<< (LogIO &os, const std::set< T > &a)
template<typename T>
LogIO & | operator<< (LogIO &os, const std::list< T > &a)
template<typename T, typename U>
LogIO & | operator<< (LogIO &os, const std::map< T, U > &a)
template<typename T>
AipsIO & | operator>> (AipsIO &ios, std::vector< T > &)
| Read or write the contents of an STL vector from/to AipsIO.
template<typename T>
AipsIO & | operator<< (AipsIO &ios, const std::vector< T > &)
template<typename K, typename V>
AipsIO & | operator>> (AipsIO &ios, std::map< K, V > &)
| Read and write the contents of a map object from/to AipsIO.
template<typename K, typename V>
AipsIO & | operator<< (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

- STL container concept

### 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);
showContainer (cout, shape);
casacore::IPosition
Definition IPosition.h:117
casacore::shape
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
casacore::STLIO_global_functions_Container_IO::showContainer
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:109

### Motivation

Effortless input/output is clearly a big win.

Definition at line 93 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 168 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 171 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 165 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 162 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 144 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 153 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 117 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 135 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 126 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 109 of file STLIO.h.

References showDataIter().

Referenced by operator<<(), operator<<(), operator<<(), and 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].

References casacore::begin(), and casacore::end().

Referenced by showContainer().

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

- casa/BasicSL/STLIO.h