Back to index

unity  6.0.0
ModelRowAdaptor.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #include "ModelRowAdaptor.h"
00021 
00022 namespace unity
00023 {
00024 namespace dash
00025 {
00026 RowAdaptorBase::RowAdaptorBase(DeeModel* model, DeeModelIter* iter, DeeModelTag* tag)
00027   : model_(model)
00028   , iter_(iter)
00029   , tag_(tag)
00030 {}
00031 
00032 RowAdaptorBase::RowAdaptorBase(RowAdaptorBase const& other)
00033 {
00034   model_ = other.model_;
00035   iter_ = other.iter_;
00036   tag_ = other.tag_;
00037 }
00038 
00039 RowAdaptorBase& RowAdaptorBase::operator=(RowAdaptorBase const& other)
00040 {
00041   model_ = other.model_;
00042   iter_ = other.iter_;
00043   tag_ = other.tag_;
00044 
00045   return *this;
00046 }
00047 
00048 std::string RowAdaptorBase::GetStringAt(int position)
00049 {
00050   if (!model_ || !iter_)
00051     return "";
00052   const gchar* value = dee_model_get_string(model_, iter_, position);
00053   if (value)
00054     return value;
00055   else
00056     return ""; // std::strings don't like null.
00057 }
00058 
00059 bool RowAdaptorBase::GetBoolAt(int position)
00060 {
00061   if (!model_ || !iter_)
00062     return 0;
00063   return dee_model_get_bool(model_, iter_, position);
00064 }
00065 
00066 unsigned int RowAdaptorBase::GetUIntAt(int position)
00067 {
00068   if (!model_ || !iter_)
00069     return 0;
00070   return dee_model_get_uint32(model_, iter_, position);
00071 }
00072 
00073 }
00074 }