souffle  2.0.2-371-g6315b36
Public Member Functions | Static Protected Member Functions | Protected Attributes
souffle::ReadFileCSV Class Reference

#include <ReadStreamCSV.h>

Inheritance diagram for souffle::ReadFileCSV:
Inheritance graph
Collaboration diagram for souffle::ReadFileCSV:
Collaboration graph

Public Member Functions

 ReadFileCSV (const std::map< std::string, std::string > &rwOperation, SymbolTable &symbolTable, RecordTable &recordTable)
 
Own< RamDomain[]> readNextTuple () override
 Read and return the next tuple. More...
 
 ~ReadFileCSV () override=default
 
- Public Member Functions inherited from souffle::ReadStreamCSV
 ReadStreamCSV (std::istream &file, const std::map< std::string, std::string > &rwOperation, SymbolTable &symbolTable, RecordTable &recordTable)
 
- Public Member Functions inherited from souffle::ReadStream
template<typename T >
void readAll (T &relation)
 
- Public Member Functions inherited from souffle::SerialisationStream< false >
virtual ~SerialisationStream ()=default
 

Static Protected Member Functions

static std::string getFileName (const std::map< std::string, std::string > &rwOperation)
 Return given filename or construct from relation name. More...
 

Protected Attributes

std::string baseName
 
std::ifstream fileHandle
 
- Protected Attributes inherited from souffle::ReadStreamCSV
const std::string delimiter
 
std::istream & file
 
std::map< int, int > inputMap
 
size_t lineNumber
 
- Protected Attributes inherited from souffle::SerialisationStream< false >
size_t arity
 
size_t auxiliaryArity
 
RO< RecordTable > & recordTable
 
RO< SymbolTable > & symbolTable
 
std::vector< std::string > typeAttributes
 
Json types
 

Additional Inherited Members

- Protected Types inherited from souffle::SerialisationStream< false >
using RO = std::conditional_t< readOnlyTables, const A, A >
 
- Protected Member Functions inherited from souffle::ReadStreamCSV
std::map< int, int > getInputColumnMap (const std::map< std::string, std::string > &rwOperation, const unsigned arity_) const
 
std::string nextElement (const std::string &line, size_t &start, size_t &end)
 
RamUnsigned readRamUnsigned (const std::string &element, size_t &charactersRead)
 Read an unsigned element. More...
 
- Protected Member Functions inherited from souffle::ReadStream
void consumeChar (const std::string &str, char c, size_t &pos)
 Read past given character, consuming any preceding whitespace. More...
 
void consumeWhiteSpace (const std::string &str, size_t &pos)
 Advance position in the string until first non-whitespace character. More...
 
RamDomain readADT (const std::string &source, const std::string &adtName, size_t pos=0, size_t *charactersRead=nullptr)
 
std::string readAlphanumeric (const std::string &source, size_t &pos)
 Read the next alphanumeric sequence (corresponding to IDENT). More...
 
RamDomain readRecord (const std::string &source, const std::string &recordTypeName, size_t pos=0, size_t *charactersRead=nullptr)
 Read a record from a string. More...
 
 ReadStream (const std::map< std::string, std::string > &rwOperation, SymbolTable &symTab, RecordTable &recTab)
 
std::string readUntil (const std::string &source, const std::string stopChars, const size_t pos, size_t *charactersRead)
 
- Protected Member Functions inherited from souffle::SerialisationStream< false >
 SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, const std::map< std::string, std::string > &rwOperation)
 
 SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, Json types)
 
 SerialisationStream (RO< SymbolTable > &symTab, RO< RecordTable > &recTab, Json types, std::vector< std::string > relTypes, size_t auxArity=0)
 

Detailed Description

Definition at line 247 of file ReadStreamCSV.h.

Constructor & Destructor Documentation

◆ ReadFileCSV()

souffle::ReadFileCSV::ReadFileCSV ( const std::map< std::string, std::string > &  rwOperation,
SymbolTable symbolTable,
RecordTable recordTable 
)
inline

Definition at line 249 of file ReadStreamCSV.h.

249  {
250  if (!fileHandle.is_open()) {
251  throw std::invalid_argument("Cannot open fact file " + baseName + "\n");
252  }
253  // Strip headers if we're using them
254  if (getOr(rwOperation, "headers", "false") == "true") {
255  std::string line;
256  getline(file, line);
257  }
258  }
259 
260  /**
261  * Read and return the next tuple.
262  *

References baseName, souffle::ReadStreamCSV::file, fileHandle, and souffle::getOr().

Here is the call graph for this function:

◆ ~ReadFileCSV()

souffle::ReadFileCSV::~ReadFileCSV ( )
overridedefault

Member Function Documentation

◆ getFileName()

static std::string souffle::ReadFileCSV::getFileName ( const std::map< std::string, std::string > &  rwOperation)
inlinestaticprotected

Return given filename or construct from relation name.

Default name is [configured path]/[relation name].facts

Parameters
rwOperationmap of IO configuration options
Returns
input filename

Definition at line 291 of file ReadStreamCSV.h.

◆ readNextTuple()

Own<RamDomain[]> souffle::ReadFileCSV::readNextTuple ( )
inlineoverridevirtual

Read and return the next tuple.

Returns nullptr if no tuple was readable.

Returns

Reimplemented from souffle::ReadStreamCSV.

Definition at line 270 of file ReadStreamCSV.h.

279  :
280  /**

Field Documentation

◆ baseName

std::string souffle::ReadFileCSV::baseName
protected

Definition at line 299 of file ReadStreamCSV.h.

Referenced by ReadFileCSV().

◆ fileHandle

std::ifstream souffle::ReadFileCSV::fileHandle
protected

Definition at line 303 of file ReadStreamCSV.h.

Referenced by ReadFileCSV().


The documentation for this class was generated from the following file:
souffle::ReadFileCSV::fileHandle
std::ifstream fileHandle
Definition: ReadStreamCSV.h:303
souffle::getOr
C::mapped_type const & getOr(const C &container, typename C::key_type key, const typename C::mapped_type &defaultValue)
Get value for a given key; if not found, return default value.
Definition: ContainerUtil.h:111
souffle::ReadFileCSV::baseName
std::string baseName
Definition: ReadStreamCSV.h:299
souffle::ReadStreamCSV::file
std::istream & file
Definition: ReadStreamCSV.h:242