moved winix directories to winixd subdirectory
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1027 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
123
winixd/db/dbitemcolumns.cpp
Normal file
123
winixd/db/dbitemcolumns.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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-2014, 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 = DbBase::AssertValueLong(r, row, id);
|
||||
if( user_id != -1 ) item.user_id = DbBase::AssertValueLong(r, row, user_id);
|
||||
if( group_id != -1 ) item.group_id = DbBase::AssertValueLong(r, row, group_id);
|
||||
if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges);
|
||||
if( date_creation != -1 ) item.date_creation = DbBase::AssertValueDate(r, row, date_creation);
|
||||
if( date_modification != -1 ) item.date_modification = DbBase::AssertValueDate(r, row, date_modification);
|
||||
if( type != -1 ) item.type = static_cast<Item::Type>( DbBase::AssertValueInt(r, row, type) );
|
||||
if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id);
|
||||
if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id);
|
||||
if( link_redirect != -1 ) item.link_redirect = DbBase::AssertValueInt(r, row, link_redirect);
|
||||
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( DbBase::AssertValueInt(r, row, content_type) );
|
||||
if( modification_user_id != -1 ) item.modification_user_id = DbBase::AssertValueLong(r, row, modification_user_id);
|
||||
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs);
|
||||
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type);
|
||||
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb);
|
||||
if( hash != -1 ) DbBase::AssertValueWide(r, row, hash, item.hash);
|
||||
if( hash_type != -1 ) item.hash_type = DbBase::AssertValueInt(r, row, hash_type);
|
||||
if( file_size != -1 ) item.file_size = DbBase::AssertValueLong(r, row, file_size);
|
||||
|
||||
if( ref != -1 ) item.ref = DbBase::AssertValueInt(r, row, ref);
|
||||
if( modify_index != -1 ) item.modify_index = DbBase::AssertValueInt(r, row, modify_index);
|
||||
|
||||
if( url != -1 ) DbBase::AssertValueWide(r, row, url, item.url);
|
||||
if( content != -1 ) DbBase::AssertValueWide(r, row, content, item.content);
|
||||
if( subject != -1 ) DbBase::AssertValueWide(r, row, subject, item.subject);
|
||||
if( file_path != -1 ) DbBase::AssertValueWide(r, row, file_path, item.file_path);
|
||||
if( link_to != -1 ) DbBase::AssertValueWide(r, row, link_to, item.link_to);
|
||||
if( guest_name != -1 ) DbBase::AssertValueWide(r, row, guest_name, item.guest_name);
|
||||
if( html_template != -1 ) DbBase::AssertValueWide(r, row, html_template, item.html_template);
|
||||
if( sort_index != -1 ) item.sort_index = DbBase::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
|
||||
|
||||
|
Reference in New Issue
Block a user