OSVR-Core
Classes | Macros | Functions
CSVTools.h File Reference

Header. More...

#include <cassert>
#include <cstddef>
#include <iosfwd>
#include <iterator>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  csvtools::StringField
 
class  csvtools::FieldParserHelper
 

Macros

#define CSV_TESTING
 
#define CSV_VERIFY(X, MSG)
 

Functions

std::string csvtools::getCleanLine (std::istream &is)
 
std::size_t csvtools::string_fields::getBeginningOfField (std::string const &line, std::size_t field)
 
template<typename F >
return true to continue to next field *void csvtools::iterateFields (F &&fieldFunc, std::string const &line, std::size_t numFields=std::string::npos, std::size_t first=0)
 
std::vector< std::string > csvtools::getFields (std::string const &line, std::size_t numFields=std::string::npos, std::size_t first=0)
 
void csvtools::stripQuotes (std::string &field)
 
void csvtools::stripQuotes (std::vector< std::string > &fields)
 

Detailed Description

Header.

Date
2016
Author
Sensics, Inc. http://sensics.com/osvr

Macro Definition Documentation

§ CSV_VERIFY

#define CSV_VERIFY (   X,
  MSG 
)
Value:
do { \
if (!(X)) { \
throw std::logic_error(MSG); \
} \
} while (0)

Function Documentation

§ iterateFields()

template<typename F >
return true to continue to next field* void csvtools::iterateFields ( F &&  fieldFunc,
std::string const &  line,
std::size_t  numFields = std::string::npos,
std::size_t  first = 0 
)
inline

"begin" iterator/position

initial "one past the end" iterator/position

the condition on b < n is because we update b = e + 1, and e might be the last character in the string.

§ stripQuotes()

void csvtools::stripQuotes ( std::string &  field)
inline

pop back first, so we have less to "slide up"

then remove the first character