| OpenMS 2.5.0

Public Member Functions | Protected Attributes | List of all members
SVOutStream Class Reference
Format

Stream class for writing to comma/tab/...-separated values files. More...

`#include <OpenMS/FORMAT/SVOutStream.h>`

Inheritance diagram for SVOutStream:

## Public Member Functions

| SVOutStream (const String &file_out, const String &sep="\, const String &replacement="_", String::QuotingMethod quoting=String::DOUBLE)
| Constructor. More...
| SVOutStream (std::ostream &out, const String &sep="\, const String &replacement="_", String::QuotingMethod quoting=String::DOUBLE)
| Constructor. More...
| ~SVOutStream () override
| Destructor. More...
SVOutStream & | operator<< (String str)
| Stream output operator for `String`. More...
SVOutStream & | operator<< (const std::string &str)
| Stream output operator for `std::string`. More...
SVOutStream & | operator<< (const char *c_str)
| Stream output operator for `char*`. More...
SVOutStream & | operator<< (const char c)
| Stream output operator for `char`. More...
SVOutStream & | operator<< (std::ostream &(*fp)(std::ostream &))
| Stream output operator for manipulators (used to catch `std::endl`) More...
SVOutStream & | operator<< (enum Newline)
| Stream output operator for custom newline (`nl`) without flushing. More...
template<typename T >
std::enable_if< std::is_arithmetic< typename std::remove_reference< T >::type >::value, SVOutStream & >::type | operator<< (const T &value)
template<typename T >
std::enable_if<!std::is_arithmetic< typename std::remove_reference< T >::type >::value, SVOutStream & >::type | operator<< (const T &value)
| Generic stream output operator (for non-character-based types) More...
SVOutStream & | write (const String &str)
| Unformatted output (no quoting: useful for comments, but use only on a line of its own!) More...
bool | modifyStrings (bool modify)
| Switch modification of strings (quoting/replacing of separators) on/off. More...
template<typename NumericT >
SVOutStream & | writeValueOrNan (NumericT thing)
| Write a numeric value or "nan"/"inf"/"-inf", if applicable (would not be needed for Linux) More...

## Protected Attributes

std::ofstream * | ofs_
| internal file stream when C'tor is called with a filename More...
String | sep_
| Separator string. More...
String | replacement_
| Replacement for separator. More...
String | nan_
| String to use for NaN values. More...
String | inf_
| String to use for Inf values. More...
String::QuotingMethod | quoting_
| String quoting method. More...
bool | modify_strings_
| On/off switch for modification of strings. More...
bool | newline_
| Are we at the beginning of a line? (Otherwise, insert separator before next item.) More...
std::stringstream | ss_
| Stream for testing if a manipulator is "std::endl". More...

## Detailed Description

Stream class for writing to comma/tab/...-separated values files.

Automatically inserts separators between items and handles quoting of strings. Requires `nl` (preferred) or `std::endl` as the line delimiter - `"\n"` won't be accepted.

## Constructor & Destructor Documentation

## ◆ SVOutStream() [1/2]

SVOutStream | ( | const String & | file_out | ) |

Constructor.

Parameters

  file_out | Output filename; will be overwritten if exists
  sep | Separator string (typically comma, semicolon, or tab)
  replacement | If `quoting` is `NONE`, used to replace occurrences of `sep` within strings before writing them
  quoting | Quoting method for strings (see `String::quote`)

## ◆ SVOutStream() [2/2]

SVOutStream | ( | std::ostream & | out | ) |

Constructor.

Parameters

  out | Output stream to write to (open file or `cout`)
  sep | Separator string (typically comma, semicolon, or tab)
  replacement | If `quoting` is `NONE`, used to replace occurrences of `sep` within strings before writing them
  quoting | Quoting method for strings (see `String::quote`)

## ◆ ~SVOutStream()

~SVOutStream | ( |  | ) |

override

Destructor.

Frees ofstream_* if filename c'tor was used.

## Member Function Documentation

## ◆ modifyStrings()

bool modifyStrings | ( | bool | modify | ) |

Switch modification of strings (quoting/replacing of separators) on/off.

Returns
  previous modification state

Referenced by NucleicAcidSearchEngine::generateLFQInput_().

## ◆ operator<<() [1/8]

SVOutStream& operator<< | ( | String | str | ) |

Stream output operator for `String`.

The argument is quoted before writing; it must not contain the newline character

## ◆ operator<<() [2/8]

SVOutStream& operator<< | ( | const std::string & | str | ) |

Stream output operator for `std::string`.

The argument is quoted before writing; it must not contain the newline character

## ◆ operator<<() [3/8]

SVOutStream& operator<< | ( | const char * | c_str | ) |

Stream output operator for `char*`.

The argument is quoted before writing; it must not contain the newline character

## ◆ operator<<() [4/8]

SVOutStream& operator<< | ( | const char | c | ) |

Stream output operator for `char`.

The argument is quoted before writing; it must not contain the newline character

## ◆ operator<<() [5/8]

SVOutStream& operator<< | ( | std::ostream &(*)(std::ostream &) | fp | ) |

Stream output operator for manipulators (used to catch `std::endl`)

## ◆ operator<<() [6/8]

SVOutStream& operator<< | ( | enum | Newline | ) |

Stream output operator for custom newline (`nl`) without flushing.

Use "nl" instead of "endl" for improved performance

## ◆ operator<<() [7/8]

std::enable_if<std::is_arithmetic<typename std::remove_reference<T>::type>::value, SVOutStream&>::type operator<< | ( | const T & | value | ) |

inline

numeric types should be converted to String first to make use of StringConversion

## ◆ operator<<() [8/8]

std::enable_if<!std::is_arithmetic<typename std::remove_reference<T>::type>::value, SVOutStream&>::type operator<< | ( | const T & | value | ) |

inline

Generic stream output operator (for non-character-based types)

## ◆ write()

SVOutStream& write | ( | const String & | str | ) |

Unformatted output (no quoting: useful for comments, but use only on a line of its own!)

## ◆ writeValueOrNan()

SVOutStream& writeValueOrNan | ( | NumericT | thing | ) |

inline

Write a numeric value or "nan"/"inf"/"-inf", if applicable (would not be needed for Linux)

References OpenMS::operator<<().

## Member Data Documentation

## ◆ inf_

String inf_

protected

String to use for Inf values.

## ◆ modify_strings_

bool modify_strings_

protected

On/off switch for modification of strings.

## ◆ nan_

String nan_

protected

String to use for NaN values.

## ◆ newline_

bool newline_

protected

Are we at the beginning of a line? (Otherwise, insert separator before next item.)

## ◆ ofs_

std::ofstream* ofs_

protected

internal file stream when C'tor is called with a filename

## ◆ quoting_

String::QuotingMethod quoting_

protected

String quoting method.

## ◆ replacement_

String replacement_

protected

Replacement for separator.

## ◆ sep_

String sep_

protected

Separator string.

## ◆ ss_

std::stringstream ss_

protected

Stream for testing if a manipulator is "std::endl".