Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

data format draft 0.1 and note

The project page is http://dataio.sourceforge.net/. More...
See also:
dataio
Note:
supported primitive data type

The supported primitive data type are:

bool, char, wchar_t (wchat_t does not work?), string, int, long, unsigned, unsigned long, float, double, long double.

To add new primitive type T, specialize the following two template methods:

_dataiorec<T>::stringtoitem(string &s, T &iten); // will change s, if desired

_dataiorec<T>::itemtostring(T const &item, string &s);

If T is supported primitive type (that above two methods is epecialized) vector <T> and vector<vector<T> > are automatically supported.

CSV (comma separated values) style
This is the basic data format used by dataio.

The data is separated by columnseparator

some conventions:

The each data block the form

[variable 1][separator][values 11]

...

[separator][values 1n]

...

[variable n][separator][values n1]

...

[separator][values nn]

the primitive data with names is posted in the data as

[var name] [separator] [value]

and without names as

[value]

The vector is posted as value separated by columnseparator, in the single line (if line is long, will use linewrap features, but remember that it meke unsupported by spreadseet application).

The vector data with name is the form

[var name] [separator] [values list]

or

[var name]

[separator] [values list]

The vector withou names is the form

[values list]

The vector<vector> are formed by several lines, each of this containning data separated by column separator as vector

with names, it is posted as

[var name] [separator] [first line values list]

[separator] [second line values list]

...

[separator] [last line values list]

or

[var name] [separator]

[first line values list]

[separator] [second line values list]

...

[separator] [last line values list]

this data without names is the form

[first line values list]

[second line values list]

...

[last line values list]

[empty line]

Note:
The primitive data type and their vectors will added to loader using dataio::add() methods. If name is passed, assumed as field as name, and if name is omoted, is assumed as name less field.

The data corresponding to composed member data obedies the above requisites, but all member field need to one column shifted to indicate that is the member. for example, record "person" with fields: name=Paul, telephon = xxxxx, age=221, is soted as

person [separator] name [separator] Paul

[separator] telephon [separator] xxxxx

[separator] age [separator] 21

with item name, or

[separator] name [separator] Paul

[separator] telephon [separator] xxxxx

[separator] age [separator] 21

without names. The record field will or not use the name. for example, Above data with item name, but name of record without field name is the form

person [separator] Paul

[separator] telephon [separator] xxxxx

[separator] age [separator] 21

the only requeriments is that the empty one column is added in the left side of each lines of composed data (relative to current position). The other rules is same as non composed data.

For composed datafield with names, the end of datas is assumed as ocurrence of line that is not shifted as current position. (that contain non empty data at left of corrent shift position - shift position is one shifted relative to name column)

for composed data without names, the end of data is detected with their field components. No special rule to determine end of specific composed data field.

Note:
class mydataio : dataio {

....

};

Suppose that mydata is mydataio type and io is dataio type;

In way to add mydata as item of io with name "subfield", call

io.add("subfield", (dataio *)&mydata); // if derived class, need casting

important note:
multi-block style
If some name appear more that once, is assumed that the data is the list blocken in the elements. For example, the data item = {x, y, z) will writed in the form

item [separator] x

item [separator] y

item [separator] z

It is suitable to describe the list of composed data (see table features). Note that can not use this features without item name, or within table data.

Note:
To manage correctly this, need to add item as member of loader, and item is that associated to extended class of dataio, so the methods

void dataio::startinblock(unsigned i) // prepare to input column i

bool dataio::startoutblock(unsigned i) // prepare to input column i

and optional

void dataio::validate(unsigned i) // validate column i that inputed

are implemented.

column oriented data
The data will be column oriented. In this case, is assumed to the transposed one (column is row and row is column) relative to standard one. As the table format, the blank line is assumed as end of datablock

If activate columnoriented and istable, the data becames as most popular spreadseet like table format.
table data
In this case, vector<vector> will not used as field data (the vector is supported, and the element is itored, one in each column). For example, suppose that ';' is used as column separator, then

name ; Alfred ; Paul ; Mary

point ; 12 ; 15 ; 17

; 21 ; 52 ; 37

; 9 ; 7 ; 27

sum ; 123 ; 74 ; 81

store the values:

column 1:

column 2: column 3: The blanck line are assumed as end of table.

Note:
In way to process table data format, need to extend dataio class and overwrite the methods:

void dataio::startinblock(unsigned i) // prepare to input column i

