cstorage/main.cpp

92 lines
3.1 KiB
C++

/*
* dtata.cpp
* Copyright (C) 2023 Leonardo de Araújo Lima <leonardo@deb-horus.local>
*
* dstorage is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* dstorage is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
# Copyright 2022 Leonardo de Araújo Lima
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# this code have a lot of educational purposes here my header's includes, necessary to include pre made objects, and funcions.
*/
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <iostream>
#include <string>
#include "sdata.h"
int main()
{
sdata monka;
monka.debug = 0;
const char *homedir; // here I'm getting the user home directory.
if ((homedir = getenv("HOME")) == NULL) //
{ //
homedir = getpwuid(getuid())->pw_dir; //
} //
string path=homedir; //
path+="/databases/"; // setting the databases directory....
monka.add_data ("nome", "Leonardo");
monka.add_data ("sobrenome", "de Araújo Lima");
monka.add_data ("email", "leonardo@asl-sl.com.br");
monka.add_data ("website", "www.asl-sl.com.br");
monka.add_data ("telefone", "(35) 3331-2320");
monka.set_dpath(path.c_str());
path+="sData.db"; // setting the database name!
monka.set_db(path.c_str());
monka.set_tb("info"); // setting yhe table name!
cout << "\nclass with debug level deactivated..." << endl;
// monka.show();
size_t s = monka.tsize();
s = monka.nsize();
cout << "\n size of data keys : " << s << " bytes." << endl;
s = monka.vsize();
cout << "\n size of data values : " << s << " bytes." << endl;
monka.debug=0;
// cout << "class with debug level deactivated..." << endl;
// monka.show();
cout << "\n size of object data : " << s << " bytes." << endl;
s = monka.nsize();
cout << "\n size of data keys : " << s << " bytes." << endl;
// monka.dbinfo();
monka.dbtest();
monka.cDBase();
monka.debug = 1;
monka.addreg();
cout << "\nloading..." << endl;
bool t = monka.load();
cout << t << endl;
monka.show();
return 0;
}