Exemplo n.º 1
0
		foreach(FormField::ref field, fields) {
			if (field->getName() == "FORM_TYPE") {
				continue;
			}
			serializedCaps += field->getName() + "<";
			std::vector<std::string> values(field->getValues());
			std::sort(values.begin(), values.end());
			foreach(const std::string& value, values) {
				serializedCaps += value + "<";
			}
Exemplo n.º 2
0
std::string fieldValue(Swift::Form::ref form, const std::string &key, const std::string &def) {
	const std::vector<FormField::ref> fields = form->getFields();
	for (std::vector<FormField::ref>::const_iterator it = fields.begin(); it != fields.end(); it++) {
#if HAVE_SWIFTEN_3
		FormField::ref field = *it;
		const std::vector<std::string> values = field->getValues();
		if (field->getName() == key) {
			return values.empty() ? "" : values[0];
		}
#else
		TextSingleFormField::ref textSingle = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<TextSingleFormField>(*it);
		if (textSingle && textSingle->getName() == key) {
			return textSingle->getValue();
		}

		TextPrivateFormField::ref textPrivate = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<TextPrivateFormField>(*it);
		if (textPrivate && textPrivate->getName() == key) {
			return textPrivate->getValue();
		}

		ListSingleFormField::ref listSingle = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<ListSingleFormField>(*it);
		if (listSingle && listSingle->getName() == key) {
			return listSingle->getValue();
		}

		BooleanFormField::ref boolean = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<BooleanFormField>(*it);
		if (boolean && boolean->getName() == key) {
			return boolean->getValue() ? "1" : "0";
		}
#endif
	}

	return def;
}
Exemplo n.º 3
0
	foreach(FormField::ref field, fields_) {
		if (field->getName() == name) {
			return field;
		}
	}