Vince's CSV Parser
Loading...
Searching...
No Matches
csv_writer.hpp File Reference

A standalone header file for writing delimiter-separated files. More...

#include <cmath>
#include <fstream>
#include <iostream>
#include <memory>
#include <ranges>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <vector>
#include "common.hpp"
#include "data_type.hpp"

Go to the source code of this file.

Classes

struct  csv::internals::is_iterable< T, typename >
 SFINAE trait: detects if a type is iterable (has std::begin/end). More...
 
struct  csv::internals::is_iterable< T, typename std::enable_if< true >::type >
 
struct  csv::internals::is_tuple< T, typename >
 SFINAE trait: detects if a type is a std::tuple. More...
 
struct  csv::internals::is_tuple< T, typename std::enable_if< true >::type >
 
class  csv::DelimWriter< OutputStream, Delim, Quote, Flush >
 Class for writing delimiter separated values files. More...
 

Namespaces

namespace  csv
 The all encompassing namespace.
 

Functions

template<typename T = int>
T csv::internals::csv_abs (T x)
 Calculate the absolute value of a number.
 
template<>
int csv::internals::csv_abs (int x)
 
template<>
long int csv::internals::csv_abs (long int x)
 
template<>
long long int csv::internals::csv_abs (long long int x)
 
template<>
float csv::internals::csv_abs (float x)
 
template<>
double csv::internals::csv_abs (double x)
 
template<>
long double csv::internals::csv_abs (long double x)
 
template<typename T , csv::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
int csv::internals::num_digits (T x)
 Calculate the number of digits in a number.
 
template<typename T , csv::enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string csv::internals::to_string (T value)
 to_string() for unsigned integers
 

CSV Writing

template<class OutputStream , bool Flush = true>
using csv::CSVWriter = DelimWriter< OutputStream, ',', '"', Flush>
 An alias for csv::DelimWriter for writing standard CSV files.
 
template<class OutputStream , bool Flush = true>
using csv::TSVWriter = DelimWriter< OutputStream, '\t', '"', Flush>
 Class for writing tab-separated values files.
 
template<class OutputStream >
CSVWriter< OutputStream > csv::make_csv_writer (OutputStream &out, bool quote_minimal=true)
 Return a csv::CSVWriter over the output stream.
 
template<class OutputStream >
CSVWriter< OutputStream, false > csv::make_csv_writer_buffered (OutputStream &out, bool quote_minimal=true)
 Return a buffered csv::CSVWriter over the output stream (does not auto flush)
 
template<class OutputStream >
TSVWriter< OutputStream > csv::make_tsv_writer (OutputStream &out, bool quote_minimal=true)
 Return a csv::TSVWriter over the output stream.
 
template<class OutputStream >
TSVWriter< OutputStream, false > csv::make_tsv_writer_buffered (OutputStream &out, bool quote_minimal=true)
 Return a buffered csv::TSVWriter over the output stream (does not auto flush)
 

Detailed Description

A standalone header file for writing delimiter-separated files.

Definition in file csv_writer.hpp.

Function Documentation

◆ csv_abs() [1/7]

template<>
double csv::internals::csv_abs ( double  x)
inline

Definition at line 55 of file csv_writer.hpp.

◆ csv_abs() [2/7]

template<>
float csv::internals::csv_abs ( float  x)
inline

Definition at line 50 of file csv_writer.hpp.

◆ csv_abs() [3/7]

template<>
int csv::internals::csv_abs ( int  x)
inline

Definition at line 35 of file csv_writer.hpp.

◆ csv_abs() [4/7]

template<>
long double csv::internals::csv_abs ( long double  x)
inline

Definition at line 60 of file csv_writer.hpp.

◆ csv_abs() [5/7]

template<>
long int csv::internals::csv_abs ( long int  x)
inline

Definition at line 40 of file csv_writer.hpp.

◆ csv_abs() [6/7]

template<>
long long int csv::internals::csv_abs ( long long int  x)
inline

Definition at line 45 of file csv_writer.hpp.

◆ csv_abs() [7/7]

template<typename T = int>
T csv::internals::csv_abs ( T  x)
inline

Calculate the absolute value of a number.

Definition at line 30 of file csv_writer.hpp.

◆ num_digits()

template<typename T , csv::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
int csv::internals::num_digits ( T  x)

Calculate the number of digits in a number.

Definition at line 71 of file csv_writer.hpp.

◆ to_string()

template<typename T , csv::enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string csv::internals::to_string ( T  value)
inline

to_string() for unsigned integers

to_string() for floating point numbers

to_string() for signed integers

Definition at line 88 of file csv_writer.hpp.