removed DbItemQuery and DbItemColumns which were used for database accessing for Item class

This commit is contained in:
Tomasz Sowa 2021-02-24 22:54:36 +01:00
parent 32e93a04c5
commit 51b1aed483
4 changed files with 0 additions and 501 deletions

View File

@ -1,123 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "dbitemcolumns.h"
#include "dbbase.h"
#include "core/log.h"
namespace Winix
{
/*
void DbItemColumns::SetColumns(PGresult * r)
{
// PQfnumber returns -1 if there is no such a column
id = PQfnumber(r, "id");
user_id = PQfnumber(r, "user_id");
group_id = PQfnumber(r, "group_id");
privileges = PQfnumber(r, "privileges");
date_creation = PQfnumber(r, "date_creation");
date_modification = PQfnumber(r, "date_modification");
url = PQfnumber(r, "url");
type = PQfnumber(r, "type");
parent_id = PQfnumber(r, "parent_id");
content_id = PQfnumber(r, "content_id");
link_to = PQfnumber(r, "link_to");
link_redirect = PQfnumber(r, "link_redirect");
subject = PQfnumber(r, "subject");
content = PQfnumber(r, "content");
content_type = PQfnumber(r, "content_type");
guest_name = PQfnumber(r, "guest_name");
html_template = PQfnumber(r, "template");
modification_user_id = PQfnumber(r, "modification_user_id");
file_path = PQfnumber(r, "file_path");
file_fs = PQfnumber(r, "file_fs");
file_type = PQfnumber(r, "file_type");
has_thumb = PQfnumber(r, "has_thumb");
hash = PQfnumber(r, "hash");
hash_type = PQfnumber(r, "hash_type");
file_size = PQfnumber(r, "file_size");
ref = PQfnumber(r, "ref");
modify_index = PQfnumber(r, "modify_index");
sort_index = PQfnumber(r, "sort_index");
meta = PQfnumber(r, "meta");
ameta = PQfnumber(r, "ameta");
}
void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
{
if( id != -1 ) item.id = db_base.AssertValueLong(r, row, id);
if( user_id != -1 ) item.user_id = db_base.AssertValueLong(r, row, user_id);
if( group_id != -1 ) item.group_id = db_base.AssertValueLong(r, row, group_id);
if( privileges != -1 ) item.privileges = db_base.AssertValueInt(r, row, privileges);
if( date_creation != -1 ) item.date_creation = db_base.AssertValueDate(r, row, date_creation);
if( date_modification != -1 ) item.date_modification = db_base.AssertValueDate(r, row, date_modification);
if( type != -1 ) item.type = static_cast<Item::Type>( db_base.AssertValueInt(r, row, type) );
if( parent_id != -1 ) item.parent_id = db_base.AssertValueLong(r, row, parent_id);
if( content_id != -1 ) item.content_id = db_base.AssertValueLong(r, row, content_id);
if( link_redirect != -1 ) item.link_redirect = db_base.AssertValueInt(r, row, link_redirect);
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( db_base.AssertValueInt(r, row, content_type) );
if( modification_user_id != -1 ) item.modification_user_id = db_base.AssertValueLong(r, row, modification_user_id);
if( file_fs != -1 ) item.file_fs = db_base.AssertValueInt(r, row, file_fs);
if( file_type != -1 ) item.file_type = db_base.AssertValueInt(r, row, file_type);
if( has_thumb != -1 ) item.has_thumb = db_base.AssertValueBool(r, row, has_thumb);
if( hash != -1 ) db_base.AssertValueWide(r, row, hash, item.hash);
if( hash_type != -1 ) item.hash_type = db_base.AssertValueInt(r, row, hash_type);
if( file_size != -1 ) item.file_size = db_base.AssertValueLong(r, row, file_size);
if( ref != -1 ) item.ref = db_base.AssertValueInt(r, row, ref);
if( modify_index != -1 ) item.modify_index = db_base.AssertValueInt(r, row, modify_index);
if( url != -1 ) db_base.AssertValueWide(r, row, url, item.url);
if( content != -1 ) db_base.AssertValueWide(r, row, content, item.content);
if( subject != -1 ) db_base.AssertValueWide(r, row, subject, item.subject);
if( file_path != -1 ) db_base.AssertValueWide(r, row, file_path, item.file_path);
if( link_to != -1 ) db_base.AssertValueWide(r, row, link_to, item.link_to);
if( guest_name != -1 ) db_base.AssertValueWide(r, row, guest_name, item.guest_name);
if( html_template != -1 ) db_base.AssertValueWide(r, row, html_template, item.html_template);
if( sort_index != -1 ) item.sort_index = db_base.AssertValueInt(r, row, sort_index);
if( meta != -1 ) db_base.AssertValueSpace(r, row, meta, item.meta);
if( ameta != -1 ) db_base.AssertValueSpace(r, row, ameta, item.ameta);
}
*/
} // namespace Winix

