Menu

Formats

Máté Kovács

The user can communicate via a command line. The user will parse and interpret commands from input line. The format is the following.

Command line commands:

These commands will be the working commands in the command prompt.
  1. DATABASE OPEN <NAME>
  2. DATABASE CLOSE
  3. DATABASE CREATE <NAME>
  4. DATABASE LIST
  5. DATABASE REMOVE <NAME>
  6. TABLE CREATE <TABLENAME> WITH [<COL1NAME>:<COL1CANBENULL>:<COL1TYPE>,...,<COLNNAME>:<COLNCANBENULL>:<COLNTYPE>]
  7. TABLE ADD <COLNAME:COLTYPE> TO <TABLENAME>
  8. TABLE REMOVE <COLNAME> FROM <TABLENAME>
  9. TABLE DELETE <TABLENAME>
  10. TABLE EMPTY <TABLENAME>
  11. ROW ADD [<VALUE1>,...,<VALUEN>] TO <TABLENAME>
  12. ROW LIST <TABLENAME> {WHERE <COLNAME><OPERATOR><VALUE>}
  13. ROW DELETE <TABLENAME> WHERE <COLNAME><OPERATOR><VALUE>
    Here <SOMETHING> means that it should be a parameter, the user has to type that without the < and > signs. These are obligatory!
    {...} means conditional part of the line. So you can just leave that part blank.
    [...] means a list. The user has to type "[" and "]" signs! These are obligatory.

File operations

Databases and database tables will be saved to text files. All the files will be written with lower case letters. There's a databases.dat file, which contains the names of the databases in that folder. Every database has a file. The names of these files have to be <databaseName>.dat, so you can't make a database with the name 'databases'. Every line has to contain one existing tablename. Database table files have the following filename format: <database>_<tablename>.dat.

The format of content of table files:

line number:
1. <number_of_columns>
2. <ValueType_of_column_1> <canBeEmpty_of_column_1> <tableName_of_column_1>
.
.
.
n+1. <ValueType_of_column_n> <canBeEmpty_of_column_n> <tableName_of_column_n>
n+2. <1.column_value _of_1.row> <2.column_value_of_1.row> . . . <n.column_value_of_1.row>
.
.
.
n+k+1. <1.column_value_of_k.row> <2.column_value_of_k.row> . . . <n.column_value_of_k.row>

There are k rows and n columns.
ValueType: 0=bool, 1=int, 2=double, 3=std::string
canBeEmpty: 0=false, 1=true
If a value can be empty, than empty value is '_'.
If a value is std::string, than you can find the value in the file in this format: '<str>value</str>'.
Bool values are saved as TRUE and FALSE.

Data handling

You can look at the [Class Diagram and Set Up] of the program.

File operations will be called in functions:
  1. Handler::newDB()
  2. Handler::listDBs()
  3. Handler::removeDB()
  4. Handler::openDB()
  5. Handler::closeDB()
  6. Database::load()
  7. Database::save()
  8. Table::writeToFile() - this function gets the file stream as a parameter

Only Handler::run() will be communicate with the user.

Here's an overview of the relation of classes (maybe it's helpful for the File operations section above):
Small Class Diagram


Related

Wiki: Class Diagram and Set Up
Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.