00001
00002
00003
00004
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 }