diff options
| author | Kevin Smith <git@kismith.co.uk> | 2012-01-10 13:54:31 (GMT) |
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2012-01-10 13:54:31 (GMT) |
| commit | 0f1163c722a39783b07ca6d4027010cb310e7b36 (patch) | |
| tree | f1c282eceb026268494485eab94b86430ac91067 /Swiften | |
| parent | f504079157860a09ba222ea38f1bd799bdb8a1f7 (diff) | |
| download | swift-contrib-0f1163c722a39783b07ca6d4027010cb310e7b36.zip swift-contrib-0f1163c722a39783b07ca6d4027010cb310e7b36.tar.bz2 | |
Don't allow null form fields
Diffstat (limited to 'Swiften')
| -rw-r--r-- | Swiften/Elements/Form.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 47ff7d4..0d1ed63 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -1,52 +1,55 @@ /* * Copyright (c) 2010 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <vector> #include <string> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/FormField.h> #include <Swiften/JID/JID.h> namespace Swift { /** * XEP-0004 Data form. * For the relevant Fields, the parsers and serialisers protect the API user against * the strange multi-value instead of newline thing by transforming them. */ class Form : public Payload { public: typedef boost::shared_ptr<Form> ref; enum Type { FormType, SubmitType, CancelType, ResultType }; public: Form(Type type = FormType) : type_(type) {} - void addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); } + /** Add a field to the form. + * @param field New field - must not be null. + */ + void addField(boost::shared_ptr<FormField> field) {assert(field); fields_.push_back(field); } const std::vector<boost::shared_ptr<FormField> >& getFields() const { return fields_; } void setTitle(const std::string& title) { title_ = title; } const std::string& getTitle() const { return title_; } void setInstructions(const std::string& instructions) { instructions_ = instructions; } const std::string& getInstructions() const { return instructions_; } Type getType() const { return type_; } void setType(Type type) { type_ = type; } std::string getFormType() const; FormField::ref getField(const std::string& name) const; private: std::vector<boost::shared_ptr<FormField> > fields_; std::string title_; std::string instructions_; Type type_; }; } |
Swift