winix/db/dbitemquery.cpp

164 lines
3.1 KiB
C++

/*
* 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-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 "dbitemquery.h"
namespace Winix
{
DbItemQuery::DbItemQuery()
{
Clear();
}
void DbItemQuery::Clear()
{
sort_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