Generating file definitions

Files are defined as sets of columns. Each column has a well-known name and a defined type is associated with it.

When a CSV file is loaded as a eepgwde::detail::DataFrame, the DataFrame::render() can be invoked on it and this will convert all of the columns to their designated types.

C++ is a compiled language and it's difficult to load file definitions as plug-in modules, so the approach here is to compile a definition for each of the files you want to load.

Each CSV file is defined by a .csd file that defines the column names to expect and the types that should be used.

tag,column,type,description
0,PX,string,none
1,X0,string,none
3,maturity,int,Maturity
4,strike,double,Strike

An AWK script can be used on this .csd (CSV schema definition) file to generate a partial C++ definition in a C++ source file.

#! /usr/bin/awk -f 

## weaves
# Generate the elements of an array from a csv0.csd file
# The types table maps types to simple suffixes.
# so if the table eurisc.csv0.csd contains
# string then full typeid string is written out.
##

BEGIN {
  FS=","

  types["date"]="N7eepgwde6detail9posixdateE"
  types["usdate"]="N7eepgwde6detail6usdateE"
  types["eudate"]="N7eepgwde6detail6eudateE"

  types["double"]="d"
  types["bps"]="N7eepgwde6detail3bpsE"
  types["rate"]="N7eepgwde6detail4rateE"

  types["string"]="Ss"
  types["int"]="i"
  types["double"]="d"

}

NR > 1 {
  printf("{ std::string(\"%s\"), std::string(\"%s\") },\n", $2, types[$3] )
}

The typeid() names that appear in this file were taken from scaltypes0.csv. You may add more types of your own and they will have different signatures. You would need to list them and include them in the AWK script. The file scaltypes0.cpp shows you how to list them.

This AWK script is called by Shell script that does some file-naming and directs the output to a file.

col_t eurisc0_attrs[] = {
{ std::string("PX"), std::string("Ss") },
{ std::string("X0"), std::string("Ss") },
{ std::string("maturity"), std::string("i") },
{ std::string("strike"), std::string("d") },
{ std::string(), std::string() }
};

This file is included into render0.cpp

That file is then included by you (the application programmer) in your application. An example of how to do this is shown in render1.cpp.

This also defines the renderer functions: see the render0_t.cpp file for examples of how to do that. This file defines which render_t function object will be used to process the column.

More names

There are some standard names defined in the file bbg-defaults.csv00.csd. These are some common names from a well-known data-feed service.

tag,column,type,description
5,PX_ASK,double,ask price
6,PX_BID,double,bid price
7,PX_LAST,double,last price

Generated on Thu Feb 18 21:30:12 2010 for eleve by  doxygen 1.5.6