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 "basic_csv_parser_simd.hpp"
#include "common.hpp"
#include "csv_exceptions.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 >
 Class for writing delimiter separated values files. More...
 

Namespaces

namespace  csv
 The all encompassing namespace.
 

Functions

template<typename T >
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 (const T &n) noexcept
 Compute 10 to the power of an integral exponent.
 
template<>
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 (const unsigned &n) noexcept
 
template<typename T = int>
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 >
using csv::CSVWriter = DelimWriter< OutputStream, ',', '"'>
 An alias for csv::DelimWriter for writing standard CSV files.
 
template<class OutputStream >
using csv::TSVWriter = DelimWriter< OutputStream, '\t', '"'>
 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 >
TSVWriter< OutputStream > csv::make_tsv_writer (OutputStream &out, bool quote_minimal=true)
 Return a csv::TSVWriter over the output stream.
 

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 86 of file csv_writer.hpp.

◆ csv_abs() [2/7]

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

Definition at line 81 of file csv_writer.hpp.

◆ csv_abs() [3/7]

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

Definition at line 66 of file csv_writer.hpp.

◆ csv_abs() [4/7]

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

Definition at line 91 of file csv_writer.hpp.

◆ csv_abs() [5/7]

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

Definition at line 71 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 76 of file csv_writer.hpp.

◆ csv_abs() [7/7]

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

Calculate the absolute value of a number.

Definition at line 61 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 ( x)

Calculate the number of digits in a number.

Definition at line 102 of file csv_writer.hpp.

◆ pow10() [1/2]

template<typename T >
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 ( const T &  n)
noexcept

Compute 10 to the power of an integral exponent.

Definition at line 30 of file csv_writer.hpp.

◆ pow10() [2/2]

template<>
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 ( const unsigned &  n)
noexcept

Definition at line 46 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 ( value)
inline

to_string() for unsigned integers

to_string() for floating point numbers

to_string() for signed integers

Definition at line 115 of file csv_writer.hpp.