bool dataio::startoutblock(unsigned i) // prepare to input column i

and optional

void dataio::validate(unsigned i) // validate column i that inputed

attributor enabled mode
In the config file, normaly the value is attributed using attributor To support this, dataio permit use of attributor to attribute value for name (replacing column separator) in the first level named variables.

Actually, the attributor enabled mode will input/output unnamed data too, but it will disabled in way to compatibilize as most standard.

The attributor mode similar to CVS, except the fact that the separator between variables and data is [attribseparator]. Actually, [column separator] and [attribseparator] will used as separator of first column.

If extendedmode is disabled, the variable without names will not used, due to most popular standard.

Note: this mode is ignored by column oriented data and table data
section enabled mode
The windows ini file use section and it is used to the applications for readding only the data associated to it. The data io assume that, if one of sectionnameopen or sectionnameclose is enabled (isgraph character), assume that the first level (not shifted data) name is used as section.

Corrently, will use unnamed data in the section enabled mode, but it will desactivated to standarize, i.e, On the first level (not subfield) the only named data will be used in the section activated mode. for example, windows inifiel do not permit use of variable outside of section definition, but the current one do not checking (and empty section definition ends the current section)

The standard are as same as CSV, that affect the composed data field in the following way. The name of composed data is posted, delimited by sectionname marker and the one column shifting of their datafield is skipped:

[sectionnameopen][var name][sectionnameclose] [datalist 1] ... [datalist n]

The end of this block is assumed as occurrence of next section definition.

The section scape is made by empty section marker, and no subsection is suported. The dataio provides datadefinition outside of section (datafield that is not composed data) only before compose data by convenience, but section scape will be disabled. Note that non section data before section is not recomended, because is not windows standard.

If extendedmode is disabled, the variable without names will not used to make standard. Note that the non-composed data type will be used because it is usefull, but is not the most popular standard.

Note:
the section enabled mode is ignored by column oriented data and table data.

Note:
The section enabled, attrib separator enabled, exteddedmode disabled mode Assume that is standard sectionized style that each composed element does not contain unnamed data member and their members is simple, or vector. Thus, insert attrib separator between first and seccond column.
comment on data
line wrapping
if linewrap is enabled, will break long line as several one The line wrapmarker says to join the line at the next one.

For example, if '\' is linewrap marker,

a [separator] b \

[separator] 7 [separator] 9

is interpreted as

a [separator] b [separator] 7 [separator] 9

Notes
flags related: -------------- 1. maped into member during input/outputsetvalue/getvalue process

are: lineseparator, columnseparator, linewrap, commentline, commentopenmark, commentclosemark, attribseparator, stringdelimiter, parseallinputstring, todo: charmarker used to specify the special characrer, like C/C++ (if is white, assumed disabled)

2. setted by method, and optionally, will map inside member during flag setting: ignorecase, emptyisvalid, decimal, validateall, collectnames todo: collectunknowdata used to decide collect or not the unknow data

3. maped by maprecomemdedflagstomember method: ignorecase, emptyisvalid, decimal, validateall, collectnames

4. Not maped inside members (do manually, if desire): sectionnameopen, sectionnameclose, istable, columnoriented, maxcolumnonline, clearemptytail, extendedmode (is checked only by operator>>() and operator<<()??

obs.: dataio::setted(string const &name) do not apply parsestring() in name. do it, if desire.

string on cell -------------- 1. The field that is not setted to string is considered as well as, if parseallinputstring is off. 2. On the name, or string item: The sequence of white space is replaced by one single space, and space on head or tail of strig is ignored. If delimiter string is used, the space before and after this is skiped. 3. if parseallinputstring is on, all item is parsed as in (2) 4. The name and string item is outputed as delimited string, if it contain markers: commentline, commentopen, commentclose, lineseparator, columnseparator, attribseparator, stringdelimiter, linewrap (if last non white of string), section name marker (if is name on first column) The lineseparator is deleted from string item, but on name or others, is keeped (atempty for, this, because linesepaator inside name, or other data that is not string will cause errors).

todo: implement extended text mode that word with non white char representations, as like C/C++ style epecification.

add/delete: ----------- 1. Add with name that arleady exist, replace old one. If need to output record list, use multiblock features.

2. Can not delete fields. Only delete features is clear() that delete all fields. Note that in the istable enabled mode, inside of startinblock, validate, delete will cause errors (setvalue do not check variable type)


Generated at Thu Sep 6 13:45:43 2001 for dataio by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001