edelib 2.0.0

edelib/EdbusList.h

00001 /*
00002  * $Id: EdbusList.h 2839 2009-09-28 11:36:20Z karijes $
00003  *
00004  * D-BUS stuff
00005  * Copyright (c) 2008 edelib authors
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef __EDELIB_EDBUSLIST_H__
00022 #define __EDELIB_EDBUSLIST_H__
00023 
00024 #include "EdbusData.h"
00025 #include "EdbusContainer.h"
00026 
00027 EDELIB_NS_BEGIN
00028 
00114 class EDELIB_API EdbusList : public EdbusContainer<EdbusData> {
00115 private:
00116         bool array_mode;
00117         EdbusList();
00118 
00119 public:
00123         typedef EdbusContainer<EdbusData>::const_iterator const_iterator;
00124 
00129         explicit EdbusList(bool a);
00130 
00134         void append(const EdbusData& val);
00135 
00139         void clear(void);
00140 
00144         void remove(const EdbusData& val);
00145 
00149         void remove_all(const EdbusData& val);
00150 
00154         bool operator==(const EdbusList& other) const;
00155 
00159         bool operator!=(const EdbusList& other) const { return !operator==(other); }
00160 
00165         EdbusDataType value_type(void);
00166 
00171         bool value_type_is_container(void);
00172 
00176         bool list_is_array(void) const { return array_mode; }
00177 
00181         bool list_is_struct(void) const { return !array_mode; }
00182 
00186         const_iterator begin(void) const;
00187 
00192         const_iterator end(void) const;
00193 
00197         unsigned int size(void) const;
00198 
00202         static EdbusList create_array(void) { return EdbusList(true); }
00203 
00207         static EdbusList create_struct(void) { return EdbusList(false); }
00208 };
00209 
00219 inline EdbusList& operator<<(EdbusList& lst, const EdbusData& val) {
00220         lst.append(val);
00221         return lst;
00222 }
00223 
00224 EDELIB_NS_END
00225 #endif