• Main Page
  • Classes
  • Files
  • File List

Swiften/Elements/Form.h

00001 /*
00002  * Copyright (c) 2010 Kevin Smith
00003  * Licensed under the GNU General Public License v3.
00004  * See Documentation/Licenses/GPLv3.txt for more information.
00005  */
00006 
00007 #pragma once
00008 
00009 #include <vector>
00010 #include <string>
00011 
00012 #include <Swiften/Base/API.h>
00013 #include <Swiften/Elements/Payload.h>
00014 #include <Swiften/Elements/FormField.h>
00015 #include <Swiften/JID/JID.h>
00016 
00017 namespace Swift {
00023   class SWIFTEN_API Form : public Payload {
00024     public:
00025       typedef boost::shared_ptr<Form> ref;
00026       typedef std::vector<FormField::ref> FormItem;
00027 
00028       enum Type { FormType, SubmitType, CancelType, ResultType };
00029 
00030     public:
00031       Form(Type type = FormType) : type_(type) {}
00032 
00036       void addField(boost::shared_ptr<FormField> field) {assert(field);  fields_.push_back(field); }
00037       const std::vector<boost::shared_ptr<FormField> >& getFields() const { return fields_; }
00038       void setTitle(const std::string& title) { title_ = title; }
00039       const std::string& getTitle() const { return title_; }
00040 
00041       void setInstructions(const std::string& instructions) { instructions_ = instructions; }
00042       const std::string& getInstructions() const { return instructions_; }
00043 
00044       Type getType() const { return type_; }
00045       void setType(Type type) { type_ = type; }
00046 
00047       std::string getFormType() const;
00048 
00049       FormField::ref getField(const std::string& name) const;
00050 
00051       void addReportedField(FormField::ref field);
00052       const std::vector<FormField::ref>& getReportedFields() const;
00053 
00054       void addItem(const FormItem& item);
00055       const std::vector<FormItem>& getItems() const;
00056     private:
00057       std::vector<boost::shared_ptr<FormField> > fields_;
00058       std::vector<boost::shared_ptr<FormField> > reportedFields_;
00059       std::vector<FormItem> items_;
00060       std::string title_;
00061       std::string instructions_;
00062       Type type_;
00063   };
00064 }

Generated on Fri Oct 12 2012 21:00:19 for Swiften by  doxygen 1.7.1