This documenta- tion describes the current state of development.
Note that interfaces and functionality may still change.

Prokee Modules:
  A
  B
  C
  D
  E
  F
  G
  I
  L
  M
  N
  O
  P
  R
  S
  T
  U
  W

     open all    |    close all

GUI Elements:
  B
  C
  I
  M
  P
  R
  S
  T

     open all    |    close all

GUI Interactions:
  B
  F
  H
  S

     open all    |    close all

GUI Layouts:
  L

     open all    |    close all

Games/Demos:
  M

     open all    |    close all

Third Party Libraries:
  P
  F
  Z

     open all    |    close all

Information about this Website / Informationen zu dieser Webseite:
In case of any questions, or comments, please feel free to contact me via email at apoll500@gmail.com.

Module csv [Version: v01] (Interface AbsCsvData)

   [AbsCsvField]   [AbsCsvRecord]   [AbsCsvSettings]   [AbsCsvData]

Contents

Inheritance:
AbsCsvData
Implementations: CsvData

Constructors:
CsvData
AbsCsvData *createCsvData()

Members:
settings
AbsCsvSettings *settings;

Methods:
Loading CSV Files
load (version 1)
int load(const char *filename,const char *docreate)
load (version 2)
int load(const char *filename)
load (version 3)
int load(const wchar_t *filename,const char *docreate)
load (version 4)
int load(const wchar_t *filename)
load (version 5)
int load(Reader *reader)
load_rec
AbsCsvRecord *load_rec(Reader *reader)
Counting Records
get_record_count
int get_record_count()
Headers
useHeader
void useHeader(bool h)
getHeaderId
int getHeaderId(const char *column_name)
getHeader
char *getHeader(int col)
Setting Values of Fields
setField (version 1)
bool setField(int row,int col,const char *val)
setField (version 2)
bool setField(int row,const char *column_name,const char *val)
Adding Records
addRecord (version 1)
int addRecord()
addRecord (version 2)
int addRecord(int fldcount)
addFieldToRecord
bool addFieldToRecord(int row)
Getting a Record
getRecord (version 1)
AbsCsvRecord *getRecord(int col,const char *val)
getRecord (version 2)
AbsCsvRecord *getRecord(int *col,const char **val)
getRecord (version 3)
AbsCsvRecord *getRecord(int row)
getRecord (version 4)
AbsCsvRecord *getRecord(const char *column_name,const char *val)
getRecord (version 5)
AbsCsvRecord *getRecord(const char **column_name,const char **val)
Selecting Records
getAllRecords (version 1)
AbsCsvRecord **getAllRecords(int col,const char *val)
getAllRecords (version 2)
AbsCsvRecord **getAllRecords()
getAllRecords (version 3)
AbsCsvRecord **getAllRecords(const char *column_name,const char *val)
Writing CSV Data
save
bool save(const char *filename)
print (version 1)
void print(FILE *f)
print (version 2)
void print(FILE *f,int *row,int *col)

Motivation


Constructors

   CsvData


Provides functionality to load, manage and store csv data.

Constructor:
CsvData()

Factory Method:
AbsCsvData *AbsCsvDataInterface::createCsvData()

Wrapper Class:
CsvDataWrapper()

The static method AbsCsvDataInterface::createCsvData creates a new instance of class CsvData.

Return value:
Returns an instance of CsvData.


Members

   settings


Provides settings for reading and writing csv files. (see AbsCsvSettings)

Signature:
AbsCsvSettings *settings;

Setter- and getter-methods:
Use the methods get_settings() and set_settings(AbsCsvSettings *) to get and set the value of this member variable.


Methods

   load (version 1)


Loads a csv-data from a file.

Signature:
int load(const char *filename,const char *docreate)

Parameters:
Type Name Direction Description
const char *filename[IN]Filename (incl. path)
const char *docreate[IN]...


Return value:
Returns 0 if successful, or a value other than 0 otherwise.

   load (version 2)


Loads a csv-data from a file.

Signature:
int load(const char *filename)

Parameters:
Type Name Direction Description
const char *filename[IN]Filename (incl. path)


Return value:
Returns 0 if successful, or a value other than 0 otherwise.

   load (version 3)


Loads a csv-data from a file.

Signature:
int load(const wchar_t *filename,const char *docreate)

Parameters:
Type Name Direction Description
const wchar_t *filename[IN]Filename (incl. path)
const char *docreate[IN]...


Return value:
Returns 0 if successful, or a value other than 0 otherwise.

Remarks:
Diese Funktion ist nur unter Windows verfügbar.

   load (version 4)


Loads a csv-data from a file.

Signature:
int load(const wchar_t *filename)

Parameters:
Type Name Direction Description
const wchar_t *filename[IN]Filename (incl. path)


Return value:
Returns 0 if successful, or a value other than 0 otherwise.

Remarks:
Diese Funktion ist nur unter Windows verfügbar.

   load (version 5)


Loads csv data.

Signature:
int load(Reader *reader)

Parameters:
Type Name Direction Description
Reader *readerPointer to an instance of an implementation of Reader.
See reader:Reader.


Return value:
Returns 0.

   load_rec


Loads the current line.

Signature:
AbsCsvRecord *load_rec(Reader *reader)

Parameters:
Type Name Direction Description
Reader *readerPointer to an instance of an implementation of Reader.
See reader:Reader.


Return value:
...

   get_record_count


Returns the number of currently loaded records.

Signature:
int get_record_count()

