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></name>
  2. DATABASE CLOSE
  3. DATABASE CREATE <name></name>
  4. DATABASE LIST
  5. DATABASE REMOVE <name></name>
  6. TABLE CREATE <tablename> WITH [<col1name>:<col1canbenull>:<col1type>,...,<colnname>:<colncanbenull>:<colntype>]</colntype></colncanbenull></colnname></col1type></col1canbenull></col1name></tablename>
  7. TABLE ADD <colname:coltype> TO <tablename></tablename></colname:coltype>
  8. TABLE REMOVE <colname> FROM <tablename></tablename></colname>
  9. TABLE DELETE <tablename></tablename>
  10. TABLE EMPTY <tablename></tablename>
  11. ROW ADD [<value1>,...,<valuen>] TO <tablename></tablename></valuen></value1>
  12. ROW LIST <tablename> {WHERE <colname><operator><value>}</value></operator></colname></tablename>
  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!</something>
    {...} 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.</value></operator></colname></tablename>

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.</tablename></database></databasename>

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></n.column_value_of_k.row></n.column_value_of_1.row></tablename_of_column_n></canbeempty_of_column_n></valuetype_of_column_n></tablename_of_column_1></canbeempty_of_column_1></valuetype_of_column_1></number_of_columns>

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.