OSVR-Core
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
osvr::util::CSVBase< Derived > Class Template Reference

(Base) Class for easily outputting CSV files. More...

#include <CSV.h>

Inheritance diagram for osvr::util::CSVBase< Derived >:
osvr::util::detail::CSVCommonBase

Public Types

using RowProxy = detail::CSVRowProxy< Derived >
 
- Public Types inherited from osvr::util::detail::CSVCommonBase
using DataRow = std::vector< std::string >
 
using column_id = std::size_t
 

Public Member Functions

RowProxy row ()
 Main call for the CSV object: returns a proxy object that you can redirect "cells" into, in order to add them to a new row in the CSV table. More...
 
std::size_t numDataRows () const
 Gets the number of rows in the internal data storage. More...
 
std::size_t numRows () const
 Gets the total number of rows that have been streamed/added to this CSV object, whether or not they're in the internal data storage. More...
 
- Public Member Functions inherited from osvr::util::detail::CSVCommonBase
column_id getColumn (std::string const &heading)
 
column_id numColumns () const
 

Protected Member Functions

void prepareForRow ()
 Called by CSVRowProxy life cycle, on row creation.
 
void dataForLatestRow (std::string const &heading, std::string const &data)
 Called by CSVRowProxy life cycle, on cell addition.
 
void finalizeLatestRow ()
 Called by CSVRowProxy life cycle, on destruction of active row proxy. More...
 
DataRow & latestRow ()
 Called internally and potentially by derived classes for access to the "latest row" temporary storage. More...
 
void outputRow (std::ostream &os, DataRow const &row) const
 Called by outputData() and by derived classes to format individual rows. More...
 
void outputData (std::ostream &os) const
 Called by derived classes to output stored data rows.
 
void moveLatestRowToData ()
 utility function for use in derived finalizeLatestRow()
 
- Protected Member Functions inherited from osvr::util::detail::CSVCommonBase
void outputHeaders (std::ostream &os) const
 

Friends

class detail::CSVRowProxy< Derived >
 

Detailed Description

template<typename Derived>
class osvr::util::CSVBase< Derived >

(Base) Class for easily outputting CSV files.

Just call the .row() method and feed it << cell("header", yourdata) << cell("anotherheader", moredata); for as many rows as you want (one row call per row, of course).

Methods of outputting the CSV data to an ostream vary between subclasses. This is a "curiously-recurring template pattern" base class for compile-time polymorphism.

Member Function Documentation

§ finalizeLatestRow()

template<typename Derived>
void osvr::util::CSVBase< Derived >::finalizeLatestRow ( )
inlineprotected

Called by CSVRowProxy life cycle, on destruction of active row proxy.

Delegates to derived classes, since this is a variance between them.

§ latestRow()

template<typename Derived>
DataRow& osvr::util::CSVBase< Derived >::latestRow ( )
inlineprotected

Called internally and potentially by derived classes for access to the "latest row" temporary storage.

§ numDataRows()

template<typename Derived>
std::size_t osvr::util::CSVBase< Derived >::numDataRows ( ) const
inline

Gets the number of rows in the internal data storage.

Note that if the particular specialized CSV class you're using doesn't put all rows in the data storage (such as StreamCSV), this won't necessarily be equal to the number of rows that have been added.

§ numRows()

template<typename Derived>
std::size_t osvr::util::CSVBase< Derived >::numRows ( ) const
inline

Gets the total number of rows that have been streamed/added to this CSV object, whether or not they're in the internal data storage.

That is, numRows() >= numDataRows()

§ outputRow()

template<typename Derived>
void osvr::util::CSVBase< Derived >::outputRow ( std::ostream &  os,
DataRow const &  row 
) const
inlineprotected

Called by outputData() and by derived classes to format individual rows.

§ row()

template<typename Derived>
RowProxy osvr::util::CSVBase< Derived >::row ( )
inline

Main call for the CSV object: returns a proxy object that you can redirect "cells" into, in order to add them to a new row in the CSV table.


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