Return value:
The number of records.

   useHeader


...

Signature:
void useHeader(bool h)

Parameters:
Type Name Direction Description
bool htrue if the first line contains headers and false otherwise.


   getHeaderId


...

Signature:
int getHeaderId(const char *column_name)

Parameters:
Type Name Direction Description
const char *column_name[IN]...


Return value:
Number of the column or -1 if a column with this name does not exist.

Remarks:
The comumn names have to be unique. If coumns have the same name, the first matching column will be found.

   getHeader


Returns the column title of a column.

Signature:
char *getHeader(int col)

Parameters:
Type Name Direction Description
int colDie Spaltennummer (Zählung beginnend mit 0).


Return value:
Title of the column spezified by its index col. If the index is out of range or, if the csv table does not contain a header line, the method returns NULL.

   setField (version 1)


...

Signature:
bool setField(int row,int col,const char *val)

Parameters:
Type Name Direction Description
int rowDie Zeilennummer (Zählung beginnend mit 0).
int colDie Spaltennummer (Zählung beginnend mit 0).
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
...

   setField (version 2)


...

Signature:
bool setField(int row,const char *column_name,const char *val)

Parameters:
Type Name Direction Description
int rowDie Zeilennummer (Zählung beginnend mit 0).
const char *column_name[IN]...
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
...

Remarks:
The comumn names have to be unique. If coumns have the same name, the first matching column will be found.

   addRecord (version 1)


Adds a new empty record.

Signature:
int addRecord()

Return value:
Returns the row-number of the new record.

Remarks:
The comumn names have to be unique. If coumns have the same name, the first matching column will be found.

   addRecord (version 2)


Adds a new record with fldcount empty fields.

Signature:
int addRecord(int fldcount)

Parameters:
Type Name Direction Description
int fldcountNumber of colums


Return value:
Returns the row-number of the new record.

   addFieldToRecord


...

Signature:
bool addFieldToRecord(int row)

Parameters:
Type Name Direction Description
int rowDie Zeilennummer (Zählung beginnend mit 0).


Return value:
...

   getRecord (version 1)


...

Signature:
AbsCsvRecord *getRecord(int col,const char *val)

Parameters:
Type Name Direction Description
int colDie Spaltennummer (Zählung beginnend mit 0).
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
...

   getRecord (version 2)


...

Signature:
AbsCsvRecord *getRecord(int *col,const char **val)

Parameters:
Type Name Direction Description
int *colNumber of the column
const char **val[IN]Values.


Return value:
...

   getRecord (version 3)


...

Signature:
AbsCsvRecord *getRecord(int row)

Parameters:
Type Name Direction Description
int rowDie Zeilennummer (Zählung beginnend mit 0).


Return value:
...

   getRecord (version 4)


...

Signature:
AbsCsvRecord *getRecord(const char *column_name,const char *val)

Parameters:
Type Name Direction Description
const char *column_name[IN]...
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
...

   getRecord (version 5)


...

Signature:
AbsCsvRecord *getRecord(const char **column_name,const char **val)

Parameters:
Type Name Direction Description
const char **column_name[IN]...
const char **val[IN]Values.


Return value:
...

   getAllRecords (version 1)


Selects all records with value val in column col.

Signature:
AbsCsvRecord **getAllRecords(int col,const char *val)

Parameters:
Type Name Direction Description
int colDie Spaltennummer (Zählung beginnend mit 0).
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
The method returns a pointer to a null-terminated sequence of pointers to the found records. If no records are found, or if column col does not exist, the method returns an empty sequence (where getAllRecords(col,val)[0]==0).

Remarks:
The application has to free the returned buffer. (Do NOT free returned records: free(r[i]); or delete r[i];.)
AbsCsvRecord **r=getAllRecords();
...
free(r);


   getAllRecords (version 2)


Selects all records

Signature:
AbsCsvRecord **getAllRecords()

Return value:
The method returns a pointer to a null-terminated sequence of pointers to all records.

Remarks:
The application has to free the returned buffer. (Do NOT free returned records: free(r[i]); or delete r[i];.)
AbsCsvRecord **r=getAllRecords();
...
free(r);


   getAllRecords (version 3)


Selects all records with value val in column column_name.

Signature:
AbsCsvRecord **getAllRecords(const char *column_name,const char *val)

Parameters:
Type Name Direction Description
const char *column_name[IN]...
const char *val[IN]Value to be stored in filed specified by row and col.


Return value:
The method returns 0, if headers are disabled or if the header field is missing. Otherwise the method returns a pointer to a null-terminated sequence of pointers to the found records.

Remarks:
The application has to free the returned buffer. (Do NOT free returned records: free(r[i]); or delete r[i];.)
AbsCsvRecord **r=getAllRecords();
...
if(r)free(r);


   save


...

Signature:
bool save(const char *filename)

Parameters:
Type Name Direction Description
const char *filename[IN]Filename (incl. path)


Return value:
...

   print (version 1)


...

Signature:
void print(FILE *f)

Parameters:
Type Name Direction Description
FILE *fHandle auf eine zum Schreiben geöffnete Datei.


Return value:
...

   print (version 2)


...

Signature:
void print(FILE *f,int *row,int *col)

Parameters:
Type Name Direction Description
FILE *fHandle auf eine zum Schreiben geöffnete Datei.
int *rowNumber of the row
int *colNumber of the column


Return value:
...


Copyright © 2017 - 2019 by Andreas Pollhammer