• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

abicollab_types.h

Go to the documentation of this file.
00001 /* Copyright (C) 2008 AbiSource Corporation B.V.
00002  *
00003  * This program is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU General Public License
00005  * as published by the Free Software Foundation; either version 2
00006  * of the License, or (at your option) any later version.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016  * 02110-1301 USA.
00017  */
00018 
00019 #ifndef __ABICOLLAB_TYPES__
00020 #define __ABICOLLAB_TYPES__
00021 
00022 #include <boost/shared_ptr.hpp>
00023 #include "soa.h"
00024 
00025 namespace abicollab {
00026 
00027 class File {
00028 public:
00029     static boost::shared_ptr<File> construct(soa::GenericPtr value) {
00030         if (soa::CollectionPtr coll = value->as<soa::Collection>()) {
00031             boost::shared_ptr<File> file(new File());
00032             if (soa::IntPtr doc_id = coll->get<soa::Int>("doc_id"))
00033                 file->doc_id = boost::lexical_cast<std::string>(doc_id->value());
00034             else if (soa::StringPtr doc_id_ = coll->get<soa::String>("doc_id"))
00035                 // HACK: sometimes the webapp returns the IDs as strings instead of
00036                 // integers. Until the webapp is fixed, we'll just handle both types.
00037                 file->doc_id = doc_id_->value();
00038             if (soa::StringPtr filename_ = coll->get<soa::String>("filename"))
00039                 file->filename = filename_->value();
00040             if (soa::StringPtr tags_ = coll->get<soa::String>("tags"))
00041                 file->tags = tags_->value();
00042             if (soa::StringPtr filesize_ = coll->get<soa::String>("filesize"))
00043                 file->filesize = filesize_->value();
00044             if (soa::StringPtr lastchanged_ = coll->get<soa::String>("lastchanged"))
00045                 file->lastchanged = lastchanged_->value();
00046             if (soa::IntPtr lastrevision_ = coll->get<soa::Int>("lastrevision"))
00047                 file->lastrevision = lastrevision_->value();
00048             if (soa::StringPtr access_ = coll->get<soa::String>("access"))
00049                 file->access = access_->value();
00050             return file;
00051         }
00052         return boost::shared_ptr<File>();
00053     }
00054 
00055     std::string doc_id;
00056     std::string filename;
00057     std::string tags;
00058     std::string filesize;
00059     std::string lastchanged;
00060     int64_t lastrevision;
00061     std::string access;
00062 };
00063 typedef boost::shared_ptr<abicollab::File> FilePtr;
00064 typedef boost::shared_ptr< soa::Array< abicollab::FilePtr > > FileArrayPtr;
00065 
00066 class Friend : public soa::Collection {
00067 public:
00068     Friend(const std::string& n)
00069         : soa::Collection(n)
00070     {}
00071 
00072     static boost::shared_ptr<Friend> construct(soa::GenericPtr value) {
00073         if (soa::CollectionPtr coll = value->as<soa::Collection>()) {
00074             boost::shared_ptr<Friend> friend_(new Friend(coll->name()));
00075             if (soa::IntPtr friend_id_ = coll->get<soa::Int>("friend_id"))
00076                 friend_->friend_id = friend_id_->value();
00077             if (soa::StringPtr name_ = coll->get<soa::String>("name"))
00078                 friend_->name = name_->value();
00079             return friend_;
00080         }
00081         return boost::shared_ptr<Friend>();
00082     }
00083 
00084     int64_t friend_id;
00085     std::string name;
00086 };
00087 typedef boost::shared_ptr<abicollab::Friend> FriendPtr;
00088 typedef boost::shared_ptr< soa::Array< abicollab::FriendPtr > > FriendArrayPtr;
00089 
00090 class Group : public soa::Collection {
00091 public:
00092     Group(const std::string& n)
00093         : soa::Collection(n)
00094     {}
00095 
00096     static boost::shared_ptr<Group> construct(soa::GenericPtr value) {
00097         if (soa::CollectionPtr coll = value->as<soa::Collection>()) {
00098             boost::shared_ptr<Group> group_(new Group(coll->name()));
00099             if (soa::IntPtr group_id_ = coll->get<soa::Int>("group_id"))
00100                 group_->group_id = group_id_->value();
00101             if (soa::StringPtr name_ = coll->get<soa::String>("name"))
00102                 group_->name = name_->value();
00103             return group_;
00104         }
00105         return boost::shared_ptr<Group>();
00106     }
00107 
00108     int64_t group_id;
00109     std::string name;
00110 };
00111 typedef boost::shared_ptr<abicollab::Group> GroupPtr;
00112 typedef boost::shared_ptr< soa::Array< abicollab::GroupPtr > > GroupArrayPtr;
00113 
00114 class FriendFiles : public soa::Collection {
00115 public:
00116     FriendFiles(const std::string& n)
00117         : soa::Collection(n)
00118     {}
00119 
00120     static boost::shared_ptr<FriendFiles> construct(soa::GenericPtr value) {
00121         if (soa::CollectionPtr coll = value->as<soa::Collection>()) {
00122             boost::shared_ptr<FriendFiles> friend_(new FriendFiles(coll->name()));
00123             if (soa::IntPtr friend_id_ = coll->get<soa::Int>("friend_id"))
00124                 friend_->friend_id = friend_id_->value();
00125             if (soa::StringPtr name_ = coll->get<soa::String>("name"))
00126                 friend_->name = name_->value();
00127             if (soa::StringPtr email_ = coll->get<soa::String>("email"))
00128                 friend_->email = email_->value();
00129             friend_->files = coll->get< soa::Array<soa::GenericPtr> >("files");
00130             return friend_;
00131         }
00132         return boost::shared_ptr<FriendFiles>();
00133     }
00134 
00135     int64_t friend_id;
00136     std::string name;
00137     std::string email;
00138     soa::ArrayPtr files;
00139 };
00140 typedef boost::shared_ptr<FriendFiles> FriendFilesPtr;
00141 typedef boost::shared_ptr< soa::Array< FriendFilesPtr > > FriendFilesArrayPtr;
00142 
00143 class GroupFiles : public soa::Collection {
00144 public:
00145     GroupFiles(const std::string& n)
00146         : soa::Collection(n)
00147     {}
00148 
00149     static boost::shared_ptr<GroupFiles> construct(soa::GenericPtr value) {
00150         if (soa::CollectionPtr coll = value->as<soa::Collection>()) {
00151             boost::shared_ptr<GroupFiles> group_(new GroupFiles(coll->name()));
00152             if (soa::IntPtr group_id_ = coll->get<soa::Int>("group_id"))
00153                 group_->group_id = group_id_->value();
00154             if (soa::StringPtr name_ = coll->get<soa::String>("name"))
00155                 group_->name = name_->value();
00156             group_->files = coll->get< soa::Array<soa::GenericPtr> >("files");
00157             return group_;
00158         }
00159         return boost::shared_ptr<GroupFiles>();
00160     }
00161 
00162     int64_t group_id;
00163     std::string name;
00164     soa::ArrayPtr files;
00165 };
00166 typedef boost::shared_ptr<GroupFiles> GroupFilesPtr;
00167 typedef boost::shared_ptr< soa::Array< GroupFilesPtr > > GroupFilesArrayPtr;
00168 
00169 }
00170 
00171 #endif /* __ABICOLLAB_TYPES__ */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1