View File

@ -1,101 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2010-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_db_dbitemcolumns
#define headerfile_winix_db_dbitemcolumns
#include <libpq-fe.h>
//#include "core/item.h"
#include "dbbase.h"
namespace Winix
{
/*
struct DbItemColumns
{
int id;
int user_id;
int group_id;
int privileges;
int date_creation;
int date_modification;
int url;
int type;
int parent_id;
int content_id;
int link_to;
int link_redirect;
int subject;
int content;
int content_type;
int guest_name;
int modification_user_id;
int html_template;
int file_path;
int file_fs;
int file_type;
int has_thumb;
int hash;
int hash_type;
int file_size;
int ref;
int modify_index;
int sort_index;
int meta;
int ameta;
DbItemColumns(DbBase & db_base_) : db_base(db_base_)
{
}
void SetColumns(PGresult * r);
void SetItem(PGresult * r, long row, Item & item);
private:
DbBase & db_base;
};
*/
} // namespace Winix
#endif

View File

@ -1,164 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2010-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "dbitemquery.h"
namespace Winix
{
/*
DbItemQuery::DbItemQuery()
{
Clear();
}
void DbItemQuery::Clear()
{
sort_index_asc = true;
sort_date_asc = true;
SetAll(true, false);
id = -1;
id_tab = 0;
parent_id = -1;
type = Item::none;
file_type = WINIX_ITEM_FILETYPE_NONE;
type_equal = true;
file_type_equal = true;
limit = 0; // limit and offset not used by default
offset = 0;
}
void DbItemQuery::SetAllSel(bool sel)
{
sel_parent_id = sel;
sel_user_id = sel;
sel_group_id = sel;
sel_guest_name = sel;
sel_privileges = sel;
sel_date = sel;
sel_subject = sel;
sel_content = sel;
sel_url = sel;
sel_type = sel;
sel_link = sel;
sel_file = sel;
sel_html_template = sel;
sel_sort_index = sel;
sel_meta = sel;
}
void DbItemQuery::SetAllWhere(bool where_)
{
where_id = where_;
where_parent_id = where_;
where_type = where_;
where_file_type = where_;
}
void DbItemQuery::SetAll(bool sel, bool where_)
{
SetAllSel(sel);
SetAllWhere(where_);
}
void DbItemQuery::WhereId(long id_)
{
where_id = true;
id = id_;
}
void DbItemQuery::WhereIdIn(const std::vector<long> & id_tab_list)
{
id_tab = &id_tab_list;
}
void DbItemQuery::WhereParentId(long parent_id_)
{
where_parent_id = true;
parent_id = parent_id_;
}
void DbItemQuery::WhereType(Item::Type type_, bool equal)
{
where_type = true;
type = type_;
type_equal = equal;
}
void DbItemQuery::WhereFileType(int file_t, bool equal)
{
where_file_type = true;
file_type = file_t;
file_type_equal = equal;
}
void DbItemQuery::Limit(long l)
{
limit = l;
}
void DbItemQuery::Offset(long o)
{
offset = o;
}
*/
} // namespace Winix

View File

@ -1,113 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2010-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_db_dbitemquery
#define headerfile_winix_db_dbitemquery
#include <vector>
//#include "core/item.h"
namespace Winix
{
/*
struct DbItemQuery
{
// id and content_id is selected always
bool sel_parent_id; // parent_id
bool sel_user_id; // user_id, modification_user_id
bool sel_group_id; // group_id
bool sel_guest_name; // guest_name
bool sel_privileges; // privileges
bool sel_date; // date_creation, date_modification
bool sel_subject; // subject
bool sel_content; // content, content_type, ref, modify_index
bool sel_url; // url
bool sel_type; // type (dir, file, none)
bool sel_link; // link_to, link_redirect
bool sel_file; // file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size
bool sel_html_template; // template
bool sel_sort_index; // sort_index
bool sel_meta; // meta and ameta (PT::Space)
bool where_id; //
bool where_parent_id; //
bool where_type;
bool where_file_type;
long id; // if where_id is true
long parent_id; // if where_parent_id is true
Item::Type type;
bool type_equal;
int file_type;
bool file_type_equal; // if true means file_type should be equal
bool sort_index_asc;
bool sort_date_asc;
const std::vector<long> * id_tab; // != 0 if WhereIdIn was used
long limit;
long offset;
DbItemQuery();
void Clear();
void SetAllSel(bool sel);
void SetAllWhere(bool where_);
void SetAll(bool sel, bool where_);
void WhereId(long id_);
void WhereIdIn(const std::vector<long> & id_tab_list);
void WhereParentId(long parent_id_);
void WhereType(Item::Type type_, bool equal = true);
void WhereFileType(int file_t, bool equal = true);
void Limit(long l); // setting 0 turns off
void Offset(long o); // setting 0 turns off
};
*/
} // namespace Winix
#endif