diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-08-22 21:07:51 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-08-23 08:02:12 (GMT) |
commit | 00284e5f4445a7bbab482196901c5927ea7d5488 (patch) | |
tree | f2ca6e0c51632a8aa5a7a884f3b312bacc3a2fb0 /Swiften/Parser | |
parent | 54da0a4c0cceae947afbde586a97d1cc60c50ed8 (diff) | |
download | swift-00284e5f4445a7bbab482196901c5927ea7d5488.zip swift-00284e5f4445a7bbab482196901c5927ea7d5488.tar.bz2 |
FormField element refactoring.
This should make FormField easier to use.
Change-Id: Ia5eeedcdb673e2fe5e38fd23d5ab00970178bc44
Diffstat (limited to 'Swiften/Parser')
5 files changed, 118 insertions, 198 deletions
diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp index 2df0a85..7c29189 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.cpp +++ b/Swiften/Parser/PayloadParsers/FormParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -10,7 +10,7 @@ namespace Swift { -FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false) { +FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false), parsingOption_(false) { } void FormParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { @@ -36,67 +36,62 @@ void FormParser::handleStartElement(const std::string& element, const std::strin else if (element == "instructions") { currentText_.clear(); } - else if (element == "field") { - std::string type; - FormField::ref correspondingReportedField; - if (!parsingItem_) { - type = attributes.getAttribute("type"); - } else { - foreach(FormField::ref field, getPayloadInternal()->getReportedFields()) { - if (field->getName() == attributes.getAttribute("var")) { - correspondingReportedField = field; - break; - } - } - } - if (type == "boolean" || boost::dynamic_pointer_cast<BooleanFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = BooleanFormFieldParseHelper::create(); - } - else if (type == "fixed" || boost::dynamic_pointer_cast<FixedFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = FixedFormFieldParseHelper::create(); + else if (element == "reported") { + parsingReported_ = true; + } + else if (element == "item") { + parsingItem_ = true; + } + } + else if (level_ == FieldLevel && currentField_) { + currentText_.clear(); + if (element == "option") { + currentOptionLabel_ = attributes.getAttribute("label"); + currentOptionValue_ = ""; + parsingOption_ = true; + } + } + if (level_ >= PayloadLevel) { + if (element == "field") { + currentField_ = boost::make_shared<FormField>(); + std::string type = attributes.getAttribute("type"); + FormField::Type fieldType = FormField::UnknownType; + if (type == "boolean") { + fieldType = FormField::BooleanType; } - else if (type == "hidden" || boost::dynamic_pointer_cast<HiddenFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = HiddenFormFieldParseHelper::create(); + if (type == "fixed") { + fieldType = FormField::FixedType; } - else if (type == "jid-multi" || boost::dynamic_pointer_cast<JIDMultiFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = JIDMultiFormFieldParseHelper::create(); + if (type == "hidden") { + fieldType = FormField::HiddenType; } - else if (type == "jid-single" || boost::dynamic_pointer_cast<JIDSingleFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = JIDSingleFormFieldParseHelper::create(); + if (type == "list-single") { + fieldType = FormField::ListSingleType; } - else if (type == "list-multi" || boost::dynamic_pointer_cast<ListMultiFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = ListMultiFormFieldParseHelper::create(); + if (type == "text-multi") { + fieldType = FormField::TextMultiType; } - else if (type == "list-single" || boost::dynamic_pointer_cast<ListSingleFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = ListSingleFormFieldParseHelper::create(); + if (type == "text-private") { + fieldType = FormField::TextPrivateType; } - else if (type == "text-multi" || boost::dynamic_pointer_cast<TextMultiFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = TextMultiFormFieldParseHelper::create(); + if (type == "text-single") { + fieldType = FormField::TextSingleType; } - else if (type == "text-private" || boost::dynamic_pointer_cast<TextPrivateFormField>(correspondingReportedField)) { - currentFieldParseHelper_ = TextPrivateFormFieldParseHelper::create(); + if (type == "jid-single") { + fieldType = FormField::JIDSingleType; } - else /*if (type == "text-single") || undefined */ { - currentFieldParseHelper_ = TextSingleFormFieldParseHelper::create(); + if (type == "jid-multi") { + fieldType = FormField::JIDMultiType; } - if (currentFieldParseHelper_) { - currentFieldParseHelper_->getField()->setName(attributes.getAttribute("var")); - currentFieldParseHelper_->getField()->setLabel(attributes.getAttribute("label")); + if (type == "list-multi") { + fieldType = FormField::ListMultiType; } + currentField_->setType(fieldType); + currentField_->setName(attributes.getAttribute("var")); + currentField_->setLabel(attributes.getAttribute("label")); } - else if (element == "reported") { - parsingReported_ = true; - level_ = PayloadLevel - 1; - } - else if (element == "item") { - parsingItem_ = true; - level_ = PayloadLevel - 1; - } - } - else if (level_ == FieldLevel && currentFieldParseHelper_) { - currentText_.clear(); - if (element == "option") { - currentOptionLabel_ = attributes.getAttribute("label"); + else if (element == "value") { + currentText_.clear(); } } ++level_; @@ -123,42 +118,48 @@ void FormParser::handleEndElement(const std::string& element, const std::string& getPayloadInternal()->setInstructions(currentInstructions + "\n" + currentText_); } } - else if (element == "field") { - if (currentFieldParseHelper_) { - if (parsingReported_) { - getPayloadInternal()->addReportedField(currentFieldParseHelper_->getField()); - } else if (parsingItem_) { - currentFields_.push_back(currentFieldParseHelper_->getField()); - } else { - getPayloadInternal()->addField(currentFieldParseHelper_->getField()); - } - currentFieldParseHelper_.reset(); - } + else if (element == "reported") { + parsingReported_ = false; + } + else if (element == "item") { + parsingItem_ = false; + getPayloadInternal()->addItem(currentFields_); + currentFields_.clear(); } } - else if (level_ == FieldLevel && currentFieldParseHelper_) { + else if (currentField_) { if (element == "required") { - currentFieldParseHelper_->getField()->setRequired(true); + currentField_->setRequired(true); } else if (element == "desc") { - currentFieldParseHelper_->getField()->setDescription(currentText_); + currentField_->setDescription(currentText_); } else if (element == "option") { - currentFieldParseHelper_->getField()->addOption(FormField::Option(currentOptionLabel_, currentText_)); + currentField_->addOption(FormField::Option(currentOptionLabel_, currentOptionValue_)); + parsingOption_ = false; } else if (element == "value") { - currentFieldParseHelper_->addValue(currentText_); + if (parsingOption_) { + currentOptionValue_ = currentText_; + } + else { + currentField_->addValue(currentText_); + } } } - if (element == "reported") { - parsingReported_ = false; - level_++; - } - else if (element == "item") { - parsingItem_ = false; - level_++; - getPayloadInternal()->addItem(currentFields_); - currentFields_.clear(); + if (level_ >= PayloadLevel && currentField_) { + if (element == "field") { + if (parsingReported_) { + getPayloadInternal()->addReportedField(currentField_); + } + else if (parsingItem_) { + currentFields_.push_back(currentField_); + } + else { + getPayloadInternal()->addField(currentField_); + } + currentField_.reset(); + } } } diff --git a/Swiften/Parser/PayloadParsers/FormParser.h b/Swiften/Parser/PayloadParsers/FormParser.h index ec480a5..0b23a81 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.h +++ b/Swiften/Parser/PayloadParsers/FormParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -18,86 +18,6 @@ namespace Swift { virtual void handleEndElement(const std::string& element, const std::string&); virtual void handleCharacterData(const std::string& data); - private: - class FieldParseHelper { - public: - virtual ~FieldParseHelper() {} - virtual void addValue(const std::string&) = 0; - virtual boost::shared_ptr<FormField> getField() const { - return field; - } - protected: - boost::shared_ptr<FormField> field; - }; - class BoolFieldParseHelper : public FieldParseHelper { - virtual void addValue(const std::string& s) { - boost::dynamic_pointer_cast< GenericFormField<bool> >(getField())->setValue(s == "1" || s == "true"); - getField()->addRawValue(s); - } - }; - class StringFieldParseHelper : public FieldParseHelper { - virtual void addValue(const std::string& s) { - boost::shared_ptr<GenericFormField<std::string> > field = boost::dynamic_pointer_cast< GenericFormField<std::string> >(getField()); - if (field->getValue().empty()) { - field->setValue(s); - } - else { - field->setValue(field->getValue() + "\n" + s); - } - getField()->addRawValue(s); - } - }; - class JIDFieldParseHelper : public FieldParseHelper { - virtual void addValue(const std::string& s) { - getField()->addRawValue(s); - boost::dynamic_pointer_cast< GenericFormField<JID> >(getField())->setValue(JID(s)); - } - }; - class StringListFieldParseHelper : public FieldParseHelper { - virtual void addValue(const std::string& s) { - // FIXME: Inefficient, but too much hassle to do efficiently - boost::shared_ptr<GenericFormField< std::vector<std::string> > > field = boost::dynamic_pointer_cast< GenericFormField<std::vector<std::string > > >(getField()); - std::vector<std::string> l = field->getValue(); - l.push_back(s); - field->setValue(l); - getField()->addRawValue(s); - } - }; - class JIDListFieldParseHelper : public FieldParseHelper { - virtual void addValue(const std::string& s) { - // FIXME: Inefficient, but too much hassle to do efficiently - boost::shared_ptr< GenericFormField< std::vector<JID> > > field = boost::dynamic_pointer_cast< GenericFormField<std::vector<JID > > >(getField()); - std::vector<JID> l = field->getValue(); - l.push_back(JID(s)); - field->setValue(l); - getField()->addRawValue(s); - } - }; - -#define SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(name, baseParser) \ - class name##FormFieldParseHelper : public baseParser##FieldParseHelper { \ - public: \ - typedef boost::shared_ptr<name##FormFieldParseHelper> ref; \ - static ref create() { \ - return ref(new name##FormFieldParseHelper()); \ - } \ - private: \ - name##FormFieldParseHelper() : baseParser##FieldParseHelper() { \ - field = name##FormField::create(); \ - } \ - } - - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(Boolean, Bool); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(Fixed, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(Hidden, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(ListSingle, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(TextMulti, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(TextPrivate, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(TextSingle, String); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(JIDSingle, JID); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(JIDMulti, JIDList); - SWIFTEN_DECLARE_FORM_FIELD_PARSE_HELPER(ListMulti, StringList); - enum Level { TopLevel = 0, PayloadLevel = 1, @@ -106,9 +26,11 @@ namespace Swift { int level_; std::string currentText_; std::string currentOptionLabel_; - boost::shared_ptr<FieldParseHelper> currentFieldParseHelper_; + std::string currentOptionValue_; bool parsingItem_; bool parsingReported_; + bool parsingOption_; + FormField::ref currentField_; std::vector<FormField::ref> currentFields_; }; } diff --git a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp index 20bad8c..ff0a061 100644 --- a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp +++ b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp @@ -96,8 +96,8 @@ void StreamInitiationParser::handleEndElement(const std::string& element, const } } else if (form->getType() == Form::SubmitType) { - if (field->getRawValues().size() > 0) { - getPayloadInternal()->setRequestedMethod(field->getRawValues()[0]); + if (!field->getValues().empty()) { + getPayloadInternal()->setRequestedMethod(field->getValues()[0]); } } } diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp index c36fbeb..bc8f1bc 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -54,13 +54,13 @@ class FormParserTest : public CppUnit::TestFixture { "</field>" "<field label=\"Password for special access\" type=\"text-private\" var=\"password\"/>" "<field label=\"What features will the bot support?\" type=\"list-multi\" var=\"features\">" - "<value>news</value>" - "<value>search</value>" "<option label=\"Contests\"><value>contests</value></option>" "<option label=\"News\"><value>news</value></option>" "<option label=\"Polls\"><value>polls</value></option>" "<option label=\"Reminders\"><value>reminders</value></option>" "<option label=\"Search\"><value>search</value></option>" + "<value>news</value>" + "<value>search</value>" "</field>" "<field label=\"Maximum number of subscribers\" type=\"list-single\" var=\"maxsubs\">" "<value>20</value>" @@ -84,37 +84,35 @@ class FormParserTest : public CppUnit::TestFixture { Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size())); - CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), boost::dynamic_pointer_cast<HiddenFormField>(payload->getFields()[0])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), payload->getFields()[0]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("FORM_TYPE"), payload->getFields()[0]->getName()); CPPUNIT_ASSERT(!payload->getFields()[0]->getRequired()); - CPPUNIT_ASSERT_EQUAL(std::string("Section 1: Bot Info"), boost::dynamic_pointer_cast<FixedFormField>(payload->getFields()[1])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("Section 1: Bot Info"), payload->getFields()[1]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("The name of your bot"), payload->getFields()[2]->getLabel()); - CPPUNIT_ASSERT_EQUAL(std::string("This is a bot.\nA quite good one actually"), boost::dynamic_pointer_cast<TextMultiFormField>(payload->getFields()[3])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("This is a bot.\nA quite good one actually"), payload->getFields()[3]->getTextMultiValue()); - CPPUNIT_ASSERT_EQUAL(true, boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getValue()); + CPPUNIT_ASSERT_EQUAL(true, payload->getFields()[4]->getBoolValue()); CPPUNIT_ASSERT(payload->getFields()[4]->getRequired()); - CPPUNIT_ASSERT_EQUAL(std::string("1"), boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getRawValues()[0]); - - CPPUNIT_ASSERT_EQUAL(std::string("news"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[0]); - CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getRawValues()[0]); - CPPUNIT_ASSERT_EQUAL(std::string("search"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[1]); - CPPUNIT_ASSERT_EQUAL(std::string("search"), payload->getFields()[6]->getRawValues()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("1"), payload->getFields()[4]->getValues()[0]); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFields()[6]->getValues().size())); + CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("search"), payload->getFields()[6]->getValues()[1]); CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(payload->getFields()[6]->getOptions().size())); CPPUNIT_ASSERT_EQUAL(std::string("Contests"), payload->getFields()[6]->getOptions()[0].label); CPPUNIT_ASSERT_EQUAL(std::string("contests"), payload->getFields()[6]->getOptions()[0].value); CPPUNIT_ASSERT_EQUAL(std::string("News"), payload->getFields()[6]->getOptions()[1].label); CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getOptions()[1].value); - CPPUNIT_ASSERT_EQUAL(std::string("20"), boost::dynamic_pointer_cast<ListSingleFormField>(payload->getFields()[7])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("20"), payload->getFields()[7]->getValues()[0]); - CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[0]); - CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[1]); + CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), payload->getFields()[8]->getJIDMultiValue(0)); + CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), payload->getFields()[8]->getJIDMultiValue(1)); CPPUNIT_ASSERT_EQUAL(std::string("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription()); - CPPUNIT_ASSERT_EQUAL(std::string("foo"), boost::dynamic_pointer_cast<TextSingleFormField>(payload->getFields()[9])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->getFields()[9]->getValues()[0]); } void testParse_FormItems() { @@ -157,29 +155,28 @@ class FormParserTest : public CppUnit::TestFixture { Form::FormItem item = items[0]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size()); - CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName()); - JIDSingleFormField::ref jidField = boost::dynamic_pointer_cast<JIDSingleFormField>(item[2]); - CPPUNIT_ASSERT(jidField); - CPPUNIT_ASSERT_EQUAL(JID("benvolio@montague.net"), jidField->getValue()); + boost::shared_ptr<FormField> jidField = item[2]; + CPPUNIT_ASSERT_EQUAL(JID("benvolio@montague.net"), jidField->getJIDSingleValue()); CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName()); item = items[1]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size()); - CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName()); - jidField = boost::dynamic_pointer_cast<JIDSingleFormField>(item[2]); + jidField = item[2]; CPPUNIT_ASSERT(jidField); - CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), jidField->getValue()); + CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), jidField->getJIDSingleValue()); CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp index ef48ced..59ea3ff 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -155,25 +155,25 @@ class SearchPayloadParserTest : public CppUnit::TestFixture { Form::FormItem item = items[0]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size()); - CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("benvolio@montague.net"), item[2]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("benvolio@montague.net"), item[2]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName()); item = items[1]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size()); - CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("romeo@montague.net"), item[2]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("romeo@montague.net"), item[2]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]); CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName()); } }; |